YouTube Icon

Interview Questions.

Top 50 Spark Sql Programming Interview Questions - Jul 28, 2022

fluid

Top 50 Spark Sql Programming Interview Questions

Q1. What Is Catalyst Framework?

Catalyst framework is a brand new optimization framework present in Spark SQL. It lets in Spark to robotically remodel SQL queries by means of including new optimizations to build a quicker processing gadget.

Q2. Name A Few Companies That Use Apache Spark In Production.

Pinterest, Conviva, Shopify, Open Table

Q3. Name A Few Commonly Used Spark Ecosystems.

Spark SQL (Shark)

Spark Streaming

GraphX

MLlib

SparkR

Q4. Is It Possible To Run Apache Spark On Apache Mesos?

Yes, Apache Spark may be run at the hardware clusters managed via Mesos.

Q5. How Can You Minimize Data Transfers When Working With Spark?

Minimizing data transfers and avoiding shuffling facilitates write spark packages that run in a fast and dependable manner. The various ways wherein information transfers may be minimized when operating with Apache Spark are:

Using Broadcast Variable- Broadcast variable enhances the efficiency of joins among small and massive RDDs.

Using Accumulators – Accumulators help replace the values of variables in parallel even as executing.

The most commonplace way is to avoid operations ByKey, repartition or any other operations which cause shuffles.

Q6. Hadoop Uses Replication To Achieve Fault Tolerance. How Is This Achieved In Apache Spark?

Data garage version in Apache Spark is primarily based on RDDs. RDDs assist reap fault tolerance via lineage. RDD constantly has the records on a way to build from other datasets. If any partition of a RDD is misplaced due to failure, lineage allows construct best that particular lost partition.

Q7. What Is A Parquet File?

Parquet is a columnar format file supported via many different information processing structures. Spark SQL plays both examine and write operations with Parquet document and consider or not it's one of the fine big facts analytics format so far.

Q8. What Are The Various Levels Of Persistence In Apache Spark?

Apache Spark robotically persists the middleman facts from various shuffle operations, but it's far regularly cautioned that customers call persist () approach at the RDD in case they plan to reuse it. Spark has diverse patience tiers to save the RDDs on disk or in reminiscence or as a mixture of each with one of a kind replication ranges.

The various storage/staying power ranges in Spark are -

MEMORY_ONLY

MEMORY_ONLY_SER

MEMORY_AND_DISK

MEMORY_AND_DISK_SER, DISK_ONLY

OFF_HEAP

Q9. Is It Necessary To Install Spark On All The Nodes Of A Yarn Cluster While Running Apache Spark On Yarn ?

No , it is not essential because Apache Spark runs on pinnacle of YARN.

Q10. What Is The Advantage Of A Parquet File?

Parquet record is a columnar layout document that facilitates –

Limit I/O operations

Consumes less area

Fetches best required columns.

Q11. What Do You Understand By Pair Rdd?

Special operations can be executed on RDDs in Spark the use of key/value pairs and such RDDs are called Pair RDDs. Pair RDDs permit customers to get admission to each key in parallel. They have a reduceByKey () technique that collects statistics based totally on each key and a join () approach that mixes different RDDs together, based at the factors having the equal key.

Q12. Why Is There A Need For Broadcast Variables When Working With Apache Spark?

These are read simplest variables, present in-reminiscence cache on every machine. When operating with Spark, utilization of broadcast variables removes the necessity to ship copies of a variable for each venture, so data can be processed quicker. Broadcast variables help in storing a research desk within the reminiscence which complements the retrieval efficiency when compared to an RDD research ().

Q13. How Spark Uses Akka?

Spark makes use of Akka essentially for scheduling. All the people request for a mission to master after registering. The master simply assigns the mission. Here Spark makes use of Akka for messaging between the employees and masters.

Q14. What Is Hive On Spark?

Hive is a part of Hortonworks’ Data Platform (HDP). Hive gives an SQL-like interface to facts saved in the HDP. Spark users will automatically get the whole set of Hive’s wealthy capabilities, including any new features that Hive might introduce within the future.

The most important task round implementing the Spark execution engine for Hive lies in query making plans, wherein Hive operator plans from the semantic analyzer that is translated to a undertaking plan that Spark can execute. It additionally includes query execution, where the generated Spark plan gets definitely carried out inside the Spark cluster.

Q15. Explain About The Different Cluster Managers In Apache Spark

The 3 distinctive clusters managers supported in Apache Spark are:

YARN

Apache Mesos -Has rich aid scheduling abilties and is well desirable to run Spark along side different packages. It is fantastic while several users run interactive shells because it scales down the CPU allocation among instructions.

Standalone deployments – Well ideal for brand new deployments which only run and are easy to set up.

Q16. Explain About The Different Types Of Transformations On Dstreams?

Stateless Transformations- Processing of the batch does not depend upon the output of the preceding batch. Examples – map (), reduceByKey (), filter out ().

