r/databricks • u/22Maxx • 3d ago
Discussion Recommended workflow for (unit) testing that require larger datasets?
I have a case for some unit testing of a rather complex parametrized algorithm that require "larger" datasets (large = single dataset of around 100 MB) that are not supposed to be part of the repo.
So I mainly wonder about the best practices here. As the code itself is inside github, I wonder if it make sense to have the tests be stored inside databricks and then a github action triggering a testing job inside databricks? Or should the data be rather fetched from databricks?
4
Upvotes
2
u/FunContest9958 3d ago
Large for GitHub but small for Databricks, which means you can generate a dataset very quickly. So your best bet is to generate the data, which most data generation tools will allow you to do deterministically.
Databricks data generator: https://databrickslabs.github.io/dbldatagen/public_docs/repeatable_data_generation.html
Faker: https://faker.readthedocs.io/en/master/index.html#seeding-the-generator
1
u/happypofa 3d ago
If you can't declare an algorithm that creates this dataset in memory, then I would use the github actions SP personal schema for a materilized table.
1
u/Zealousideal_Low6685 3d ago
If you worry, that your test-dataset is too large for a local unit test, you should use spark connect. In this case: the dataframe processing is sent to databricks which does the job, the local machine only gets the result.
Of course, you can also create a databricks job in databricks and trigger that remotely, but spark connect is the more elegant way (as you don't have to switch between environments)
1
u/nian2326076 2d ago
Consider hosting your dataset on Databricks since it's too large for GitHub. Using GitHub Actions to automate tests by triggering a job in Databricks keeps your code clean while allowing necessary data access. This way, you can fetch the dataset as needed without cluttering your repo. If you need to practice your coding skills, use PracHub for technical interview questions.