PBI2Snow
Power BI to Snowflake SQL Translator - Convert Power BI models (.bim files) to Snowflake SQL with enhanced M and DAX support.
Features
- Complete Model Translation: Extract and convert entire Power BI data models
- M Language Support: Advanced translation of Power Query M expressions to SQL
- DAX Translation: Convert DAX formulas to Snowflake SQL equivalents
- Relationship Mapping: Preserve table relationships and foreign keys
- View Generation: Create optimized Snowflake views with proper naming conventions
- Configuration Options: Flexible translation modes and confidence levels
- Production Ready: Comprehensive error handling and logging
Installation
From PyPI (Recommended)
pip install pbi2snow
From Source
git clone https://github.com/llmsresearch/pbi2snow.git
cd pbi2snow
pip install -e .
Quick Start
Command Line Usage
# Basic usage
pbi2snow --bim-file model.bim --output-dir output/
# With custom schema and verbose output
pbi2snow --bim-file model.bim --output-dir output/ --target-schema MY_SCHEMA --verbose
# Production mode with high confidence threshold
pbi2snow --bim-file model.bim --mode production --confidence-threshold 80
Python API
from pbi2snow import extract
from pbi2snow.translator import UnifiedTranslator, TranslationConfig
# Load Power BI model
model_data = extract.collect('path/to/model.bim')
# Configure translator
config = TranslationConfig(
target_schema='SEMANTIC',
confidence_threshold=70,
mode='production'
)
# Translate model
translator = UnifiedTranslator(config)
results = []
for table in model_data['tables']:
result = translator.translate_table(table)
results.append(result)
print(f"Translated {len(results)} tables")
Command Line Options
| Option | Short | Default | Description |
|---|---|---|---|
--bim-file |
-b |
input/Model.bim |
Path to the BIM file |
--output-dir |
-o |
out_unified |
Output directory for SQL files |
--target-schema |
-s |
SEMANTIC |
Target Snowflake schema name |
--mode |
-m |
balanced |
Translation mode: conservative, balanced, aggressive |
--confidence-threshold |
-c |
50 |
Minimum confidence level (0-100) |
--verbose |
-v |
False |
Enable verbose logging |
Translation Modes
Conservative Mode
- High accuracy, lower coverage
- Only translates well-understood patterns
- Confidence threshold: 80+
Balanced Mode (Default)
- Good balance of accuracy and coverage
- Handles most common scenarios
- Confidence threshold: 50+
Aggressive Mode
- Maximum coverage, experimental translations
- May require manual review
- Confidence threshold: 20+
Output Structure
output/
├── views/ # Generated Snowflake views
│ ├── V_TABLE_NAME.sql # Individual view files
│ └── ...
├── manifest.json # Translation summary and metadata
└── all_views.sql # Combined SQL file
Supported Power BI Features
M Language (Power Query)
- Table transformations
- Column operations
- Filtering and grouping
- Joins and merges
- Data type conversions
- Custom functions (limited)
DAX Expressions
- Basic calculations
- Aggregations (SUM, COUNT, AVG, etc.)
- Time intelligence functions
- Filter functions (FILTER, CALCULATE)
- Relationship functions
- Complex nested expressions (limited)
Model Elements
- Tables and columns
- Relationships and foreign keys
- Calculated columns
- Calculated tables
- Measures (basic)
Use Cases
- Data Warehouse Migration: Move Power BI models to Snowflake
- SQL Modernization: Convert legacy BI logic to modern SQL
- Multi-Platform Support: Run the same logic on different platforms
- Performance Optimization: Leverage Snowflake's compute power
- Compliance & Governance: Centralize data transformations
Development Setup
# Clone the repository
git clone https://github.com/llmsresearch/pbi2snow.git
cd pbi2snow
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black pbi2snow/
flake8 pbi2snow/
License
This project is licensed under the MIT License - see the LICENSE file for details.
Roadmap
- Enhanced DAX function support
- Azure Synapse SQL support
- Power BI Premium integration
- Real-time translation validation
- Visual Studio Code extension
- Automated testing framework
Metadata
Release files for pbi2snow 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pbi2snow-2.0.0.tar.gz | 24.3 kB | Without provenance | Details for pbi2snow-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pbi2snow-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for pbi2snow-2.0.0-py3-none-any.whl |
Total release size: 48.2 kB
Release files / pbi2snow-2.0.0.tar.gz
| Download URL | pbi2snow-2.0.0.tar.gz |
|---|---|
| Size | 24.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bf3be9bcd93d73e34dad58a4f8d476aca808caa08673193a58ccf419676e4ee8
|
|
BLAKE2b-256 checksum How to use checksums |
3f99feec4c0f180ed58f3e64e4766bf485190a5e98e883fc0bc026d88575ef99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / pbi2snow-2.0.0-py3-none-any.whl
| Download URL | pbi2snow-2.0.0-py3-none-any.whl |
|---|---|
| Size | 23.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
363915cb9881bb435cc5a379a70d0bf157f2ff75e4e8b53b0c4eb6a38819f651
|
|
BLAKE2b-256 checksum How to use checksums |
e41fe93fef1e36bbae05edb16a4d5fe0bfa65eee8919858da5d24a330f4414ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Security for pbi2snow 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.