-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Bigquery sync table require filter #36677
Conversation
869f11f
to
7352041
Compare
our-metadata (our-metadata database) | ||
strip-desc (fn [metadata] | ||
(set (map #(dissoc % :description) metadata))) | ||
name+schema->db-table (m/index-by (juxt :name :schema) db-tables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a stab at refactoring this sync step a bit.
Details in the following comments
(when (seq changed-tables) | ||
(sync-util/with-error-handling (format "Error updating table description for %s" (sync-util/name-for-logging database)) | ||
(update-table-description! database changed-tables))) | ||
(sync-util/with-error-handling (format "Error updating table metadata for %s" (sync-util/name-for-logging database)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously, only table description could be updated during sync step, but I've changed it so that it could extend to other properties too.
table-metadata) | ||
to-update-keys) | ||
[_ changes _] (data/diff old-table new-table) | ||
changes (cond-> changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a specical case, check test metabase.sync.sync-metadata.comments-test/sync-existing-table-comment-test
and metabase.sync.sync-metadata.comments-test/dont-overwrite-table-custom-description-test
to know how it's expected to work.
@@ -114,7 +117,14 @@ | |||
(mt/dataset (basic-table "table_with_comment_after_sync" nil) | |||
;; modify the source DB to add the comment and resync | |||
(driver/notify-database-updated driver/*driver* (mt/db)) | |||
(tx/create-db! driver/*driver* (basic-table "table_with_comment_after_sync" "added comment")) | |||
(tx/create-db! driver/*driver* (basic-table "table_with_comment_after_sync" nil)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test relied on the fact that descriptions are not included when inserting tables, the correct behavior is to start with a table without a description, then sync, then add a description, then sync. see https://github.com/metabase/metabase/pull/36677/files#r1427842665 for context.
@@ -185,8 +185,8 @@ | |||
(mt/with-test-user :rasta | |||
(automagic-dashboards.test/with-dashboard-cleanup | |||
(doseq [[table cardinality] (map vector | |||
(t2/select Table :db_id (mt/id) {:order-by [[:id :asc]]}) | |||
[15 11 7 5])] | |||
(t2/select Table :db_id (mt/id) {:order-by [[:name :asc]]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 things happening here:
- this is a consequence of test tables ids being changed (context).
- after Move
sample-dataset
intotest-data
for backend tests #35973, the test-data database now has 8 tables. so that's why you see my changes also include 4 more items.
@@ -16,15 +16,15 @@ describe("scenarios > admin > datamodel > hidden tables (metabase#9759)", () => | |||
|
|||
it("hidden table should not show up in various places in UI", () => { | |||
// Visit the main page, we shouldn't be able to see the table | |||
cy.visit(`/browse/${PRODUCTS_ID}`); | |||
cy.visit(`/browse/${SAMPLE_DB_ID}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a mistake and it accidentally works because producs_id
and sample_db_id
had the same id (=1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦♂️
modules/drivers/bigquery-cloud-sdk/test/metabase/driver/bigquery_cloud_sdk_test.clj
Show resolved
Hide resolved
Co-authored-by: Cal Herries <39073188+calherries@users.noreply.github.com>
modules/drivers/bigquery-cloud-sdk/src/metabase/driver/bigquery_cloud_sdk.clj
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solid work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually sorry, I think you're missing a test case for a table that is initially created without a required filter, then synced, then is modified to have a required filter, then synced again. Similar to sync-existing-table-comment-test
This is not possible in bigquery because whether a table requires partition or not is a property it's created with. afaik You can't change it after. I could add sth like |
Also using SQL (source):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
@qnkhuat Did you forget to add a milestone to the issue for this PR? When and where should I add a milestone? |
First milestone of #36668
Known limitation: this won't work for materialized views, see https://github.com/metabase/metabase/pull/36677/files#diff-370f1464c7c10bd0d0bd84544e6f80102152617fcd99fea6e9bd4dbaff4903caR131-R135 for why
To read more about partitioned tables, see https://cloud.google.com/bigquery/docs/partitioned-tables