Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure 'name' is the first column when exporting in dbt format, considering column attributes #541

Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- Type conversion when importing contracts into dbt and exporting contracts from dbt (#534)
- Ensure 'name' is the first column when exporting in dbt format, considering column attributes (#541)

### Fixed
- Modify the arguments to narrow down the import target with `--dbt-model` (#532)
Expand Down
7 changes: 3 additions & 4 deletions datacontract/export/dbt_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@ def _supports_constraints(model_type):
def _to_columns(fields: Dict[str, Field], supports_constraints: bool, adapter_type: Optional[str]) -> list:
columns = []
for field_name, field in fields.items():
column = _to_column(field, supports_constraints, adapter_type)
column["name"] = field_name
column = _to_column(field_name, field, supports_constraints, adapter_type)
columns.append(column)
return columns


def _to_column(field: Field, supports_constraints: bool, adapter_type: Optional[str]) -> dict:
column = {}
def _to_column(field_name: str, field: Field, supports_constraints: bool, adapter_type: Optional[str]) -> dict:
column = {"name": field_name}
simonharrer marked this conversation as resolved.
Show resolved Hide resolved
adapter_type = adapter_type or "snowflake"
dbt_type = convert_to_sql_type(field, adapter_type)
if dbt_type is not None:
Expand Down
Loading