How datamole-ai/pysparkdt works
Project Type and Purpose
This is an open-source testing library specifically designed to facilitate local testing of Databricks workflows using PySpark and Delta tables. The key purpose is to emulate Unity Catalog behavior outside of Databricks environment.
Main Components
A. Core Library Components:
• Metastore Emulation Layer
• Spark Session Management
• Delta Table Handler
B. Testing Infrastructure:
• Local File System Interface
• Table Schema Management
• Test Data Management
C. Integration Points:
• PySpark Integration
• Delta Lake Integration
• Unity Catalog Emulation
┌─ Application Layer ─────────────────────────────────────┐
• User's Test Code │
• (pytest fixtures & test cases) │
• PySparkDT Core ──────────────────────────────────────┤
• ┌─ Test Setup ─┐ ┌─ Metastore ─┐ ┌─ Spark ─┐ │
• Data Loading │◄──┤Local Storage│◄──┤Session │ │
• Schema Init │ │ Management │ │Manager │ │
• ┘ └─────────────┘ └─────────┘ │
• Infrastructure Layer ─────────────────────────────────┤
• ┌─ File System ─┐ ┌─ Delta Lake ┐ ┌─ PySpark ┐ │
• NDJSON Data │ │ Table │ │ Execution│ │
• JSON Schema │ │ Operations │ │ Engine │ │
• ┘ └─────────────┘ └──────────┘ │
• ┘
Additional Elements
• Component type indicators
B. Notes Section:
• Key limitations (e.g., Map Key Type restriction)
• Important configuration points
• Test parallelization considerations
Implementation Details
• The spark_base function's role in session management
• The reinit_local_metastore function's operation
• Test data directory structure
• Delta table interaction patterns