-
Notifications
You must be signed in to change notification settings - Fork 3.4k
BigQuery: Add table validity check for BigQueryMetastoreCatalog #14113
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
Merged
kevinjqliu
merged 8 commits into
apache:main
from
thomaschow:tchow/check-table-validity-bqms
Sep 19, 2025
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bef7569
fix: Add table validity check for BigQueryMetastoreCatalog
thomaschow b050563
lint
thomaschow 9a2e653
move test
thomaschow acddd8f
Update bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBig…
nastra 8a33121
Apply suggestions from code review
nastra c9979c1
Update bigquery/src/test/java/org/apache/iceberg/gcp/bigquery/TestBig…
nastra 16a835a
Apply suggestions from code review
nastra 056da20
review feedback
thomaschow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,11 +21,19 @@ | |
| import static org.apache.iceberg.CatalogUtil.ICEBERG_CATALOG_TYPE; | ||
| import static org.apache.iceberg.CatalogUtil.ICEBERG_CATALOG_TYPE_BIGQUERY; | ||
| import static org.apache.iceberg.gcp.bigquery.BigQueryMetastoreCatalog.PROJECT_ID; | ||
| import static org.assertj.core.api.Assertions.assertThat; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.Mockito.spy; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import java.io.File; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import org.apache.iceberg.CatalogProperties; | ||
| import org.apache.iceberg.MetadataTableUtils; | ||
| import org.apache.iceberg.Table; | ||
| import org.apache.iceberg.TableMetadata; | ||
| import org.apache.iceberg.TableOperations; | ||
|
nastra marked this conversation as resolved.
Outdated
|
||
| import org.apache.iceberg.catalog.CatalogTests; | ||
| import org.apache.iceberg.catalog.Namespace; | ||
| import org.apache.iceberg.catalog.TableIdentifier; | ||
|
|
@@ -39,6 +47,8 @@ | |
| import org.junit.jupiter.api.io.TempDir; | ||
| import org.junit.jupiter.params.ParameterizedTest; | ||
| import org.junit.jupiter.params.provider.ValueSource; | ||
| import org.mockito.MockedStatic; | ||
| import org.mockito.Mockito; | ||
|
nastra marked this conversation as resolved.
Outdated
|
||
|
|
||
| public class TestBigQueryCatalog extends CatalogTests<BigQueryMetastoreCatalog> { | ||
| @TempDir private File tempFolder; | ||
|
|
@@ -144,9 +154,7 @@ public void createTableTransaction(int formatVersion) { | |
| @Test | ||
| public void testCreateTableWithDefaultColumnValue() {} | ||
|
|
||
|
nastra marked this conversation as resolved.
|
||
| @Disabled("BigQuery Metastore does not support multi layer namespaces") | ||
| @Test | ||
|
nastra marked this conversation as resolved.
Outdated
|
||
| public void testLoadMetadataTable() {} | ||
|
|
||
| @Disabled("BigQuery Metastore does not support rename tables") | ||
| @Test | ||
|
|
@@ -171,4 +179,30 @@ public void renameTableNamespaceMissing() { | |
| public void testRenameTableMissingSourceTable() { | ||
| super.testRenameTableMissingSourceTable(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testIsValidIdentifierWithValidSingleLevelNamespace() { | ||
| TableIdentifier validIdentifier = TableIdentifier.of("dataset1", "table1"); | ||
| assertThat(catalog.isValidIdentifier(validIdentifier)).isTrue(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testIsValidIdentifierWithInvalidMultiLevelNamespace() { | ||
| TableIdentifier invalidIdentifier = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: all of these can be inlined
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done, formatting creates multiple lines for a few of the more verbose cases. |
||
| TableIdentifier.of(Namespace.of("level1", "level2"), "table1"); | ||
| assertThat(catalog.isValidIdentifier(invalidIdentifier)).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testIsValidIdentifierWithThreeLevelNamespace() { | ||
| TableIdentifier invalidIdentifier = | ||
| TableIdentifier.of(Namespace.of("level1", "level2", "level3"), "table1"); | ||
| assertThat(catalog.isValidIdentifier(invalidIdentifier)).isFalse(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testIsValidIdentifierWithEmptyNamespace() { | ||
| TableIdentifier invalidIdentifier = TableIdentifier.of(Namespace.empty(), "table1"); | ||
| assertThat(catalog.isValidIdentifier(invalidIdentifier)).isFalse(); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.