Website Preloader

Databricks Antipatterns

Intro

At Dtyped, we’re still seeing a surprising number of Databricks anti-patterns in the wild — not just in how teams operate Databricks, but also in how they set it up to scale securely and reliably. As Databricks keeps evolving, there are more ways than ever to deploy and manage it — Terraform, Asset Bundles, SDKs, the CLI, and REST APIs all have their place. But that flexibility can quickly turn into complexity when the wrong tools (or the wrong patterns) are used together.

We often come across setups where IAM roles aren’t clearly defined, Unity Catalog structures don’t scale, documentation is missing, or job ownership isn’t properly managed. These gaps don’t just slow teams down — they create real risks around governance, cost and security. Perhaps the biggest annoyance we encounter is the lack of structure around Code Quality and Development Practices — there are often no defined coding standards, no linting and no other forms of quality control in place. As a result, the codebase becomes inconsistent, harder to maintain, and increasingly prone to bugs and issues over time.

This post revisits some of the most common Databricks anti-patterns we’ve encountered at Dtyped over the years, explains what each counter measure is, and overall highlights how to structure your Databricks environment so it scales well, remains secure and stays easy to manage. 

To make it clear, we’ve put all the anti patterns into a list into their own category.

Databricks Anti patterns

Governance, Security & DevOps
Code Quality & Development Practices
Data Engineering & Pipeline Design
# Category Antipattern Countermeasure
1 Governance, Security & DevOps Job owners are not service accounts Configure production jobs to run under dedicated service principals with least-privilege access to improve auditability and security posture.
2 Governance, Security & DevOps Unity Catalog structure does not follow best practices Adopt a governed Unity Catalog hierarchy (metastore → catalog → schema) that reflects business domains and enforces clear ownership boundaries.
Official documentation here.
3 Governance, Security & DevOps No group structure for IAM Implement role-based access control (RBAC) using AD/SCIM groups to streamline permission management and reduce human error.
4 Governance, Security & DevOps Secrets are hardcoded Move all secrets to Databricks Secret Scopes or a centralized vault, and inject them securely at runtime via environment variables or widgets.
5 Governance, Security & DevOps Not everything is in Git Adopt full Git-based version control for notebooks, workflows, and infrastructure-as-code to ensure traceability and reproducibility.
6 Governance, Security & DevOps No CI/CD (Asset bundles) Implement CI/CD pipelines using Databricks Asset Bundles or similar automation frameworks to standardize deployment and reduce manual errors.
7 Governance, Security & DevOps No GitFlow strategy Enforce a branching strategy such as GitFlow or trunk-based development to support controlled releases and collaborative development.
8 Governance, Security & DevOps Using the wrong Databricks API abstractions for the wrong job Establish a consistent infrastructure deployment strategy using the appropriate Databricks tools for each layer of the platform:

  • Terraform: Use for provisioning infrastructure such as workspaces, networking, groups, service principals, Unity Catalog objects, and supporting cloud resources.
  • Asset Bundles (DABs): Use for deploying project-level artifacts like notebooks, jobs, and pipelines. Built on Terraform but simplifies state management and deployment complexity.
  • Databricks SDKs: Use Python, Go, or Java SDKs for programmatic automation where custom logic is needed, abstracting API authentication and error handling.
  • Databricks CLI: Best suited for one-time administrative or diagnostic actions; avoid using for orchestrated deployments.
  • Databricks REST APIs: Use only when SDKs or higher-level tools do not support a feature; SDKs are preferred for maintainability and resilience.
# Category Antipattern Countermeasure
1 Code Quality & Development Practices Loads of unnecessary if-else logic Refactor conditional logic into dedicated functions or leverage mapping structures to simplify decision flows and improve testability.
2 Code Quality & Development Practices A lot of repeated code Abstract common logic into reusable functions or modules to improve maintainability and reduce the likelihood of inconsistent behavior.
3 Code Quality & Development Practices Hardcoded API parameters and URLs Externalize all environment-specific values into configuration files, environment variables, or secrets management services.
4 Code Quality & Development Practices No docstrings used in functions Adopt standardized docstring formats (e.g., NumPy or Google style) to clearly describe function purpose, parameters, and return values.
5 Code Quality & Development Practices Hardly any logic encapsulated in functions Encapsulate logic into modular, well-defined functions or classes to enhance readability, reusability, and unit test coverage.
6 Code Quality & Development Practices Inconsistent use of Python variables (Camel_Case vs snake_case) Enforce PEP8 naming conventions via linting tools such as flake8 or black to maintain consistent code style.
7 Code Quality & Development Practices Zero Python standards like PEP8 are used Integrate automated code formatting and static analysis tools into CI pipelines to enforce compliance with Python best practices.
8 Code Quality & Development Practices Unformatted SparkSQL code, causing readability issues Adopt a consistent SQL formatting convention and use tooling or linters to enforce style and improve maintainability.
9 Code Quality & Development Practices Libraries (like pandas) imported but unused Perform periodic code cleanups to remove unused imports, commented-out blocks, and obsolete dependencies to improve clarity and performance. Use pre-commit hooks to check for unused libraries.
# Category Antipattern Countermeasure
1 Data Engineering & Pipeline Design Automatic schema evolution using autoMerge Disable automatic schema merging and implement explicit schema definitions validated against contract schemas or Delta Live Tables expectations.
2 Data Engineering & Pipeline Design No schema checks whatsoever Introduce schema validation at ingestion using libraries like Great Expectations or custom checks to enforce data quality boundaries.
3 Data Engineering & Pipeline Design Partition all data by yyyy/mm/dd/hh in ADLS or S3 Consider partitioning the following way: yyyy=2025mm=5dd=6hh=13.
4 Data Engineering & Pipeline Design Spark settings set in notebooks instead of cluster config Centralize Spark configuration in cluster or job settings to ensure consistency and prevent environment drift between executions.

Conclusion

We hope this setup helps solve some of the recurring challenges teams face when building and scaling on Databricks. By identifying common antipatterns and pairing them with actionable countermeasures, our goal is to promote cleaner engineering practices, more reliable pipelines, and a stronger governance foundation. Whether you’re refactoring existing workloads or designing new data products, adhering to these principles will help your teams deliver code that’s maintainable, secure, and production-ready. Continuous improvement in these areas not only streamlines your workflows but also strengthens the overall data ecosystem — enabling you to move faster with confidence.

Jaco