Skip to content

Commit

Permalink
Considering the attributes within the column, name is placed first. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
syou6162 authored Dec 10, 2024
1 parent 117aa40 commit 7d34626
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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}
adapter_type = adapter_type or "snowflake"
dbt_type = convert_to_sql_type(field, adapter_type)
if dbt_type is not None:
Expand Down

0 comments on commit 7d34626

Please sign in to comment.