This dbt package contains macros that:
- can be (re)used across dbt projects running on Spark
- define Spark-specific implementations of dispatched macros from other packages
Check dbt Hub for the latest installation instructions, or read the docs for more information on installing packages.
This package provides "shims" for:
- dbt_utils, except for:
dbt_utils.get_relations_by_prefix_sql
dbt_utils.get_tables_by_pattern_sql
dbt_utils.get_tables_by_prefix
dbt_utils.get_tables_by_pattern
- snowplow (tested on Databricks only)
In order to use these "shims," you should set a dispatch
config in your root project (on dbt v0.20.0 and newer). For example, with this project setting, dbt will first search for macro implementations inside the spark_utils
package when resolving macros from the dbt_utils
namespace:
dispatch:
- macro_namespace: dbt_utils
search_order: ['spark_utils', 'dbt_utils']
The spark-utils package may be able to provide compatibility for your package, especially if your package leverages dbt-utils macros for cross-database compatibility. This package does not need to be specified as a depedency of your package in packages.yml
. Instead, you should encourage anyone using your package on Apache Spark / Databricks to:
- Install
spark_utils
alongside your package - Add a
dispatch
config in their root project, like the one above
Caveat: These are not tested in CI, or guaranteed to work on all platforms.
Each of these macros accepts a regex pattern, finds tables with names matching the pattern, and will loop over those tables to perform a maintenance operation:
spark_optimize_delta_tables
: Runsoptimize
for all matched Delta tablesspark_vacuum_delta_tables
: Runsvacuum
for all matched Delta tablesspark_analyze_tables
: Compute statistics for all matched tables
We welcome contributions to this repo! To contribute a new feature or a fix,
please open a Pull Request with 1) your changes and 2) updated documentation for
the README.md
file.
- What is dbt?
- Installation
- Join the #spark channel in dbt Slack
Everyone interacting in the dbt project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PyPA Code of Conduct.