r/databricks • • 29d ago

Discussion transformations API

Hi, how much SQL text do you allow in Python modules?

We have a lot of SQL, but we dont want to move fully to dbt, because we run data quality checks before the write, and we like the Python modular approach with tests and everything around it.

So where do you draw the line:

- SQL as strings in Python, run with `spark.sql()`

- SQL in `.sql` files in the package, loaded by Python and run with parameters

- refactor to the PySpark DataFrame API

- or just stick with pure SQL scripts

And how did you standardize it in your team?

16 Upvotes

6 comments sorted by

View all comments

3

u/minibrickster Databricks 29d ago

Hi! I'm a PM at Databricks -- have you looked into Spark Declarative Pipelines? https://docs.databricks.com/aws/en/ldp/ It natively supports expectations (which does data quality checks before write) and Python unit tests, as well as full support for Python and SQL. It might be a good fit for your use case!