A Streamlit web application for viewing and managing table configurations stored in Databricks. This tool provides an intuitive interface for editing table schemas, managing primary keys, and handling Slowly Changing Dimension (SCD) configurations.
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Project Structure
- Architecture
- Development
- Troubleshooting
- Contributing
- License
-
Table Configuration Browser
- View all table configurations in a paginated list
- Filter by Source System, Table Key, and Table Name
- Real-time search and filtering capabilities
- Pagination support (10 rows per page)
-
Interactive Schema Editor
- Edit DataSchema fields with an intuitive data editor
- Add or remove schema fields dynamically
- Modify field properties (name, data type, nullable, comments)
- Visual representation of schema fields
-
Key Management
- Configure Primary Keys through UI checkboxes
- Set SCD (Slowly Changing Dimension) Join Keys
- Define SCD Sequence Keys
- Automatic synchronization with schema changes
-
Data Type Support
- String, Integer, Long, Double, Float
- Boolean, Date, Timestamp
- Decimal, Array, Struct, Map
-
Metadata Preservation
- Preserves existing metadata during schema edits
- Displays metadata fields as separate columns
- Supports custom metadata fields
-
Real-time Updates
- Changes are immediately saved to Databricks
- Automatic cache refresh after updates
- Connection status monitoring
- Clean, modern UI built with Streamlit
- Wide layout for better data visibility
- Sidebar navigation with quick actions
- Inline help text and tooltips
- Success/error notifications
- Raw JSON schema viewer
Before you begin, ensure you have the following installed:
- Python 3.8 or higher
- pip (Python package manager)
- Databricks workspace with SQL Warehouse access
- Databricks personal access token
- Access to a Databricks workspace
- SQL Warehouse configured and running
- Table with the following schema structure:
TableKey(identifier)SourceSystem(source system name)TableName(table name)DataSchema(JSON schema definition)PrimaryKeys(comma-separated or JSON array)ScdJoinKeys(comma-separated or JSON array)ScdSequenceKeys(comma-separated or JSON array)
git clone <repository-url>
cd table_config_app# Create virtual environment
python -m venv venv
# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activatepip install -r requirements.txtThis will install all required packages including:
- Streamlit (web framework)
- Databricks SQL Connector (database connectivity)
- Pandas & NumPy (data processing)
- Python-dotenv (environment management)
- Plotly & Altair (visualization)
- OpenPyXL & XlsxWriter (Excel export support)
- Development tools (Black, Flake8, Pytest)
Copy the template file and create your .env file:
cp env.template .envEdit the .env file with your Databricks credentials:
# Databricks SQL Warehouse Connection
DATABRICKS_SERVER_HOSTNAME=adb-1234567890123456.7.azuredatabricks.net
DATABRICKS_HTTP_PATH=/sql/1.0/warehouses/your-warehouse-id
DATABRICKS_TOKEN=dapiXXXXXXXXXXXXXXXXXXXXXXXXXXXX
# Optional: Environment Configuration
ENVIRONMENT=dev
LOG_LEVEL=INFO-
Server Hostname & HTTP Path:
- Go to your Databricks workspace
- Navigate to SQL Warehouses
- Click on your warehouse
- Go to Connection Details tab
- Copy the Server hostname and HTTP path
-
Access Token:
- In Databricks, click your username in the top right
- Select User Settings
- Go to Access Tokens tab
- Click Generate New Token
- Copy and save the token securely
Edit utils/config.py to point to your configuration table:
CATALOG = "your_catalog"
SCHEMA = "your_schema"
TABLE = "your_table_config".env file to version control!
- The
.envfile contains sensitive credentials - Add
.envto your.gitignorefile - Use the
env.templatefile as a reference - Rotate your access tokens regularly
Run the Streamlit application:
streamlit run app.pyThe application will automatically open in your default web browser at http://localhost:8501.
- View All Tables: The main page displays all table configurations
- Filter Results: Use the dropdowns and text inputs to filter tables
- Source System dropdown
- Table Key search
- Table Name search
- Navigate Pages: Use pagination controls to browse through tables
- View Details: Click "View →" button to edit a specific table
- Choose a Source System from the dropdown
- Select a table from the filtered list
- Click "🔄 Load This Table" to edit
-
The data editor displays all schema fields with columns:
- Source Name: Original field name from source
- Target Name: Target field name (required)
- Data Type: Select from supported types
- Nullable: Check if field can be null
- Is Primary Key: Mark as primary key
- Is SCD Join Key: Mark as SCD join key
- Is SCD Sequence Key: Mark as SCD sequence key
- Comment: Field description
-
Add Fields: Click the "+" button in the data editor
-
Remove Fields: Click the "×" button on any row
-
Edit Values: Click any cell to edit directly
- Review your changes in the data editor
- Click "💾 Save Schema Changes" to commit
- Changes are immediately written to Databricks
- Configuration keys (Primary Keys, SCD Keys) are automatically updated
- Reset: Click "↩️ Reset" to discard changes
- View Raw JSON: Expand the "🔍 View Raw JSON Schema" section
- Back to List: Use the sidebar button to return to main page
- Refresh Data: Clear cache and reload from database
While using Streamlit:
Ctrl/Cmd + R- Rerun the appCtrl/Cmd + C- Stop the serverC- Clear cacheR- Rerun
table_config_app/
├── app.py # Main application entry point
├── pages/
│ └── 1_Edit_Config.py # Edit configuration page
├── utils/
│ ├── __init__.py # Package initializer
│ ├── config.py # Configuration constants
│ ├── database.py # Database operations
│ └── table_config.py # TableConfig class
├── requirements.txt # Python dependencies
├── env.template # Environment template
├── .env # Environment variables (not in git)
├── .gitignore # Git ignore rules
└── README.md # This file
Main entry point and homepage of the application. Displays the table list with filtering, pagination, and navigation capabilities.
Key Functions:
main(): Application entry point- Renders table list view
- Handles filtering and pagination
- Manages connection status
Detail page for editing individual table configurations. Provides interactive schema editing with support for adding/removing fields.
Key Features:
- Table selection interface
- Schema editor with data_editor component
- Key management (Primary, SCD Join, SCD Sequence)
- Raw JSON viewer
Central configuration file containing Databricks table references.
Constants:
CATALOG: Databricks catalog nameSCHEMA: Schema nameTABLE: Configuration table nameFULL_TABLE_NAME: Complete table reference
Database connectivity and CRUD operations for Databricks SQL.
Key Functions:
get_connection(): Establish Databricks connectionfetch_table_list(): Retrieve all table configurationsfetch_table_config(TableKey): Get specific table configupdate_DataSchema(TableKey, schema): Update schemaupdate_table_config(TableKey, updates): Update config fields
TableConfig class for managing table configurations, schema parsing, and data transformations.
Key Methods:
__init__(table_key): Initialize and load configget_schema_dataframe(): Convert schema to DataFrameconvert_dataframe_to_schema(df): Convert DataFrame to schemaparse_key_list(key_name): Parse comma-separated keys- Property accessors for keys and schema
┌─────────────────┐
│ Streamlit UI │
│ (Browser) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ app.py / │
│ Edit_Config │
└────────┬────────┘
│
▼
┌─────────────────┐
│ TableConfig │
│ Class │
└────────┬────────┘
│
▼
┌─────────────────┐
│ database.py │
│ (SQL Queries) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Databricks │
│ SQL Warehouse │
└─────────────────┘
- Caching: Uses
@st.cache_resourcefor database connections - Session State: Manages pagination and selected tables
- Separation of Concerns: UI, business logic, and data access are separated
- Configuration Management: Centralized configuration in
utils/config.py
The application expects DataSchema to be stored as JSON with the following structure:
{
"fields": [
{
"name": "field_name",
"type": "string",
"nullable": true,
"metadata": {
"source_name": "source_field",
"target_name": "target_field",
"is_primary_key": false,
"comment": "Field description"
}
}
]
}This project uses:
- Black for code formatting
- Flake8 for linting
- Pytest for testing
# Format code
black .
# Run linter
flake8 .
# Run tests (if available)
pytest- Install development dependencies (included in requirements.txt)
- Set
ENVIRONMENT=devin your.envfile - Set
LOG_LEVEL=DEBUGfor verbose logging
When adding new features:
- Follow the existing project structure
- Add new pages in the
pages/directory - Add utility functions in
utils/modules - Update this README with new features
- Test thoroughly with your Databricks environment
Add a new data type:
Edit the SelectboxColumn options in pages/1_Edit_Config.py:
"Data Type": st.column_config.SelectboxColumn(
"Data Type",
options=["string", "integer", "your_new_type"],
required=True,
)Modify table configuration:
Edit utils/config.py:
CATALOG = "new_catalog"
SCHEMA = "new_schema"
TABLE = "new_table"Add new schema columns:
Extend the schema_to_dataframe() method in utils/table_config.py
Error: ❌ Failed to connect to Databricks
Solutions:
- Verify your
.envfile exists and contains correct credentials - Check that your Databricks SQL Warehouse is running
- Ensure your access token hasn't expired
- Verify network connectivity to Databricks workspace
Error: ❌ Missing required environment variables
Solutions:
- Create a
.envfile fromenv.template - Ensure all required variables are set
- Check for typos in variable names
Error: Failed to load table list
Solutions:
- Verify
CATALOG,SCHEMA, andTABLEinutils/config.py - Ensure your access token has read permissions
- Check that the table exists in your Databricks workspace
Error: ❌ Failed to update schema
Solutions:
- Ensure your access token has write permissions
- Check that all required fields are filled
- Verify Target Name is provided for all fields
- Look at the console output for SQL error details
Error: ModuleNotFoundError: No module named 'streamlit'
Solutions:
- Activate your virtual environment
- Run
pip install -r requirements.txt - Verify Python version is 3.8+
Enable debug mode for more detailed error messages:
# In .env file
LOG_LEVEL=DEBUG
# Run with Streamlit debug mode
streamlit run app.py --logger.level=debugIf you encounter issues:
- Check the Streamlit console output for error messages
- Enable debug logging in your
.envfile - Verify your Databricks connection using the SQL connector directly
- Check the Streamlit documentation
- Review Databricks SQL Connector docs
Contributions are welcome! Here's how you can help:
- Check if the bug has already been reported
- Include detailed steps to reproduce
- Provide error messages and logs
- Specify your environment (Python version, OS, etc.)
- Describe the feature and its use case
- Explain how it would benefit users
- Provide examples or mockups if possible
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Make your changes
- Run tests and linting
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- All submissions require review
- Follow existing code style and conventions
- Add tests for new functionality
- Update documentation as needed
This project is licensed under the MIT License - see the LICENSE file for details.
- Built with Streamlit
- Uses Databricks SQL Connector
- Powered by Pandas
For questions or support, please:
- Open an issue in the repository
- Contact the development team
- Check the documentation
Version: 1.0.0
Last Updated: November 2025
Status: Active Development
- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Configure
.envwith Databricks credentials - Run the app:
streamlit run app.py - Browse and edit your table configurations!
Happy configuring! 🎉