Need advice about which tool to choose?Ask the StackShare community!

dbt

464
426
+ 1
15
Apache Spark

3K
3.5K
+ 1
140
Add tool

Apache Spark vs dbt: What are the differences?

Introduction:

Apache Spark and dbt are both popular tools used in data processing and analysis. While they have some similarities, there are several key differences between the two. In this article, we will explore these differences in detail.

  1. Architecture: One of the key differences between Apache Spark and dbt lies in their architecture. Apache Spark is a distributed computing system that allows for the parallel processing of large datasets across a cluster of computers. On the other hand, dbt is an SQL-based transformation tool that operates on a single machine. This fundamental difference in architecture allows Apache Spark to handle big data workloads more efficiently, while dbt is better suited for smaller datasets.

  2. Processing Engine: Apache Spark and dbt use different processing engines. Apache Spark leverages an in-memory computing engine, which enables it to perform real-time data processing at a much faster speed. dbt, on the other hand, uses a traditional disk-based processing engine, which is slower in comparison. This difference in processing engines gives Apache Spark an advantage when it comes to handling complex data processing tasks.

  3. Data Source Support: Another important difference between Apache Spark and dbt is the range of data sources they support. Apache Spark has extensive support for various data sources, including Hadoop Distributed File System (HDFS), Amazon S3, and more. This makes it easier to integrate Apache Spark with different data platforms and extract data from diverse sources. dbt, on the other hand, has limited data source support and primarily focuses on SQL-based databases.

  4. Transformation Capabilities: When it comes to data transformations, Apache Spark offers a wide range of built-in operators and functions that facilitate complex data transformations. It provides a flexible and powerful programming interface that allows users to manipulate data using SQL, Python, Scala, or R. dbt, on the other hand, is primarily focused on SQL-based transformations and lacks the versatility offered by Apache Spark.

  5. Data Modeling: Apache Spark and dbt approach data modeling differently. Apache Spark provides a GraphX library that enables graph-parallel computation, making it easier to model and analyze graph databases. It also supports machine learning and graph algorithms out of the box. dbt, on the other hand, does not have built-in support for graph modeling or machine learning and is primarily designed for SQL-based data modeling.

  6. Data Governance and Collaboration: Apache Spark and dbt have different capabilities when it comes to data governance and collaboration. Apache Spark provides features like access control, auditing, and data lineage, which are crucial for ensuring data governance and compliance. It also supports collaborative development by providing integration with version control systems like Git. On the other hand, dbt does not have built-in support for data governance or collaborative development.

In summary, Apache Spark is a distributed computing system with advanced processing capabilities, extensive data source support, and versatile transformation capabilities. On the other hand, dbt is a SQL-based transformation tool that operates on a single machine and is primarily focused on SQL-based data modeling.

Advice on dbt and Apache Spark
Nilesh Akhade
Technical Architect at Self Employed · | 5 upvotes · 516.5K views

We have a Kafka topic having events of type A and type B. We need to perform an inner join on both type of events using some common field (primary-key). The joined events to be inserted in Elasticsearch.

In usual cases, type A and type B events (with same key) observed to be close upto 15 minutes. But in some cases they may be far from each other, lets say 6 hours. Sometimes event of either of the types never come.

In all cases, we should be able to find joined events instantly after they are joined and not-joined events within 15 minutes.

See more
Replies (2)
Recommends
on
ElasticsearchElasticsearch

The first solution that came to me is to use upsert to update ElasticSearch:

  1. Use the primary-key as ES document id
  2. Upsert the records to ES as soon as you receive them. As you are using upsert, the 2nd record of the same primary-key will not overwrite the 1st one, but will be merged with it.

Cons: The load on ES will be higher, due to upsert.

To use Flink:

  1. Create a KeyedDataStream by the primary-key
  2. In the ProcessFunction, save the first record in a State. At the same time, create a Timer for 15 minutes in the future
  3. When the 2nd record comes, read the 1st record from the State, merge those two, and send out the result, and clear the State and the Timer if it has not fired
  4. When the Timer fires, read the 1st record from the State and send out as the output record.
  5. Have a 2nd Timer of 6 hours (or more) if you are not using Windowing to clean up the State