Stateful Transformations- Processing of the batch depends at the intermediary consequences of the previous batch. Examples –Transformations that rely upon sliding home windows.

Q17. How Spark Handles Monitoring And Logging In Standalone Mode?

Spark has a web based user interface for tracking the cluster in standalone mode that shows the cluster and activity facts. The log output for each task is written to the work listing of the slave nodes.

Q18. Explain About The Popular Use Cases Of Apache Spark

Apache Spark is in particular used for

Iterative machine getting to know.

Interactive facts analytics and processing.

Stream processing

Sensor records processing

Q19. What Is A Dstream?

Discretized Stream is a series of Resilient Distributed Databases that represent a circulation of statistics. DStreams can be produced from various assets like Apache Kafka, HDFS, and Apache Flume. DStreams have  operations –

Transformations that produce a brand new DStream.

Output operations that write facts to an external system.

Q20. What Are The Languages Supported By Apache Spark For Developing Big Data Applications?

Scala, Java, Python, R and Clojure

Q21. What Is Lineage Graph?

The RDDs in Spark, rely upon one or greater different RDDs. The representation of dependencies in among RDDs is referred to as the lineage graph. Lineage graph information is used to compute each RDD on call for, in order that whenever a part of persistent RDD is lost, the facts this is lost can be recovered the use of the lineage graph facts.

Q22. How Spark Uses Hadoop?

Spark has its personal cluster management computation and mainly makes use of Hadoop for garage.

Q23. Explain About The Common Workflow Of A Spark Program

The most important step in a Spark program involves creating input RDD's from external facts.

Use various RDD alterations like clear out() to create new transformed RDD's based totally on the commercial enterprise good judgment.

Persist() any intermediate RDD's which might have to be reused in destiny.

Launch diverse RDD movements() like first(), be counted() to start parallel computation , in an effort to then be optimized and achieved with the aid of Spark.

Q24. What Do You Understand By Lazy Evaluation?

Spark is intellectual inside the manner in which it operates on data. When you tell Spark to perform on a given dataset, it heeds the instructions and makes a notice of it, in order that it does no longer overlook - but it does not anything, unless requested for the very last result. When a change like map () is known as on a RDD-the operation is not carried out straight away. Transformations in Spark aren't evaluated until you perform an action. This facilitates optimize the overall information processing workflow.

Q25. What Is Shark?

Most of the information users realize simplest SQL and aren't suitable at programming. Shark is a tool, advanced for those who are from a database historical past - to access Scala MLib skills via Hive like SQL interface. Shark device allows information users run Hive on Spark - imparting compatibility with Hive metastore, queries and facts.

Q26. Is It Necessary To Start Hadoop To Run Any Apache Spark Application ?

Starting hadoop isn't manadatory to run any spark software. As there's no seperate storage in Apache Spark, it makes use of Hadoop HDFS however it is not mandatory. The facts can be saved in neighborhood file machine, may be loaded from nearby document device and processed.

Q27. How Can You Remove The Elements With A Key Present In Any Other Rdd?

Use the subtractByKey () characteristic

Q28. What Are The Key Features Of Apache Spark That You Like?

Spark gives advanced analytic alternatives like graph algorithms, machine mastering, streaming data, and many others

It has built-in APIs in more than one languages like Java, Scala, Python and R

It has appropriate performance gains, as it facilitates run an software within the Hadoop cluster ten instances quicker on disk and one hundred times faster in memory.

Q29. What Do You Understand By Executor Memory In A Spark Application?

Every spark software has identical fixed heap size and glued number of cores for a spark executor. The heap size is what known as the Spark executor reminiscence which is controlled with the spark.Executor.Memory property of the –executor-memory flag. Every spark software may have one executor on every worker node. The executor reminiscence is essentially a measure on how a great deal memory of the worker node will the application make use of.

Q30. How Can You Compare Hadoop And Spark In Terms Of Ease Of Use?

Hadoop MapReduce requires programming in Java that is tough, although Pig and Hive make it substantially simpler. Learning Pig and Hive syntax takes time. Spark has interactive APIs for special languages like Java, Python or Scala and also includes Shark i.E. Spark SQL for SQL fanatics - making it comparatively less complicated to use than Hadoop.

Q31. Why Is Blinkdb Used?

BlinkDB is a question engine for executing interactive SQL queries on massive volumes of records and renders question outcomes marked with meaningful blunders bars. BlinkDB allows customers balance ‘query accuracy’ with response time.

Q32. What Is Rdd?

RDDs (Resilient Distributed Datasets) are simple abstraction in Apache Spark that constitute the records getting into the machine in object format. RDDs are used for in-memory computations on large clusters, in a fault tolerant way. RDDs are examine-only portioned, collection of data, which might be –

Immutable – RDDs cannot be altered.

Resilient – If a node preserving the partition fails the other node takes the facts.

Q33. What Is Spark Sql?

