Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

- new `datacontract import powerbi` command : import PowerBI Semantic Model into an ODCS contract

### Added
- `datacontract test` now logs the Data Contract CLI version and whether it ran as a local CLI or through the FastAPI server (including the request URL) as part of the test result logs

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,7 @@ For more information about the Excel template structure, visit the [ODCS Excel T
│ spark Import a data contract from a Spark schema. │
│ iceberg Import a data contract from an Iceberg schema. │
│ excel Import a data contract from an Excel file. │
│ powerbi Import a data contract from an PowerBI template file. │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Example: datacontract import sql --source ddl.sql --dialect postgres --output datacontract.yaml
Expand Down
18 changes: 18 additions & 0 deletions datacontract/command_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,21 @@ def import_excel(
enable_debug_logging(debug)
result = DataContract.import_from_source(format="excel", source=source, schema=schema, owner=owner, id=id)
_write_result(result, output)


@import_app.command(
name="powerbi",
epilog="Example: datacontract import powerbi --source datacontract.pbit --output datacontract.yaml",
)
def import_powerbi(
source: Annotated[Optional[str], typer.Option(help="Path to the Power BI .pbit file.")] = None,
output: output_option = None,
schema: schema_option = None,
owner: owner_option = None,
id: id_option = None,
debug: debug_option = None,
):
"""Import a data contract from a Power BI .pbit file."""
enable_debug_logging(debug)
result = DataContract.import_from_source(format="powerbi", source=source, schema=schema, owner=owner, id=id)
_write_result(result, output)
1 change: 1 addition & 0 deletions datacontract/imports/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ImportFormat(str, Enum):
csv = "csv"
protobuf = "protobuf"
excel = "excel"
powerbi = "powerbi"

@classmethod
def get_supported_formats(cls):
Expand Down
6 changes: 5 additions & 1 deletion datacontract/imports/importer_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ def load_module_class(module_path, class_name):
module_path="datacontract.imports.excel_importer",
class_name="ExcelImporter",
)

importer_factory.register_lazy_importer(
name=ImportFormat.powerbi,
module_path="datacontract.imports.powerbi_importer",
class_name="PowerBIImporter",
)

importer_factory.register_lazy_importer(
name=ImportFormat.json,
Expand Down
Loading
Loading