Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,16 @@ public Map<String, String> loadNamespaceMetadata(Namespace namespace) {
}
}

@Override
protected boolean isValidIdentifier(TableIdentifier identifier) {
try {
validateNamespace(identifier.namespace());
} catch (IllegalArgumentException e) {
return false;
}
return true;
}

@Override
public String name() {
return catalogName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
nastra marked this conversation as resolved.
Outdated

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;
Comment thread
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;
Expand All @@ -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;
Comment thread
nastra marked this conversation as resolved.
Outdated

public class TestBigQueryCatalog extends CatalogTests<BigQueryMetastoreCatalog> {
@TempDir private File tempFolder;
Expand Down Expand Up @@ -144,9 +154,7 @@ public void createTableTransaction(int formatVersion) {
@Test
public void testCreateTableWithDefaultColumnValue() {}

Comment thread
nastra marked this conversation as resolved.
@Disabled("BigQuery Metastore does not support multi layer namespaces")
@Test
Comment thread
nastra marked this conversation as resolved.
Outdated
public void testLoadMetadataTable() {}

@Disabled("BigQuery Metastore does not support rename tables")
@Test
Expand All @@ -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 =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: all of these can be inlined

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The 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();
}
}
Loading