SQL Spark, better known as Shark is a novel module delivered in Spark to paintings with established information and carry out established statistics processing. Through this module, Spark executes relational SQL queries on the facts. The center of the issue helps an altogether exceptional RDD called SchemaRDD, composed of rows items and schema gadgets defining facts sort of every column in the row. It is much like a desk in relational database.

Q34. What Is The Default Level Of Parallelism In Apache Spark?

If the person does no longer explicitly specify then the wide variety of partitions are taken into consideration as default degree of parallelism in Apache Spark.

Q35. What Is A Sparse Vector?

Sparse vector has  parallel arrays –one for indices and the opposite for values. These vectors are used for storing non-0 entries to store space.

Q36. Explain About The Major Libraries That Constitute The Spark Ecosystem

Spark MLib- Machine mastering library in Spark for usually used gaining knowledge of algorithms like clustering, regression, classification, and so forth.

Spark Streaming – This library is used to method real time streaming facts.

Spark GraphX – Spark API for graph parallel computations with basic operators like joinVertices, subgraph, aggregateMessages, and so on.

Spark SQL – Helps execute SQL like queries on Spark facts the usage of trendy visualization or BI gear.

Q37. Can We Do Real-time Processing Using Spark Sql?

Not without delay however we are able to check in an present RDD as a SQL desk and cause SQL queries on pinnacle of that.

Q38. What Are The Benefits Of Using Spark With Apache Mesos?

It renders scalable partitioning among diverse Spark times and dynamic partitioning between Spark and different large facts frameworks.

Q39. How Can You Trigger Automatic Clean-united statesIn Spark To Handle Accumulated Metadata?

You can cause the clean-united states of americawith the aid of setting the parameter ‘spark.Cleanser.Ttl’ or by means of dividing the lengthy walking jobs into specific batches and writing the intermediary results to the disk.

Q40. When Running Spark Applications, Is It Necessary To Install Spark On All The Nodes Of Yarn Cluster?

Spark need not be mounted when running a job underneath YARN or Mesos because Spark can execute on pinnacle of YARN or Mesos clusters without affecting any alternate to the cluster.

Q41. Can You Use Spark To Access And Analyse Data Stored In Cassandra Databases?

Yes, it's miles feasible if you use Spark Cassandra Connector.

Q42. List The Functions Of Spark Sql.

Spark SQL is able to:

Loading information from a spread of based resources

Querying records the usage of SQL statements, each inner a Spark software and from outside equipment that connect with Spark SQL via widespread database connectors (JDBC/ODBC). For example, using enterprise intelligence equipment like Tableau

Providing rich integration between SQL and everyday Python/Java/Scala code, such as the capacity to sign up for RDDs and SQL tables, expose custom features in SQL, and greater

Q43. What Are The Common Mistakes Developers Make When Running Spark Applications?

Developers regularly make the mistake of-

Hitting the internet service several times by the usage of multiple clusters.

Run the entirety on the nearby node instead of dispensing it.

Developers want to be careful with this, as Spark uses memory for processing.

Q44. What Are Benefits Of Spark Over Mapreduce?

Due to the supply of in-reminiscence processing, Spark implements the processing round 10-100x quicker than Hadoop MapReduce. MapReduce makes use of persistence storage for any of the facts processing tasks.

Unlike Hadoop, Spark presents in-built libraries to perform more than one responsibilities shape the identical middle like batch processing, Steaming, Machine getting to know, Interactive SQL queries. However, Hadoop only helps batch processing.

Hadoop is fantastically disk-dependent while Spark promotes caching and in-reminiscence facts garage

Spark is capable of performing computations more than one instances on the identical dataset. This is called iterative computation while there may be no iterative computing applied by using Hadoop.

Q45. What Makes Apache Spark Good At Low-latency Workloads Like Graph Processing And Machine Learning?

Apache Spark stores data in-reminiscence for quicker model building and education. Machine studying algorithms require multiple iterations to generate a resulting most useful version and further graph algorithms traverse all the nodes and edges.These low latency workloads that need a couple of iterations can cause elevated performance. Less disk get entry to and  controlled community site visitors make a huge distinction while there is lots of information to be processed.

Q46. How Sparksql Is Different From Hql And Sql?

SparkSQL is a special element at the spark Core engine that help SQL and Hive Query Language without converting any syntax. It’s viable to join SQL desk and HQL desk.

Q47. What Does The Spark Engine Do?

Spark engine schedules, distributes and monitors the statistics utility across the spark cluster.

Q48. How Can You Achieve High Availability In Apache Spark?

Implementing single node recuperation with neighborhood file gadget

Using StandBy Masters with Apache ZooKeeper.

Q49. Is Apache Spark A Good Fit For Reinforcement Learning?

No. Apache Spark works properly simplest for easy gadget studying algorithms like clustering, regression, category.

Q50. What Do You Understand By Schemardd?

An RDD that includes row objects (wrappers around simple string or integer arrays) with schema records approximately the form of facts in every column.




CFG