Skip to content

Commit

Permalink
Support BigQuery table snapshots (#898)
Browse files Browse the repository at this point in the history
* Support bigquery snapshot table

* Bump version
  • Loading branch information
elic-eon authored Jul 11, 2024
1 parent ea6451c commit 7e2d07a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
9 changes: 9 additions & 0 deletions metaphor/bigquery/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ def parse_schema(bq_table: bigquery.table.Table) -> DatasetSchema:
materialization=MaterializationType.MATERIALIZED_VIEW,
table_schema=bq_table.mview_query,
)
elif bq_table.table_type == "SNAPSHOT":
schema.sql_schema = SQLSchema(
materialization=MaterializationType.SNAPSHOT,
snapshot_time=(
bq_table.snapshot_definition.snapshot_time
if bq_table.snapshot_definition
else None
),
)
else:
raise ValueError(f"Unexpected table type {bq_table.table_type}")

Expand Down
10 changes: 5 additions & 5 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "metaphor-connectors"
version = "0.14.30"
version = "0.14.31"
license = "Apache-2.0"
description = "A collection of Python-based 'connectors' that extract metadata from various sources to ingest into the Metaphor app."
authors = ["Metaphor <[email protected]>"]
Expand Down Expand Up @@ -29,7 +29,7 @@ databricks-sdk = { version = "^0.29.0", optional = true }
databricks-sql-connector = { version = "^3.1.1", optional = true }
fastavro = { version = "^1.9.2", optional = true }
GitPython = "^3.1.37"
google-cloud-bigquery = { version = "^3.1.0", optional = true }
google-cloud-bigquery = { version = "^3.25.0", optional = true }
google-cloud-logging = { version = "^3.5.0", optional = true }
gql = { extras = ["requests"], version = "^3.4.1", optional = true }
grpcio-tools = { version = "^1.59.3", optional = true }
Expand All @@ -41,7 +41,7 @@ llama-index-readers-confluence = { version = "^0.1.4", optional = true }
llama-index-readers-notion = { version = "^0.1.6", optional = true }
looker-sdk = { version = "^24.2.0", optional = true }
lxml = { version = "~=5.0.0", optional = true }
metaphor-models = "0.35.5"
metaphor-models = "0.36.1"
more-itertools = { version = "^10.1.0", optional = true }
msal = { version = "^1.28.0", optional = true }
msgraph-beta-sdk = { version = "~1.4.0", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion tests/snowflake/test_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def should_raise(_0, _1):
extractor._fetch_table_info({normalized_name: table_info}, False, set())

assert dataset.schema.sql_schema.table_schema is None
assert dataset.statistics.last_updated is None
assert dataset.source_info.last_updated is None


@patch("metaphor.snowflake.auth.connect")
Expand Down

0 comments on commit 7e2d07a

Please sign in to comment.