Skip to content

Commit

Permalink
Merge branch 'paw/type-fix' into fixTypeAnnotations
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt committed Sep 22, 2023
2 parents a8871fb + 2608fda commit 86afcd2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20230922-125327.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Fixed a mypy failure by reworking BigQueryAdapter constructor.
time: 2023-09-22T12:53:27.339599-04:00
custom:
Author: peterallenwebb
Issue: "934"
38 changes: 4 additions & 34 deletions dbt/adapters/bigquery/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ class BigQueryAdapter(BaseAdapter):
ConstraintType.foreign_key: ConstraintSupport.ENFORCED,
}

def __init__(self, config) -> None:
super().__init__(config)
self.connections: BigQueryConnectionManager = self.connections

###
# Implementations of abstract methods
###
Expand Down Expand Up @@ -470,40 +474,6 @@ def _agate_to_schema(
bq_schema.append(SchemaField(col_name, type_)) # type: ignore[arg-type]
return bq_schema

def _materialize_as_view(self, model: Dict[str, Any]) -> str:
model_database = model.get("database")
model_schema = model.get("schema")
model_alias = model.get("alias")
model_code = model.get("compiled_code")

logger.debug("Model SQL ({}):\n{}".format(model_alias, model_code))
self.connections.create_view(
database=model_database, schema=model_schema, table_name=model_alias, sql=model_code
)
return "CREATE VIEW"

def _materialize_as_table(
self,
model: Dict[str, Any],
model_sql: str,
decorator: Optional[str] = None,
) -> str:
model_database = model.get("database")
model_schema = model.get("schema")
model_alias = model.get("alias")

if decorator is None:
table_name = model_alias
else:
table_name = "{}${}".format(model_alias, decorator)

logger.debug("Model SQL ({}):\n{}".format(table_name, model_sql))
self.connections.create_table(
database=model_database, schema=model_schema, table_name=table_name, sql=model_sql
)

return "CREATE TABLE"

@available.parse(lambda *a, **k: "")
def copy_table(self, source, destination, materialization):
if materialization == "incremental":
Expand Down

0 comments on commit 86afcd2

Please sign in to comment.