Skip to content

Commit

Permalink
Merge pull request #8 from DalgoT4D/premerge-tables-use-ref
Browse files Browse the repository at this point in the history
use ref while generating premerge table
  • Loading branch information
fatchat authored Sep 29, 2023
2 parents 12c2568 + 23b6b6c commit 6f23662
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions flattenairbyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def mk_dbtmodel(sourcename: str, srctablename: str, columntuples: list):
dbtmodel += f", _airbyte_data->>'{json_field}' as \"{sql_column}\""
dbtmodel += "\n"

dbtmodel += f"FROM {sourcename}.{srctablename}"
dbtmodel += f"FROM {{{{source('{sourcename}','{srctablename}')}}}}"

return dbtmodel

Expand Down Expand Up @@ -118,8 +118,8 @@ def mk_dbtmodel(sourcename: str, srctablename: str, columntuples: list):

# and the .sql model
model_sql = mk_dbtmodel(
SOURCE_SCHEMA,
tablename,
source['name'], # pass the source in the yaml file
modelname,
zip(json_fields, sql_columns),
)
dbtproject.write_model(DEST_SCHEMA, modelname, model_sql, logger=logger)
Expand Down
2 changes: 1 addition & 1 deletion mergetables.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def get_columnspec(schema_: str, table_: str):
else:
statement += f'NULL AS "{column}",'
statement = statement[:-1] # drop the final comma
statement += f" FROM {table['schema']}.{table['tablename']}"
statement += f"FROM {{{{ref('{table['tablename']}')}}}}"
dbtproject.write_model(
mergespec["outputsschema"],
f'premerge_{table["tablename"]}',
Expand Down

0 comments on commit 6f23662

Please sign in to comment.