Pro: if you have already having Flink ingesting this stream. Otherwise, I would just go with the 1st solution.

See more
Akshaya Rawat
Senior Specialist Platform at Publicis Sapient · | 3 upvotes · 361.2K views
Recommends
on
Apache SparkApache Spark

Please refer "Structured Streaming" feature of Spark. Refer "Stream - Stream Join" at https://spark.apache.org/docs/latest/structured-streaming-programming-guide.html#stream-stream-joins . In short you need to specify "Define watermark delays on both inputs" and "Define a constraint on time across the two inputs"

See more
Get Advice from developers at your company using StackShare Enterprise. Sign up for StackShare Enterprise.
Learn More
Pros of dbt
Pros of Apache Spark
  • 5
    Easy for SQL programmers to learn
  • 2
    CI/CD
  • 2
    Schedule Jobs
  • 2
    Reusable Macro
  • 2
    Faster Integrated Testing
  • 2
    Modularity, portability, CI/CD, and documentation
  • 61
    Open-source
  • 48
    Fast and Flexible
  • 8
    One platform for every big data problem
  • 8
    Great for distributed SQL like applications
  • 6
    Easy to install and to use
  • 3
    Works well for most Datascience usecases
  • 2
    Interactive Query
  • 2
    Machine learning libratimery, Streaming in real
  • 2
    In memory Computation

Sign up to add or upvote prosMake informed product decisions

Cons of dbt
Cons of Apache Spark
  • 1
    Only limited to SQL
  • 1
    Cant do complex iterations , list comprehensions etc .
  • 1
    People will have have only sql skill set at the end
  • 1
    Very bad for people from learning perspective
  • 4
    Speed

Sign up to add or upvote consMake informed product decisions

- No public GitHub repository available -

What is dbt?

dbt is a transformation workflow that lets teams deploy analytics code following software engineering best practices like modularity, portability, CI/CD, and documentation. Now anyone who knows SQL can build production-grade data pipelines.

What is Apache Spark?

Spark is a fast and general processing engine compatible with Hadoop data. It can run in Hadoop clusters through YARN or Spark's standalone mode, and it can process data in HDFS, HBase, Cassandra, Hive, and any Hadoop InputFormat. It is designed to perform both batch processing (similar to MapReduce) and new workloads like streaming, interactive queries, and machine learning.

Need advice about which tool to choose?Ask the StackShare community!

What companies use dbt?
What companies use Apache Spark?
See which teams inside your own company are using dbt or Apache Spark.
Sign up for StackShare EnterpriseLearn More

Sign up to get full access to all the companiesMake informed product decisions

What tools integrate with dbt?
What tools integrate with Apache Spark?

Sign up to get full access to all the tool integrationsMake informed product decisions

Blog Posts

Mar 24 2021 at 12:57PM

Pinterest

GitJenkinsKafka+7
3
2124
MySQLKafkaApache Spark+6
2
1999
Aug 28 2019 at 3:10AM

Segment

PythonJavaAmazon S3+16
7
2551
What are some alternatives to dbt and Apache Spark?
act
Rather than having to commit/push every time you want test out the changes you are making to your .github/workflows/ files (or for any changes to embedded GitHub actions), you can use this tool to run the actions locally. The environment variables and filesystem are all configured to match what GitHub provides.
Airflow
Use Airflow to author workflows as directed acyclic graphs (DAGs) of tasks. The Airflow scheduler executes your tasks on an array of workers while following the specified dependencies. Rich command lines utilities makes performing complex surgeries on DAGs a snap. The rich user interface makes it easy to visualize pipelines running in production, monitor progress and troubleshoot issues when needed.
Looker
We've built a unique data modeling language, connections to today's fastest analytical databases, and a service that you can deploy on any infrastructure, and explore on any device. Plus, we'll help you every step of the way.
Slick
It is a modern database query and access library for Scala. It allows you to work with stored data almost as if you were using Scala collections while at the same time giving you full control over when a database access happens and which data is transferred.
Spring Data
It makes it easy to use data access technologies, relational and non-relational databases, map-reduce frameworks, and cloud-based data services. This is an umbrella project which contains many subprojects that are specific to a given database.
See all alternatives