Questions tagged [apache-spark]

Apache Spark is an open source distributed data processing engine written in Scala providing a unified API and distributed data sets to users for both batch and streaming processing. Use cases for Apache Spark often are related to machine/deep learning and graph processing.

From https://spark.apache.org/:

Apache Spark is an open source cluster computing system that aims to make data analytics fast — both fast to run and fast to write.

To run programs faster, Spark offers a general execution model based on the RDD data abstraction that can help optimizing arbitrary long operator graphs, and supports in-memory computing, which lets it query data faster than disk-based engines like .

Spark is not tied to the two-stage paradigm, and promises performance up to 100 times faster than Hadoop MapReduce.

Spark provides primitives for in-memory cluster computing that allows user programs to load data into a cluster's memory and query it repeatedly, making it well suited for interactive as well as iterative algorithms in machine learning or graph computing.

Spark can be used to tackle stream processing problems with many approaches (micro-batch processing, continuous processing since 2.3, running SQL queries, windowing on data and on streams, running ML libraries to learn from streamed data, and so on ...).

To make programming faster, Spark provides clean, concise APIs in , , and . You can also use Spark interactively from the , and shells to rapidly query big datasets.

Spark runs on , , , standalone, or in the cloud. It can access diverse data sources including , , , and .

When asking Spark related questions, please don't forget to provide a reproducible example (AKA MVCE) and, when applicable, specify the Spark version you're using (since different versions can often disagree). You can refer to How to make good reproducible Apache Spark examples for general guidelines and suggestions.

Latest version

Release Notes for Stable Releases

Apache Spark GitHub Repository

Recommended reference sources:

81095 questions
15
votes
1 answer

Exception with Table identified via AWS Glue Crawler and stored in Data Catalog

I'm working to build the new data lake of the company and are trying to find the best and the most recent option to work here. So, I found a pretty nice solution to work with EMR + S3 + Athena + Glue. The process that I did was: 1 - Run Apache Spark…
15
votes
3 answers

Connecting to remote master on standalone Spark

I launch Spark in standalone mode on my remote server via following next steps: cp spark-env.sh.template spark-env.sh append to spark-env.sh SPARK_MASTER_HOST=IP_OF_MY_REMOTE_SERVER and run next commands for standalone mode: sbin/start-master.sh…
pacman
  • 797
  • 10
  • 28
15
votes
1 answer

Executing separate streaming queries in spark structured streaming

I am trying to aggregate stream with two different windows and printing it into the console. However only the first streaming query is being printed. The tenSecsQ is not printed into the console. SparkSession spark = SparkSession .builder() …
atom
  • 153
  • 1
  • 5
15
votes
2 answers

Spark Data frame search column starting with a string

I have a requirement to filter a data frame based on a condition that a column value should starts with a predefined string. I am trying following: val domainConfigJSON = sqlContext.read .jdbc(url, "CONFIG", prop) .select("DID", "CONF",…
Anush
  • 149
  • 1
  • 1
  • 4
15
votes
9 answers

Scala Error: Could not find or load main class in both Scala IDE and Eclipse

Here is my problem, I know there are lots of answers for similar questions, however none of them worked after I tried. I'm using both Scala IDE 4.6 and eclipse Oxygen to run the code and all failed on this error. Here's my scala compiler…
SKSKSKSK
  • 545
  • 1
  • 4
  • 15
15
votes
3 answers

Spark: Most efficient way to sort and partition data to be written as parquet

My data is in principle a table, which contains a column ID and a column GROUP_ID, besides other 'data'. In the first step I am reading CSV's into Spark, do some processing to prepare the data for the second step, and write the data as parquet. The…
akoeltringer
  • 1,671
  • 3
  • 19
  • 34
15
votes
2 answers

How to use collect_set and collect_list functions in windowed aggregation in Spark 1.6?

In Spark 1.6.0 / Scala, is there an opportunity to get collect_list("colC") or collect_set("colC").over(Window.partitionBy("colA").orderBy("colB")?
15
votes
3 answers

Spark SQL change format of the number

After show command spark prints the following: +-----------------------+---------------------------+ |NameColumn |NumberColumn | +-----------------------+---------------------------+ |name |4.3E-5 …
Cherry
  • 31,309
  • 66
  • 224
  • 364
15
votes
2 answers

Empty output for Watermarked Aggregation Query in Append Mode

I use Spark 2.2.0-rc1. I've got a Kafka topic which I'm querying a running watermarked aggregation, with a 1 minute watermark, giving out to console with append output mode. import org.apache.spark.sql.types._ val schema =…
himanshuIIITian
  • 5,985
  • 6
  • 50
  • 70
15
votes
2 answers

How to run Scala script using spark-submit (similarly to Python script)?

I try to execute a simple Scala script using Spark as described in the Spark Quick Start Tutorial. I have not troubles to execute the following Python code: """SimpleApp.py""" from pyspark import SparkContext logFile = "tmp.txt" # Should be some…
Roman
  • 124,451
  • 167
  • 349
  • 456
15
votes
2 answers

What is StringIndexer , VectorIndexer, and how to use them?

Dataset dataFrame = ... ; StringIndexerModel labelIndexer = new StringIndexer() .setInputCol("label") .setOutputCol("indexedLabel") .fit(dataFrame); VectorIndexerModel featureIndexer = new…
15
votes
6 answers

Spark Scala Split dataframe into equal number of rows

I have a Dataframe and wish to divide it into an equal number of rows. In other words, I want a list of dataframes where each one is a disjointed subset of the original dataframe. Let's say the input dataframer is the following: …
Alessandro La Corte
  • 419
  • 3
  • 6
  • 18
15
votes
2 answers

When are cache and persist executed (since they don't seem like actions)?

I am implementing a spark application, of which below is a sample snippet(Not the exact same code): val rdd1 = sc.textfile(HDFS_PATH) val rdd2 = rdd1.map(func) rdd2.persist(StorageLevel.MEMORY_AND_DISK) println(rdd2.count) On checking the…
Ankit Khettry
  • 997
  • 1
  • 13
  • 33
15
votes
2 answers

How to split pipe-separated column into multiple rows?

I have a dataframe that contains the following: movieId / movieName / genre 1 example1 action|thriller|romance 2 example2 fantastic|action I would like to obtain a second dataframe (from the first one), that contains the…
Lechucico
  • 1,914
  • 7
  • 27
  • 60
15
votes
1 answer

Apache Spark: User Memory vs Spark Memory

I'm building a Spark application where I have to cache about 15 GB of CSV files. I read about the new UnifiedMemoryManager introduced in Spark 1.6 here: https://0x0fff.com/spark-memory-management/ It shows also this picture: The author differs…
D. Müller
  • 3,336
  • 4
  • 36
  • 84
1 2 3
99
100