id stringlengths 7 11 | source stringclasses 1
value | category stringclasses 11
values | title stringlengths 15 214 | text stringlengths 70 30.5k | url stringlengths 57 160 | tags stringlengths 3 113 | created_at int64 1.22B 1.79B |
|---|---|---|---|---|---|---|---|
se_79707005 | stackoverflow | DATA_ENGINEERING | Not able to run a spark code due to some issue on my local | Not able to run a spark code due to some issue on my local
I am facing the below error while running the given piece of spark code on my local Pycharm Community Edition and the spark session is not getting created.
I have set up all my local environment variable correctly for jdk and spark both.
FYI I am using java "o... | https://stackoverflow.com/questions/79707005/not-able-to-run-a-spark-code-due-to-some-issue-on-my-local | python, java, apache-spark, pyspark, pyspark-pandas | 1,752,906,934 |
se_78986579 | stackoverflow | DATA_ENGINEERING | "Exception in thread "main" java.lang.UnsatisfiedLinkError: 'boolean org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(java.lang.String, int)' i | "Exception in thread "main" java.lang.UnsatisfiedLinkError: 'boolean org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(java.lang.String, int)' i
Exception in thread "main" java.lang.UnsatisfiedLinkError: 'boolean org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(java.lang.String, int)
... | https://stackoverflow.com/questions/78986579/exception-in-thread-main-java-lang-unsatisfiedlinkerror-boolean-org-apache | apache-spark | 1,726,371,794 |
se_79675582 | stackoverflow | DATA_ENGINEERING | Effective Solution for Spark Left Join Data Skew (Spark 3.2.2) - Broadcast & AQE | Effective Solution for Spark Left Join Data Skew (Spark 3.2.2) - Broadcast & AQE
Problem Description
I'm facing severe data skew issues with Spark left join operations in a Spark 3.2.2 cluster, and none of the common solutions have resolved the problem. Here's the detailed context:
Environment:
Spark version: 3.... | https://stackoverflow.com/questions/79675582/effective-solution-for-spark-left-join-data-skew-spark-3-2-2-broadcast-aqe | sql, apache-spark, hive | 1,750,647,948 |
se_79708005 | stackoverflow | DATA_ENGINEERING | Delta live tables are producing different results | Delta live tables are producing different results
I am trying to perform aggregation on top a table. I applied same aggregation in dlt pipeline and pyspark query. But results are different.
My pyspark query looks like below: -
agg_df = filter_df.groupBy("job_title").pivot("owns_car").count()
The output here is as per... | https://stackoverflow.com/questions/79708005/delta-live-tables-are-producing-different-results | apache-spark, databricks, azure-databricks, delta-live-tables | 1,753,016,334 |
se_66182498 | stackoverflow | DATA_ENGINEERING | How to reduce multiple joins in spark | How to reduce multiple joins in spark
I am using Spark 2.4.1, to figure out some ratios on my data frame.
Where I need to find different ratio factors of ratios, different columns in given data frame(df_data) by joining to meta dataframe (i.e. resDs).
I am getting these ratio factors (i.e. ratio_1_factor, ratio_2_fact... | https://stackoverflow.com/questions/66182498/how-to-reduce-multiple-joins-in-spark | scala, dataframe, apache-spark, pyspark, apache-spark-sql | 1,613,198,700 |
se_76422728 | stackoverflow | DATA_ENGINEERING | Spark JDBC Postgresql Overwrite job - minimise downtime of target table | Spark JDBC Postgresql Overwrite job - minimise downtime of target table
I want to overwrite a Postgresql table transactionStats which is used by the customer facing dashboards.
This table needs to be updated every 30 mins. I will write a AWS Glue Spark job via JDBC connection to perform this operation.
Spark dataframe... | https://stackoverflow.com/questions/76422728/spark-jdbc-postgresql-overwrite-job-minimise-downtime-of-target-table | postgresql, apache-spark, pyspark, jdbc, apache-spark-sql | 1,686,136,567 |
se_41107835 | stackoverflow | DATA_ENGINEERING | Pyspark: Parse a column of json strings | Pyspark: Parse a column of json strings
I have a pyspark dataframe consisting of one column, called json, where each row is a unicode string of json. I'd like to parse each row and return a new dataframe where each row is the parsed json.
# Sample Data Frame
jstr1 = u'{"header":{"id":12345,"foo":"bar"},"body":{"id":1... | https://stackoverflow.com/questions/41107835/pyspark-parse-a-column-of-json-strings | python, json, apache-spark, pyspark | 1,481,569,800 |
se_79705414 | stackoverflow | DATA_ENGINEERING | Spark hint changes query results | Spark hint changes query results
Should adding a hint to a spark query ever return different results? I'm able to reproduce a production issue with the code below. It's worth noting that the last statement is just a copy/pasted version of the prior statement with a hint added. However, the last statement returns 0 rec... | https://stackoverflow.com/questions/79705414/spark-hint-changes-query-results | apache-spark, apache-spark-sql | 1,752,786,922 |
se_79705627 | stackoverflow | DATA_ENGINEERING | Apache Spark Connect is falling back to classic local mode by default | Apache Spark Connect is falling back to classic local mode by default
I'm trying to use Apache Spark Connect from PySpark (version 4.0.0) with the following config:
spark1 = SparkSession.builder \
.config("spark.api.mode", "connect") \
.config("spark.connect.server.address", "sc://192.x.x.x:7077") \
.confi... | https://stackoverflow.com/questions/79705627/apache-spark-connect-is-falling-back-to-classic-local-mode-by-default | apache-spark, pyspark, spark-connect | 1,752,807,615 |
se_79706954 | stackoverflow | DATA_ENGINEERING | Spark SQL Fails to Create Table from Volume-Based Data Source in Databricks | Spark SQL Fails to Create Table from Volume-Based Data Source in Databricks
In Databricks, I uploaded my source data under a volume folder (e.g., /Volumes/my_catalog/my_schema/landing_source/). Now, I want to create a DataFrame or table using this volume path as the source.
1. Using Spark API:
I am able to successfull... | https://stackoverflow.com/questions/79706954/spark-sql-fails-to-create-table-from-volume-based-data-source-in-databricks | apache-spark, pyspark, databricks, azure-data-lake, delta | 1,752,901,784 |
se_79700490 | stackoverflow | DATA_ENGINEERING | Why the Encoder of map(toGroupement(row), Encoders.bean(Groupement.class)) left some null members when toGroupement(...) has already created them? | Why the Encoder of map(toGroupement(row), Encoders.bean(Groupement.class)) left some null members when toGroupement(...) has already created them?
With Spark 3.5.6, I have some complex Row to convert to Java objects.
sirenGroupement
nomGroupement
natureJuridique
sirenCommuneSiege
codeCommuneSiege
nomCommuneSiege
co... | https://stackoverflow.com/questions/79700490/why-the-encoder-of-maptogroupementrow-encoders-beangroupement-class-left | java, apache-spark | 1,752,473,588 |
se_38794522 | stackoverflow | DATA_ENGINEERING | Pandas dataframe to Spark dataframe "Can not merge type error" | Pandas dataframe to Spark dataframe "Can not merge type error"
I have csv data and created Pandas dataframe using read_csv and forcing all columns as string.
Then when I try to create Spark dataframe from the Pandas dataframe, I get the error message below.
from pyspark import SparkContext
from pyspark.sql ... | https://stackoverflow.com/questions/38794522/pandas-dataframe-to-spark-dataframe-can-not-merge-type-error | pandas, apache-spark, dataframe, pyspark, apache-spark-sql | 1,470,416,928 |
se_79704462 | stackoverflow | DATA_ENGINEERING | Apache Spark 2.4.3 Java Job Stuck in "Active" State in Cluster Mode (Java web app with spark java API) — No Errors in Logs | Apache Spark 2.4.3 Java Job Stuck in "Active" State in Cluster Mode (Java web app with spark java API) — No Errors in Logs
I'm running an Apache Spark application (v2.4.3) in standalone cluster mode, developed using the Java Spark API, and deployed from a web application. My Spark job reads and processes 50+... | https://stackoverflow.com/questions/79704462/apache-spark-2-4-3-java-job-stuck-in-active-state-in-cluster-mode-java-web-ap | apache-spark, apache-spark-standalone, spark-ui | 1,752,738,581 |
se_72088067 | stackoverflow | DATA_ENGINEERING | TypeError:Invalid argument, not a string or column | TypeError:Invalid argument, not a string or column
I am trying to do some source to target testing in pyspark. First part I am trying to do is a count of columns using a Lean Six Sigma method making sure there are less than 3/1000000 discrepancies in the columns. When I run this though, the if statement throws a:
Typ... | https://stackoverflow.com/questions/72088067/typeerrorinvalid-argument-not-a-string-or-column | python, pandas, dataframe, apache-spark, pyspark | 1,651,501,124 |
se_79536058 | stackoverflow | DATA_ENGINEERING | create iceberg partitioned table using pypspark | create iceberg partitioned table using pypspark
I want to create an iceberg table with partition using pyspark dataframe. I see how this can be done using spark sql but not with pyspark dataframes.
https://iceberg.apache.org/docs/1.4.3/spark-ddl/#partitioned-by
Can someone help with this? | https://stackoverflow.com/questions/79536058/create-iceberg-partitioned-table-using-pypspark | apache-spark, pyspark, apache-iceberg | 1,742,983,826 |
se_62611515 | stackoverflow | DATA_ENGINEERING | Spark SQL : Why am I seeing 3 jobs instead of one single job in the Spark UI? | Spark SQL : Why am I seeing 3 jobs instead of one single job in the Spark UI?
As per my understanding, there will be one job for each action in Spark.
But often I see there are more than one jobs triggered for a single action.
I was trying to test this by doing a simple aggregation on a dataset to get the maximum from... | https://stackoverflow.com/questions/62611515/spark-sql-why-am-i-seeing-3-jobs-instead-of-one-single-job-in-the-spark-ui | apache-spark, apache-spark-sql, spark-ui | 1,593,269,382 |
se_76051523 | stackoverflow | DATA_ENGINEERING | How to rename the columns inside nested column in pyspark | How to rename the columns inside nested column in pyspark
I have a column product inside which there is a nested column called Color. I want to remove the {} from the column color.
I don't want to flatten the column and rename it. I directly want to rename the column or drop the column.
|-- product: struct (nullable ... | https://stackoverflow.com/questions/76051523/how-to-rename-the-columns-inside-nested-column-in-pyspark | python, apache-spark, pyspark, data-cleaning, azure-synapse | 1,681,887,313 |
se_79677346 | stackoverflow | DATA_ENGINEERING | Does converting an RDD to DataFrame and back affect partitions or data structure inside partitions in Spark? | Does converting an RDD to DataFrame and back affect partitions or data structure inside partitions in Spark?
I’m experimenting with Spark and want to clarify how partitioning behaves when converting between RDDs and DataFrames.
Here’s my example:
rdd1 = sc.parallelize([("a",1), ("b",2), ("c",3), ("d",4)], 4)
print(rdd... | https://stackoverflow.com/questions/79677346/does-converting-an-rdd-to-dataframe-and-back-affect-partitions-or-data-structure | python, apache-spark, pyspark | 1,750,757,553 |
se_76333545 | stackoverflow | DATA_ENGINEERING | How to get metric for a spark pod OOMKilled using prometheus | How to get metric for a spark pod OOMKilled using prometheus
I have a spark executor pod, which when goes to OOMKilled status, I want to alert it. I am exporting spark metrics using prometheus to grafana.
I have tried some queries to
kube_pod_container_status_last_terminated_reason{reason="OOMKilled"}
kube_pod_contain... | https://stackoverflow.com/questions/76333545/how-to-get-metric-for-a-spark-pod-oomkilled-using-prometheus | apache-spark, kubernetes, out-of-memory, prometheus, grafana | 1,685,025,787 |
se_71480044 | stackoverflow | DATA_ENGINEERING | spark-submit with external python packages | spark-submit with external python packages
I am using the python textblob package to calculate the sentiment in a spark job. In order to make the textblob package available on the spark cluster, I created a virtual environment, installed the textblob package in there and packed it using venv-pack. The resulting archiv... | https://stackoverflow.com/questions/71480044/spark-submit-with-external-python-packages | apache-spark, pyspark, textblob | 1,647,337,506 |
se_79695118 | stackoverflow | DATA_ENGINEERING | Can't use pyspark.sql.functions with DataprocSparkSession | Can't use pyspark.sql.functions with DataprocSparkSession
I have code like this on a Google BigQuery notebook
from google.cloud.dataproc_spark_connect import DataprocSparkSession
from pyspark.sql.functions import col, unix_timestamp, expr, dayofweek, round
spark = DataprocSparkSession.builder.getOrCreate()
# SOME... | https://stackoverflow.com/questions/79695118/cant-use-pyspark-sql-functions-with-dataprocsparksession | dataframe, apache-spark, google-cloud-platform, pyspark | 1,752,039,871 |
se_79690400 | stackoverflow | DATA_ENGINEERING | Why is this task taking so long even for a graph with merely 5-6 nodes and edges? | Why is this task taking so long even for a graph with merely 5-6 nodes and edges?
I am trying to implement the Parallelized BFS algorithm using Pyspark.
I am following the material in CS246,
What exactly in my implementation is making this thing take so long?
Pardon me I am just a beginner.
I was trying to implement p... | https://stackoverflow.com/questions/79690400/why-is-this-task-taking-so-long-even-for-a-graph-with-merely-5-6-nodes-and-edges | apache-spark, pyspark, apache-spark-sql, directed-acyclic-graphs | 1,751,642,604 |
se_79694466 | stackoverflow | DATA_ENGINEERING | unable to merge to iceberg table with timestamp column after casting column to timestamp using spark | unable to merge to iceberg table with timestamp column after casting column to timestamp using spark
I have a dataframe with columns that are timestamps, the data is read from a parquet file where the columns in question are definitely strings, but i have looked at each one and they are are "yyyy-MM-dd HH:mm:ss".
I t... | https://stackoverflow.com/questions/79694466/unable-to-merge-to-iceberg-table-with-timestamp-column-after-casting-column-to-t | apache-spark, pyspark, apache-iceberg | 1,751,987,378 |
se_54246761 | stackoverflow | DATA_ENGINEERING | TB data write to parquet | TB data write to parquet
we have 2.5TB data in hbase, and the region size is 5g or 10g, and the hbase table have 450 reigons. and we need transform to spark-sql. and the method used below:
1.snapshot hbase table.
2.read hfile by newHadoopAPIRDD
3.write to parquet.
val hconf = HBaseConfiguration.create()
hconf.set(... | https://stackoverflow.com/questions/54246761/tb-data-write-to-parquet | apache-spark, hbase | 1,547,776,440 |
se_79662229 | stackoverflow | DATA_ENGINEERING | How to update a row in delta table and make sure that old version is removed? | How to update a row in delta table and make sure that old version is removed?
I have a delta table in s3 that I write to via data bricks. The demo code I have is as so:
mount_name = '/mnt/dummy'
col_names = ["id","name"]
rows = [
(
"id1",
"name1"
)
]
df_output = spark.createDataFrame(rows... | https://stackoverflow.com/questions/79662229/how-to-update-a-row-in-delta-table-and-make-sure-that-old-version-is-removed | apache-spark, databricks, delta-lake | 1,749,654,850 |
se_79693769 | stackoverflow | DATA_ENGINEERING | My classes getters and setters are now prefix-less. But Spark isn't able to use their objects correctly, as if get and set prefixes were mandatory | My classes getters and setters are now prefix-less. But Spark isn't able to use their objects correctly, as if get and set prefixes were mandatory
For convenience, I'm switching my business classes to a style where getters and setters methods do not have get and set prefixes anymore. By the way, I'm also making se... | https://stackoverflow.com/questions/79693769/my-classes-getters-and-setters-are-now-prefix-less-but-spark-isnt-able-to-use | java, apache-spark, getter-setter | 1,751,957,259 |
se_79692751 | stackoverflow | DATA_ENGINEERING | Running image as root in podman when Containerfile has defined a USER | Running image as root in podman when Containerfile has defined a USER
Im not sure if this is doable and if it is it would have some security issued related
I have an image with an Apache Spark installation that sets a specific USER 185 in its Containerfile. When I run it normally it runs within the image as user 185. ... | https://stackoverflow.com/questions/79692751/running-image-as-root-in-podman-when-containerfile-has-defined-a-user | apache-spark, pyspark, root, podman, podman-compose | 1,751,885,922 |
se_79688793 | stackoverflow | DATA_ENGINEERING | Spark streaming failing intermittently with llegalStateException: Found no SST files | Spark streaming failing intermittently with llegalStateException: Found no SST files
I'm encountering the following error while trying to upload a RocksDB checkpoint in Databricks:
java.lang.IllegalStateException: Found no SST files during uploading RocksDB checkpoint version 498 with 2332 key(s).
at com.databrick... | https://stackoverflow.com/questions/79688793/spark-streaming-failing-intermittently-with-llegalstateexception-found-no-sst-f | apache-spark, pyspark, apache-spark-sql, databricks, spark-structured-streaming | 1,751,543,587 |
se_79604233 | stackoverflow | DATA_ENGINEERING | How can I do a join on each array element in a column and replace with something from the join table? | How can I do a join on each array element in a column and replace with something from the join table?
I have a table, base_df, with many columns, one of which is an array column:
Id
FruitNames
Col1
Col2
Col3
...
Col99
1
["apple", "banana", "orange"]
...
...
...
...
...
2
["banana"]
...
...
...
...
...
3
["g... | https://stackoverflow.com/questions/79604233/how-can-i-do-a-join-on-each-array-element-in-a-column-and-replace-with-something | apache-spark, pyspark, apache-spark-sql | 1,746,227,891 |
se_79589101 | stackoverflow | DATA_ENGINEERING | Lookback logic in spark scala dataframe | Lookback logic in spark scala dataframe
I am trying to write lookback logic for transactional table as below.
P_ID Desc P_Date
100 ABC 2025-04-23
101 XYZ 2025-04-23
102 LMN 2025-04-23
103 CDE 2025-04-23
101 XYZ 2025-04-15
103 CDE 2025-04-10
I am loading the data day wise in this case for 2024-04-23. Need to find out t... | https://stackoverflow.com/questions/79589101/lookback-logic-in-spark-scala-dataframe | sql, dataframe, scala, apache-spark | 1,745,426,839 |
se_52728741 | stackoverflow | DATA_ENGINEERING | How can I read a XML file Azure Databricks Spark | How can I read a XML file Azure Databricks Spark
I was looking for some info on the MSDN forums but couldn't find a good forum/ While reading on the spark site I've the hint that here I would have better chances.
So bottom line, I want to read a Blob storage where there is a contiguous feed of XML files, all small fil... | https://stackoverflow.com/questions/52728741/how-can-i-read-a-xml-file-azure-databricks-spark | azure, apache-spark, databricks | 1,539,116,369 |
se_70283745 | stackoverflow | DATA_ENGINEERING | Why Spark JDBC infers table schema even when schema is specified? | Why Spark JDBC infers table schema even when schema is specified?
I'm using spark.read.format("jdbc").option("query", tmpSql) to load a table from Mysql, and I can see a query select * from (xxx) where 1=0 from database monitor, later I know this query is used for inferring table schema in Spark.
However when I use sp... | https://stackoverflow.com/questions/70283745/why-spark-jdbc-infers-table-schema-even-when-schema-is-specified | mysql, apache-spark, spark-jdbc | 1,639,013,741 |
se_79691031 | stackoverflow | DATA_ENGINEERING | Error Accessing Volume Data in Databricks Trial: "Maximum Number of Retries Exceeded" | Error Accessing Volume Data in Databricks Trial: "Maximum Number of Retries Exceeded"
I’m currently learning Databricks using a trial account. I created a volume and successfully loaded data into it. However, when trying to access the file using Spark, I encountered the following error:
"The maximum number o... | https://stackoverflow.com/questions/79691031/error-accessing-volume-data-in-databricks-trial-maximum-number-of-retries-exce | apache-spark, databricks, azure-databricks, aws-databricks | 1,751,717,568 |
se_67227558 | stackoverflow | DATA_ENGINEERING | Parsing string using regexp_extract using pyspark | Parsing string using regexp_extract using pyspark
I am trying to split the string to different columns using regular expression
Below is my data
decodeData = [('M|C705|Exx05','2'),
('M|Exx05','4'),
('M|C705 P|Exx05','6'),
('M|C705 P|8960 L|Exx05','7'),('M|C705 P|78|8960','9')]
df = sc.parallelize(decodeData).... | https://stackoverflow.com/questions/67227558/parsing-string-using-regexp-extract-using-pyspark | regex, string, apache-spark, pyspark | 1,619,170,625 |
se_67223763 | stackoverflow | DATA_ENGINEERING | How to regexp_extract if a matching pattern resides anywhere in the string - pyspark | How to regexp_extract if a matching pattern resides anywhere in the string - pyspark
I was trying to get some insights on regexp_extract in pyspark and I tried to do a check with this option to get better understanding.
Below is my dataframe
data = [('2345', 'Checked|by John|for kamal'),
('2398', 'Checked|by John|for ... | https://stackoverflow.com/questions/67223763/how-to-regexp-extract-if-a-matching-pattern-resides-anywhere-in-the-string-pys | regex, apache-spark, pyspark, apache-spark-sql | 1,619,149,805 |
se_79668367 | stackoverflow | DATA_ENGINEERING | Can I Using .cache() in the Middle of a Spark SQL Chain? | Can I Using .cache() in the Middle of a Spark SQL Chain?
The code example here:
val results = readFromMyDB("url")
.cache()
.flatMap(flatMyResults)
.repartition()
results.write.parquet(outputS3Path)
val total = results.count(),
println(total)
I checked the graph, I didn't find any ... | https://stackoverflow.com/questions/79668367/can-i-using-cache-in-the-middle-of-a-spark-sql-chain | scala, apache-spark, apache-spark-sql | 1,750,121,613 |
se_79690716 | stackoverflow | DATA_ENGINEERING | Is there another way to construct this column in pyspark that avoids an iterative algorithm? | Is there another way to construct this column in pyspark that avoids an iterative algorithm?
I have two dataframes, df1:
| attribute1 | attribute2 |
| -------- | -------- |
| value1 | value2 |
| value1 | value4 |
This is a dataframe with around 20 million rows.
And df2:
| attribute1... | https://stackoverflow.com/questions/79690716/is-there-another-way-to-construct-this-column-in-pyspark-that-avoids-an-iterativ | apache-spark, pyspark, optimization, iteration | 1,751,671,070 |
se_79491630 | stackoverflow | DATA_ENGINEERING | apache spark-submit to local k8s cluster fails despite having the necessary edit rbac setup | apache spark-submit to local k8s cluster fails despite having the necessary edit rbac setup
I have created the necessary serviceaccount and clusterrolebinding with edit clusterrole but still fails to submit to a local k8s cluster:
$ spark-submit --master k8s://https://127.0.0.1:16443 --conf spark.executor.instances=1 ... | https://stackoverflow.com/questions/79491630/apache-spark-submit-to-local-k8s-cluster-fails-despite-having-the-necessary-edit | apache-spark, kubernetes, pyspark, python-3.12, kubernetes-rbac | 1,741,336,074 |
se_78532812 | stackoverflow | DATA_ENGINEERING | When reading a CSV file directly using Databricks SQL how to set options like use the first line as header | When reading a CSV file directly using Databricks SQL how to set options like use the first line as header
I'd like to use the following syntax to read data directly from a CSV file:
SELECT * FROM csv.`/Volumes/main/pokemon/data/pokemon.csv`
And it works, but I'd also like to set the option to use the first line as t... | https://stackoverflow.com/questions/78532812/when-reading-a-csv-file-directly-using-databricks-sql-how-to-set-options-like-us | sql, apache-spark, databricks | 1,716,648,694 |
se_79614126 | stackoverflow | DATA_ENGINEERING | Spark Executor OOM Error with Adaptive Query Execution enabled | Spark Executor OOM Error with Adaptive Query Execution enabled
We have Databricks Spark Job with spark.sql.autoBroadcastJoinThreshold: "-1". After migration from Databricks Runtime 10.4 to 15.4 one of our Spark jobs which uses broadcast hint started to fail with error:
ERROR Executor: Exception in task 2.0 in stage 37... | https://stackoverflow.com/questions/79614126/spark-executor-oom-error-with-adaptive-query-execution-enabled | apache-spark, databricks, azure-databricks | 1,746,794,048 |
se_46030123 | stackoverflow | DATA_ENGINEERING | In PySpark RDD, how to use foreachPartition() to print out the first record of each partition? | In PySpark RDD, how to use foreachPartition() to print out the first record of each partition?
In PySpark RDD, how to use foreachPartition() to print out the first record of each partition? | https://stackoverflow.com/questions/46030123/in-pyspark-rdd-how-to-use-foreachpartition-to-print-out-the-first-record-of-e | apache-spark, pyspark, rdd | 1,504,497,735 |
se_79682788 | stackoverflow | DATA_ENGINEERING | How can I enforce repartitioning of a pyspark dataframe using a column such that each value of that column goes to its own partition? | How can I enforce repartitioning of a pyspark dataframe using a column such that each value of that column goes to its own partition?
I am running Spark 3.5.3 with Python 3.12.3. I have created a dataframe like this:
df = spark.createDataFrame(data=[(1, "Tom"), (1, "Mitchell"), (2, "Alice"), (0, "Max"), (3, "Bob"), (3... | https://stackoverflow.com/questions/79682788/how-can-i-enforce-repartitioning-of-a-pyspark-dataframe-using-a-column-such-that | apache-spark, pyspark | 1,751,093,332 |
se_60698056 | stackoverflow | DATA_ENGINEERING | parquet int96 timestamp conversion to datetime/date via python | parquet int96 timestamp conversion to datetime/date via python
TL;DR
I'd like to convert an int96 value such as ACIE4NxJAAAKhSUA into a readable timestamp format like 2020-03-02 14:34:22 or whatever that could be normally interpreted...I mostly use python so I'm looking to build a function that does this conversion. ... | https://stackoverflow.com/questions/60698056/parquet-int96-timestamp-conversion-to-datetime-date-via-python | python, apache-spark, casting, timestamp, parquet | 1,584,309,358 |
se_63609363 | stackoverflow | DATA_ENGINEERING | Skip first line of a csv file in scala | Skip first line of a csv file in scala
I want to read and write a csv file ignoring the first line as the header starts from second line.
val df =df1.withColumn("index", monotonicallyIncreasingId()).filter(col("index") > 1).drop("index")
This does not resolves my issue. | https://stackoverflow.com/questions/63609363/skip-first-line-of-a-csv-file-in-scala | scala, dataframe, apache-spark, databricks | 1,598,503,584 |
se_79686358 | stackoverflow | DATA_ENGINEERING | Spark Dynamic Resource Allocation Configuration while using IBM S3 Shuffle Plugin on EMR on EKS | Spark Dynamic Resource Allocation Configuration while using IBM S3 Shuffle Plugin on EMR on EKS
I have successfully implemented the IBM S3 Shuffle Plugin v0.9.6 (https://github.com/IBM/spark-s3-shuffle)
on EMR on EKS (Spark 3.5.0) and the shuffle operations are
working correctly with S3 storage. However, Dynamic Resou... | https://stackoverflow.com/questions/79686358/spark-dynamic-resource-allocation-configuration-while-using-ibm-s3-shuffle-plugi | apache-spark, amazon-eks, amazon-emr, karpenter | 1,751,387,174 |
se_79677327 | stackoverflow | DATA_ENGINEERING | Hive 4.0.1 doesn't work because of Jar files not found | Hive 4.0.1 doesn't work because of Jar files not found
Hive 4.0.1 doesn't work because of Jar files not found. I want to use hive integrated with hadoop 3.4.1 to query data on apache spark.
I tried to type in ./hive/bin/hive and expected it to return >hive in the terminal.
Instead I got the following error:
ls: :/... | https://stackoverflow.com/questions/79677327/hive-4-0-1-doesnt-work-because-of-jar-files-not-found | apache-spark, hadoop, hive | 1,750,756,655 |
se_76072664 | stackoverflow | DATA_ENGINEERING | Convert PySpark Dataframe to Pandas Dataframe fails on timestamp column | Convert PySpark Dataframe to Pandas Dataframe fails on timestamp column
I create my pyspark dataframe:
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType, StructField, BinaryType, ArrayType, StringType, TimestampType
input_schema = StructType([
StructField("key", StringType()... | https://stackoverflow.com/questions/76072664/convert-pyspark-dataframe-to-pandas-dataframe-fails-on-timestamp-column | python, pandas, dataframe, apache-spark, pyspark | 1,682,076,081 |
se_48269880 | stackoverflow | DATA_ENGINEERING | Why does this PySpark join fail? | Why does this PySpark join fail?
I misunderstand the performance of PySpark in the following example.
I have several DataFrame's and I join them consequently.
print"users_data"
print users_data.show()
print"calc"
print calc.show()
print"users_cat_data"
print users_cat_data.show()
data1 = calc.join(users_data, ['cat... | https://stackoverflow.com/questions/48269880/why-does-this-pyspark-join-fail | apache-spark, pyspark, apache-spark-sql | 1,516,046,465 |
se_54577747 | stackoverflow | DATA_ENGINEERING | How to calculate No of cores,executors, amount of memory in Spark Job | How to calculate No of cores,executors, amount of memory in Spark Job
Can someone help me in finding the no of cores,executors,memory ..etc in spark.
I am using open source apache spark cluster
below is my configuration -
Total 6 nodes(1 master and 5 slaves).
32GB per node
16 vCPUS per node
Note - seems like m... | https://stackoverflow.com/questions/54577747/how-to-calculate-no-of-cores-executors-amount-of-memory-in-spark-job | scala, apache-spark | 1,549,556,396 |
se_48334634 | stackoverflow | DATA_ENGINEERING | How to make BSON document splitable in Spark so it can be processed parallely? | How to make BSON document splitable in Spark so it can be processed parallely?
I am querying MongoDB from Spark program. it's returning BSON document. Since BSON is not a splittable format its processing it sequentially with only one executor even though it has multiple available.
One solution I came to know is to S... | https://stackoverflow.com/questions/48334634/how-to-make-bson-document-splitable-in-spark-so-it-can-be-processed-parallely | mongodb, apache-spark, split, compression, bson | 1,516,339,658 |
se_53252181 | stackoverflow | DATA_ENGINEERING | Python worker failed to connect back | Python worker failed to connect back
I'm trying to complete this Spark tutorial.
After installing Spark on local machine (Win10 64, Python 3, Spark 2.4.0) and setting all env variables (HADOOP_HOME, SPARK_HOME, etc) I'm trying to run a simple WordCount.py Spark application:
from pyspark import SparkContext, SparkConf
... | https://stackoverflow.com/questions/53252181/python-worker-failed-to-connect-back | python, windows, apache-spark, pyspark, local | 1,541,963,196 |
se_79680933 | stackoverflow | DATA_ENGINEERING | Spark Unit test failing maven test but pass in IntelliJ | Spark Unit test failing maven test but pass in IntelliJ
I'm working on a Scala project using Spark (with Hive support in some tests) and running unit and integration tests via both IntelliJ and Maven Surefire.
I have a shared test session setup like this:
SharedSparkSession trait (base)
SharedUnitTestSparkSession (no ... | https://stackoverflow.com/questions/79680933/spark-unit-test-failing-maven-test-but-pass-in-intellij | java, scala, maven, apache-spark, hadoop | 1,750,958,431 |
se_70333435 | stackoverflow | DATA_ENGINEERING | Avro schema evolution(backward compatibility) return null with pyspark structured streaming | Avro schema evolution(backward compatibility) return null with pyspark structured streaming
Avro backward compatibility return null record.
I send a record endoded by schema_ver1.avsc, and a record encoded by schema_ver2.avsc to kafka,
then, I query pyspark Streaming memory sink named avro_sink3 decode by ver2 schema(... | https://stackoverflow.com/questions/70333435/avro-schema-evolutionbackward-compatibility-return-null-with-pyspark-structure | apache-spark, pyspark, apache-kafka, avro | 1,639,392,557 |
se_79682724 | stackoverflow | DATA_ENGINEERING | Using AWS Glue, how can I process different file types in a folder to their own Glue table | Using AWS Glue, how can I process different file types in a folder to their own Glue table
I am new to AWS Glue, Apache Spark and all things big data.
I have files being delivered to S3 with the following structure.
s3://raw-data/dd-mm-yyyy/<source>/<product>/<reportType>/[0-9]/[0-9]/<uid>
e.g.
s3://raw-data/2025-06-2... | https://stackoverflow.com/questions/79682724/using-aws-glue-how-can-i-process-different-file-types-in-a-folder-to-their-own | apache-spark, aws-glue | 1,751,086,106 |
se_79681034 | stackoverflow | DATA_ENGINEERING | EMR on EKS: Dynamic Allocation + FSx Lustre -- Executors with shuffle data won't terminate despite idle timeout | EMR on EKS: Dynamic Allocation + FSx Lustre -- Executors with shuffle data won't terminate despite idle timeout
Having trouble getting dynamic allocation to properly terminate idle executors when using FSx Lustre for shuffle persistence on EMR 7.8 (Spark 3.5.4) on EKS. Trying this strategy out to battle cost via ... | https://stackoverflow.com/questions/79681034/emr-on-eks-dynamic-allocation-fsx-lustre-executors-with-shuffle-data-wont | apache-spark, amazon-eks, amazon-emr, amazon-fsx | 1,750,964,354 |
se_79682291 | stackoverflow | DATA_ENGINEERING | How to convert PySpark dataframe into a list of dictionaries grouped by a column | How to convert PySpark dataframe into a list of dictionaries grouped by a column
I have a PySpark dataframe that looks like:
A
B
C
D
E
1
a
0
metric4
value6
1
a
0
metric3
value7
1
b
1
metric2
value5
2
b
0
metric4
value8
2
c
0
metric3
value9
I want to groupby on column A and get following output:
A
... | https://stackoverflow.com/questions/79682291/how-to-convert-pyspark-dataframe-into-a-list-of-dictionaries-grouped-by-a-column | python, apache-spark, pyspark, databricks | 1,751,045,001 |
se_30283415 | stackoverflow | DATA_ENGINEERING | Calculating duration by subtracting two datetime columns in string format | Calculating duration by subtracting two datetime columns in string format
I have a Spark Dataframe in that consists of a series of dates:
from pyspark.sql import SQLContext
from pyspark.sql import Row
from pyspark.sql.types import *
sqlContext = SQLContext(sc)
import pandas as pd
rdd = sc.parallelizesc.parallelize([... | https://stackoverflow.com/questions/30283415/calculating-duration-by-subtracting-two-datetime-columns-in-string-format | apache-spark, datetime, pyspark, apache-spark-sql, timestamp | 1,431,837,413 |
se_71190684 | stackoverflow | DATA_ENGINEERING | spark - what is F string for the date/time format? | spark - what is F string for the date/time format?
Spark document Datetime Patterns for Formatting and Parsing says F is about aligned day of week in month but what does it mean?
Symbol
Meaning
Presentation
Examples
E
day-of-week
text
Tue; Tuesday
F
aligned day of week in month
number(1)
3
For both 2007-11... | https://stackoverflow.com/questions/71190684/spark-what-is-f-string-for-the-date-time-format | apache-spark, date, datetime, pyspark, apache-spark-sql | 1,645,320,852 |
se_25006607 | stackoverflow | DATA_ENGINEERING | How to get day of week in Spark SQL? | How to get day of week in Spark SQL?
I am trying to select all the records recorded on Sunday using Spark SQL.
I have unsuccessfully tried this:
SELECT * FROM mytable WHERE DATEPART(WEEKDAY, create_time) = 0
SELECT * FROM mytable WHERE strftime("%w", create_time) = 0
How to get day of week from date/timestamp in Spar... | https://stackoverflow.com/questions/25006607/how-to-get-day-of-week-in-spark-sql | sql, apache-spark, date, apache-spark-sql, dayofweek | 1,406,594,808 |
se_57742725 | stackoverflow | DATA_ENGINEERING | Get weekday name from date in PySpark | Get weekday name from date in PySpark
I use this code to return the day name from a date of type string:
import Pandas as pd
df = pd.Timestamp("2019-04-10")
print(df.weekday_name)
so when I have "2019-04-10" the code returns "Wednesday"
I would like to apply it a column in PySpark DataFrame to get the day name in tex... | https://stackoverflow.com/questions/57742725/get-weekday-name-from-date-in-pyspark | dataframe, apache-spark, date, pyspark, dayofweek | 1,567,303,165 |
se_50138118 | stackoverflow | DATA_ENGINEERING | How to extract week day as a number from a Spark dataframe with the Scala API | How to extract week day as a number from a Spark dataframe with the Scala API
I have a date column which is string in dataframe in the 2017-01-01 12:15:43 timestamp format.
I want to get weekday number (1 to 7) from that column using dataframe and Scala (not Spark SQL).
Like below
df.select(weekday(col("colname")))
I... | https://stackoverflow.com/questions/50138118/how-to-extract-week-day-as-a-number-from-a-spark-dataframe-with-the-scala-api | dataframe, scala, apache-spark, apache-spark-sql, dayofweek | 1,525,274,340 |
se_38928919 | stackoverflow | DATA_ENGINEERING | How to get the weekday from day of month using PySpark | How to get the weekday from day of month using PySpark
I have a dataframe log_df:
I generate a new dataframe based on the following code:
from pyspark.sql.functions import split, regexp_extract
split_log_df = log_df.select(regexp_extract('value', r'^([^\s]+\s)', 1).alias('host'),
regexp_ext... | https://stackoverflow.com/questions/38928919/how-to-get-the-weekday-from-day-of-month-using-pyspark | apache-spark, pyspark, apache-spark-sql, timestamp, dayofweek | 1,471,059,112 |
se_79681171 | stackoverflow | DATA_ENGINEERING | combining JSON strings into one JSON array | combining JSON strings into one JSON array
I've got a dataframe that basically has a "key" column and a column that is a JSON string.
key
jsonString
111
{"id" : "12345", "foo" : "stuff"}
111
{"id" : "23456", "bar" : "other stuff"}
111
{"id" : "34567", "baz" : "even other stuff"}
For each "key" value, I w... | https://stackoverflow.com/questions/79681171/combining-json-strings-into-one-json-array | apache-spark, databricks | 1,750,973,423 |
se_79680348 | stackoverflow | DATA_ENGINEERING | Latency too high for a spark structured streaming job | Latency too high for a spark structured streaming job
I am running a structured streaming workflow in Databricks that is reading data stream from Kinesis. And then I am writing this data to external delta table (on s3). This workflow is running 4 streams that are reading from the same kinesis. I am using the following... | https://stackoverflow.com/questions/79680348/latency-too-high-for-a-spark-structured-streaming-job | apache-spark, spark-streaming, spark-structured-streaming, amazon-kinesis | 1,750,935,081 |
se_57057648 | stackoverflow | DATA_ENGINEERING | List all additional jars loaded in pyspark | List all additional jars loaded in pyspark
I want to see the jars that my spark context is using.
I found the code in Scala:
$ spark-shell --jars --master=spark://datasci:7077 --jars /opt/jars/xgboost4j-spark-0.7-jar-with-dependencies.jar --packages elsevierlabs-os:spark-xml-utils:1.6.0
scala> spark.sparkContext.list... | https://stackoverflow.com/questions/57057648/list-all-additional-jars-loaded-in-pyspark | apache-spark, pyspark | 1,563,281,302 |
se_74564803 | stackoverflow | DATA_ENGINEERING | Add new column with pandas API on spark to dataframe | Add new column with pandas API on spark to dataframe
Context: I'm trying to add a new column in a dataframe that was initially created with spark reading a parquet file and then converted to dataframe using pandas API on spark as following:
import pyspark.pandas as ps
df = spark.read.parquet(file)
psdf = ps.DataFrame... | https://stackoverflow.com/questions/74564803/add-new-column-with-pandas-api-on-spark-to-dataframe | python, pandas, dataframe, apache-spark | 1,669,313,463 |
se_30949202 | stackoverflow | DATA_ENGINEERING | Spark DataFrame TimestampType - how to get Year, Month, Day values from field? | Spark DataFrame TimestampType - how to get Year, Month, Day values from field?
I have Spark DataFrame with take(5) top rows as follows:
import datetime
[Row(date=datetime.datetime(1984, 1, 1, 0, 0), hour=1, value=638.55),
Row(date=datetime.datetime(1984, 1, 1, 0, 0), hour=2, value=638.55),
Row(date=datetime.datetim... | https://stackoverflow.com/questions/30949202/spark-dataframe-timestamptype-how-to-get-year-month-day-values-from-field | apache-spark, date, datetime, pyspark, timestamp | 1,434,761,510 |
se_49120835 | stackoverflow | DATA_ENGINEERING | Replace duplicate columns in data frame | Replace duplicate columns in data frame
I have a data frame in pyspark. This data frame has say some columns with special characters.
cols = df.schema.names
cols
['abc test', 'test*abc', 'eng)test', 'abc_&test']
reps = ((' ', '_&'), ('(', '*_'), (')', '_*'), ('{', '#_'), ('}', '_#'), (';', '_##'), ('.', '_$'), (','... | https://stackoverflow.com/questions/49120835/replace-duplicate-columns-in-data-frame | python, apache-spark, pyspark | 1,520,290,513 |
se_79627670 | stackoverflow | DATA_ENGINEERING | Pandas zstd compression level 10 better than Apache Spark's | Pandas zstd compression level 10 better than Apache Spark's
For the same compression level of 10 using zstd with Parquet, I get significantly better performance in Pandas than from Apache Spark. The following files, for example, were first generated using Spark and then loaded and saved using python shell. Why is ... | https://stackoverflow.com/questions/79627670/pandas-zstd-compression-level-10-better-than-apache-sparks | pandas, apache-spark, parquet, zstd, parquet-mr | 1,747,588,725 |
se_25407550 | stackoverflow | DATA_ENGINEERING | How do I log from my Python Spark script | How do I log from my Python Spark script
I have a Python Spark program which I run with spark-submit. I want to put logging statements in it.
logging.info("This is an informative message.")
logging.debug("This is a debug message.")
I want to use the same logger that Spark is using so that the log messages come out ... | https://stackoverflow.com/questions/25407550/how-do-i-log-from-my-python-spark-script | python, apache-spark, logging, python-logging | 1,408,545,426 |
se_78649534 | stackoverflow | DATA_ENGINEERING | How to achieve max(column_a) keep (dense_rank last order by column_b) in databricks? | How to achieve max(column_a) keep (dense_rank last order by column_b) in databricks?
I have a sql in oracle that I need to convert to databricks. Is there a databricks equivalent to the
max() keep (dense_rank order by)?
select
id,
max(column_a) keep (dense_rank last order by column_b)
group by id; | https://stackoverflow.com/questions/78649534/how-to-achieve-maxcolumn-a-keep-dense-rank-last-order-by-column-b-in-databri | oracle-database, apache-spark, databricks | 1,718,916,806 |
se_55063736 | stackoverflow | DATA_ENGINEERING | Add month number column from timestamp column | Add month number column from timestamp column
I have a time column, with timestamps in the form 2018-04-12 06:48:39. How can I add a column Month from this timestamp, in this case containing 4? | https://stackoverflow.com/questions/55063736/add-month-number-column-from-timestamp-column | apache-spark, pyspark, apache-spark-sql | 1,552,049,906 |
se_35762459 | stackoverflow | DATA_ENGINEERING | Add Jar to standalone pyspark | Add Jar to standalone pyspark
I'm launching a pyspark program:
$ export SPARK_HOME=
$ export PYTHONPATH=$SPARK_HOME/python:$SPARK_HOME/python/lib/py4j-0.9-src.zip
$ python
And the py code:
from pyspark import SparkContext, SparkConf
conf = SparkConf().setAppName("Example").setMaster("local[2]")
sc = SparkContext(con... | https://stackoverflow.com/questions/35762459/add-jar-to-standalone-pyspark | python, apache-spark, pyspark | 1,456,974,637 |
se_79185163 | stackoverflow | DATA_ENGINEERING | Why do I need to use dataframe to work with queries in databricks? | Why do I need to use dataframe to work with queries in databricks?
I'm learning databricks with a friend and one thing I really do not get it.
I'm trying to query using pyspark and spark sql in a json file that is in a storage account in azure.
The path of the file in azure is this: 'abfss://raw@estudos.dfs.core.windo... | https://stackoverflow.com/questions/79185163/why-do-i-need-to-use-dataframe-to-work-with-queries-in-databricks | apache-spark, pyspark, apache-spark-sql, databricks | 1,731,505,217 |
se_79664911 | stackoverflow | DATA_ENGINEERING | Spark slows down when computing RDDs together | Spark slows down when computing RDDs together
I am trying to optimize my Spark code.
Initial Code :
Dataset<Row> df = spark.read()
.option("header", "true")
.csv("/opt/spark/data/Input.csv");
// Get column indices once
java.util.Map<String, Integer> columnIndice... | https://stackoverflow.com/questions/79664911/spark-slows-down-when-computing-rdds-together | apache-spark | 1,749,820,736 |
se_79677016 | stackoverflow | DATA_ENGINEERING | Spark Kafka Streaming Not Picking Up Next group_id Messages, But Batch Read Succeeds | Spark Kafka Streaming Not Picking Up Next group_id Messages, But Batch Read Succeeds
Issue: Kafka Structured Streaming Not Processing Next group_id Messages
I'm working on a PySpark Structured Streaming job that reads from a Kafka topic and processes records in batches using foreachBatch. I'm using a custom logic that... | https://stackoverflow.com/questions/79677016/spark-kafka-streaming-not-picking-up-next-group-id-messages-but-batch-read-succ | python, apache-spark, apache-kafka | 1,750,740,940 |
se_79671403 | stackoverflow | DATA_ENGINEERING | Use Spark ML in Scala using Spark Connect | Use Spark ML in Scala using Spark Connect
I want to use Spark ML APIs in my already existing Scala project using Spark Connect to remotely execute the code in Spark clusters. When I try to import org.apache.spark.ml it doesn't exists. I am using Scala 2.13 with Spark Connect Client JVM 4.0.0. Am I missing something?
M... | https://stackoverflow.com/questions/79671403/use-spark-ml-in-scala-using-spark-connect | java, scala, apache-spark, apache-spark-ml, spark-connect | 1,750,290,736 |
se_49654050 | stackoverflow | DATA_ENGINEERING | Could not bind on a random free port error while trying to connect to spark master | Could not bind on a random free port error while trying to connect to spark master
I have a spark master running on amazon ec2.
I tried to connect to it using pyspark as follows from another ec2 instance as follows:
spark = SparkSession.builder.appName("MyApp") \
.master("spark_url_as_obtai... | https://stackoverflow.com/questions/49654050/could-not-bind-on-a-random-free-port-error-while-trying-to-connect-to-spark-mast | python-3.x, apache-spark, amazon-ec2, pyspark | 1,522,853,204 |
se_79675115 | stackoverflow | DATA_ENGINEERING | How to dynamically load JARs in a SparkApplication from PySpark | How to dynamically load JARs in a SparkApplication from PySpark
I am writing a framework on top of PySpark 3.5.5.
My code tries to determine during runtime which JARs are required for certain operations and then load them when creating SparkSessions.
While this all works nicely on a local driver, it fails when submitt... | https://stackoverflow.com/questions/79675115/how-to-dynamically-load-jars-in-a-sparkapplication-from-pyspark | java, apache-spark, pyspark | 1,750,592,635 |
se_77327653 | stackoverflow | DATA_ENGINEERING | hadoop-common / hadoop-aws / aws-java-sdk-bundle version compatibility? | hadoop-common / hadoop-aws / aws-java-sdk-bundle version compatibility?
I'm getting this exception on a worker when trying to read from S3:
java.lang.NoSuchMethodError: 'java.lang.Object org.apache.hadoop.fs.statistics.impl.IOStatisticsBinding.invokeTrackingDuration(org.apache.hadoop.fs.statistics.DurationTracker, org... | https://stackoverflow.com/questions/77327653/hadoop-common-hadoop-aws-aws-java-sdk-bundle-version-compatibility | apache-spark, amazon-s3 | 1,697,760,231 |
se_55029788 | stackoverflow | DATA_ENGINEERING | How to retrieve the month from a date column values in scala dataframe? | How to retrieve the month from a date column values in scala dataframe?
Given:
val df = Seq((1L, "04-04-2015")).toDF("id", "date")
val df2 = df.withColumn("month", from_unixtime(unix_timestamp($"date", "dd/MM/yy"), "MMMMM"))
df2.show()
I got this output:
+---+----------+-----+
| id| date|month|
+---+---------... | https://stackoverflow.com/questions/55029788/how-to-retrieve-the-month-from-a-date-column-values-in-scala-dataframe | scala, apache-spark, dataframe, apache-spark-sql | 1,551,896,400 |
se_53297872 | stackoverflow | DATA_ENGINEERING | How can I sum multiple columns in a spark dataframe in pyspark? | How can I sum multiple columns in a spark dataframe in pyspark?
I've got a list of column names I want to sum
columns = ['col1','col2','col3']
How can I add the three and put it in a new column ? (in an automatic way, so that I can change the column list and have new results)
Dataframe with result I want:
col1 col2... | https://stackoverflow.com/questions/53297872/how-can-i-sum-multiple-columns-in-a-spark-dataframe-in-pyspark | python, apache-spark, pyspark, apache-spark-sql | 1,542,190,901 |
se_79608619 | stackoverflow | DATA_ENGINEERING | Airflow Submit PySpark Job to Remote Spark | Airflow Submit PySpark Job to Remote Spark
I have airflow in machine A and Spark (master and several worker) in machine B. The spark is in standalone mode (i.e I don't use kubernetes or YARN). Both spark and airflow are deployed using docker. I want airflow to submit spark job to machine B with the master acting as a ... | https://stackoverflow.com/questions/79608619/airflow-submit-pyspark-job-to-remote-spark | docker, apache-spark, pyspark, airflow, minio | 1,746,531,255 |
se_79612400 | stackoverflow | DATA_ENGINEERING | Try follow Spark QuickStart on Docker spark:python3 container | Try follow Spark QuickStart on Docker spark:python3 container
I try to follow Spark QuickStart on quick-start in the Spark documentation. I'm having trouble since I'm using a Docker container (spark: python 3).
The main issue is that instructions order to find a file README.md but the docker is initiated on /opt/spark... | https://stackoverflow.com/questions/79612400/try-follow-spark-quickstart-on-docker-sparkpython3-container | apache-spark, pyspark | 1,746,707,976 |
se_39750630 | stackoverflow | DATA_ENGINEERING | Using curl within a Databricks+Spark notebook | Using curl within a Databricks+Spark notebook
I'm running a Spark cluster using Databricks. I'd like to transfer data from a server using curl. For example,
curl -H "Content-Type: application/json" -H "auth:xxxx" -X GET "https://websites.net/Automation/Offline?startTimeInclusive=201609240100&endTimeExclusive=2016092... | https://stackoverflow.com/questions/39750630/using-curl-within-a-databricksspark-notebook | curl, apache-spark, databricks | 1,475,073,467 |
se_79671409 | stackoverflow | DATA_ENGINEERING | Unable to load org.apache.spark.sql.delta classes from JVM pyspark | Unable to load org.apache.spark.sql.delta classes from JVM pyspark
I’m working on Databricks with a cluster running Runtime 16.4, which includes Spark 3.5.2 and Scala 2.12.
For a specific need, I want to implement my own custom way of writing to Delta tables by manually managing Delta transactions from PySpark. To do ... | https://stackoverflow.com/questions/79671409/unable-to-load-org-apache-spark-sql-delta-classes-from-jvm-pyspark | java, scala, apache-spark, pyspark, databricks | 1,750,291,290 |
se_75308871 | stackoverflow | DATA_ENGINEERING | Unable to save partitioned data in in iceberg format when using s3 and glue | Unable to save partitioned data in in iceberg format when using s3 and glue
Getting the following error-
java.lang.IllegalStateException: Incoming records violate the writer assumption that records are clustered by spec and by partition within each spec. Either cluster the incoming records or switch to fanout writers... | https://stackoverflow.com/questions/75308871/unable-to-save-partitioned-data-in-in-iceberg-format-when-using-s3-and-glue | apache-spark, amazon-s3, aws-glue, apache-iceberg | 1,675,247,585 |
se_60411391 | stackoverflow | DATA_ENGINEERING | Can I process 100 GB of data using Apache Spark on my local machine? | Can I process 100 GB of data using Apache Spark on my local machine?
I have around 100GB data of users and want to process it using Apache Spark on my laptop.I have installed Hadoop and Spark and for the test I uploaded a file of around 9 GB to HDFS and accessed & queried it using pyspak.
The test file has total 113... | https://stackoverflow.com/questions/60411391/can-i-process-100-gb-of-data-using-apache-spark-on-my-local-machine | python, apache-spark, hadoop, pyspark | 1,582,711,649 |
se_79613458 | stackoverflow | DATA_ENGINEERING | Control Spark Join Hash Partitioning | Control Spark Join Hash Partitioning
I have three dataframes A, B, and C.
I need to join dataframes A and B on columns [a, b] and dataframes A and C on columns [a, c].
I would like to force Spark to only hash-partition the three dataframes A, B, and C by the common column "a". Thereby, for the two joins I would need t... | https://stackoverflow.com/questions/79613458/control-spark-join-hash-partitioning | apache-spark, join, pyspark, partitioning | 1,746,762,279 |
se_79668531 | stackoverflow | DATA_ENGINEERING | How can I calculate the timestamp difference based on status using spark Dataframes? | How can I calculate the timestamp difference based on status using spark Dataframes?
I am trying to calculate the timestamp difference on cumulative rows based on ID and status columns
Example dataframe:
ID
TIMESTAMP
STATUS
V1
2023-06-18 13:00:00
1
V1
2023-06-18 13:01:00
1
V1
2023-06-18 13:02:00
1
V1
2023... | https://stackoverflow.com/questions/79668531/how-can-i-calculate-the-timestamp-difference-based-on-status-using-spark-datafra | dataframe, scala, apache-spark, apache-spark-sql | 1,750,140,337 |
se_73275331 | stackoverflow | DATA_ENGINEERING | Change Spark day timestamp from name to number | Change Spark day timestamp from name to number
I'm trying to get the day of the week in int format from it saying Mon, Tues, Wed, etc.
I'm using this code right now:
from pyspark.sql.functions import date_format
df_ex1 = df.withColumn("day", date_format('Timestamp', 'E'))
Output:
+-------------------+----+----+----+-... | https://stackoverflow.com/questions/73275331/change-spark-day-timestamp-from-name-to-number | apache-spark, pyspark, apache-spark-sql, timestamp, dayofweek | 1,659,949,344 |
se_62442352 | stackoverflow | DATA_ENGINEERING | Convert month name to number in PySpark | Convert month name to number in PySpark
This is my PySpark dataframe:
+--------+-----+---+----+----+----+----+-----+-----------+-----------+
|Currency|Month|Day|Year|Open|High| Low|Close| Volume| Market Cap|
+--------+-----+---+----+----+----+----+-----+-----------+-----------+
| tezos| Dec| 04|2019|1.29|1.32|1... | https://stackoverflow.com/questions/62442352/convert-month-name-to-number-in-pyspark | python, dataframe, apache-spark, date, pyspark | 1,592,454,098 |
se_69905730 | stackoverflow | DATA_ENGINEERING | Return month name in specified locale | Return month name in specified locale
Using date_format we can extract month name from a date in English:
from pyspark.sql import functions as F
df = spark.createDataFrame([('2021-05-01',),('2021-06-01',)], ['c1']).select(F.col('c1').cast('date'))
df = df.withColumn('month', F.date_format('c1', 'LLLL'))
df.show()
#+--... | https://stackoverflow.com/questions/69905730/return-month-name-in-specified-locale | apache-spark, date, pyspark, apache-spark-sql, locale | 1,636,495,980 |
se_46983420 | stackoverflow | DATA_ENGINEERING | Spark dataframe string to month | Spark dataframe string to month
I have a dataframe where one column orddate as string, and I want to extract months from the orddate, make a new column with month name on new df.
|orddate|
|12/1/10 9:37|
|20/3/10 10:37|
|09/8/14 4:56|
|30/12/11 12:13|
|24/5/10 7:27|
convert to
|orddate| month |
|12/1/10 9:37|... | https://stackoverflow.com/questions/46983420/spark-dataframe-string-to-month | dataframe, scala, apache-spark, date, apache-spark-sql | 1,509,138,419 |
se_44377052 | stackoverflow | DATA_ENGINEERING | Change month numbers to month name in a dataframe (PySpark) | Change month numbers to month name in a dataframe (PySpark)
I have a column of month numbers in a dataframe and want to change it to month name, so I used this which resulted in a type error:
df['monthName'] = df['monthNumber'].apply(lambda x: calendar.month_name[x])
TypeError: 'Column' object is not callable
How ... | https://stackoverflow.com/questions/44377052/change-month-numbers-to-month-name-in-a-dataframe-pyspark | dataframe, apache-spark, date, pyspark, apache-spark-sql | 1,496,694,111 |
se_74493973 | stackoverflow | DATA_ENGINEERING | Map monthname to monthnumber in Azure Databricks using Scala | Map monthname to monthnumber in Azure Databricks using Scala
Need to map monthname to monthnumber in Azure Databricks using Scala.
I have column name PERIOD which have data like months name(like Jan,Feb,Mar,....,Nov,Dec), I want to replace this monthname with monthnumber (like 01,02,03,...,11,12).
Result should be lik... | https://stackoverflow.com/questions/74493973/map-monthname-to-monthnumber-in-azure-databricks-using-scala | scala, apache-spark, date, apache-spark-sql, azure-databricks | 1,668,796,256 |
se_79669972 | stackoverflow | DATA_ENGINEERING | Pyspark aggregations failed when writing to parquet, not at .count() | Pyspark aggregations failed when writing to parquet, not at .count()
I have the following spark configuration.
spark = SparkSession\
.builder\
.appName("App")\
.config("spark.executor.memory","10g")\
.config("spark.executor.cores","4")\
.config("spark.executor.instances","6")... | https://stackoverflow.com/questions/79669972/pyspark-aggregations-failed-when-writing-to-parquet-not-at-count | dataframe, apache-spark, pyspark, parquet | 1,750,215,033 |
se_48482243 | stackoverflow | DATA_ENGINEERING | How to get month name abbr instead of month number in Hive | How to get month name abbr instead of month number in Hive
I want month name instead of month number from a Date passed in HIVE.
This gives me a month number:
select Month(date_field) from <tablename>;
How to get month names ? | https://stackoverflow.com/questions/48482243/how-to-get-month-name-abbr-instead-of-month-number-in-hive | apache-spark, date, apache-spark-sql, hive | 1,517,102,335 |
se_41788919 | stackoverflow | DATA_ENGINEERING | Concatenating string by rows in PySpark | Concatenating string by rows in PySpark
I have this PySpark dataframe:
df = spark.createDataFrame(
[('JOHN', 'SAM'),
('JOHN', 'PETER'),
('JOHN', 'ROBIN'),
('BEN', 'ROSE'),
('BEN', 'GRAY')],
['DOCTOR', 'PATIENT'])
DOCTOR | PATIENT
JOHN | SAM
JOHN | PETER
JOHN | ROBIN
BEN | ROSE
BEN... | https://stackoverflow.com/questions/41788919/concatenating-string-by-rows-in-pyspark | dataframe, apache-spark, pyspark, group-by, concatenation | 1,485,074,303 |
se_72109797 | stackoverflow | DATA_ENGINEERING | Concatenate string on grouping with the other column | Concatenate string on grouping with the other column
I have dataframe as follows
+----------+--------------------+
|CustomerNo| desc |
+----------+--------------------+
| 351856.0| FORM & BEAUTY 075 P|
| 351856.0| FORM & BEAUTY 075 P|
| 326022.0| D 151 HP|
| 69430.0|Shape Sensation 0...|
... | https://stackoverflow.com/questions/72109797/concatenate-string-on-grouping-with-the-other-column | apache-spark, pyspark, group-by, concatenation, aggregate-functions | 1,651,652,170 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.