Skip to content

GCP: Avoid redundant namespace existence check in removeProperties#17061

Open
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/bigquery-removeproperties-redundant-check
Open

GCP: Avoid redundant namespace existence check in removeProperties#17061
thswlsqls wants to merge 1 commit into
apache:mainfrom
thswlsqls:fix/bigquery-removeproperties-redundant-check

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Closes #17059

Summary

  • BigQueryMetastoreCatalog.removeProperties() checked namespace existence via namespaceExists() (client.load()) before calling client.removeParameters(), which already performs the same existence check internally — doubling the BigQuery API GET requests.
  • Removes the redundant pre-check; removeProperties() now delegates directly to client.removeParameters(), matching setProperties() and the parity pattern in GlueCatalog/HiveCatalog, both of which check existence exactly once.
  • Behavior change: calling removeProperties() with an empty properties set on a namespace that does not exist now returns false instead of throwing NoSuchNamespaceException, because the isEmpty() check now runs before any existence check. SupportsNamespaces.removeProperties() documents this exception as optional, so this is not a contract violation.

Testing done

  • Added TestBigQueryMetastoreCatalog#removePropertiesChecksNamespaceExistenceOnlyOnce verifying client.load() is called exactly once (via a Mockito spy on FakeBigQueryMetastoreClient).
  • Added TestBigQueryMetastoreCatalog#removePropertiesPropagatesNoSuchNamespaceException verifying the exception thrown by client.removeParameters() still propagates.
  • Added TestBigQueryMetastoreCatalog#removePropertiesReturnsFalseForEmptyPropertiesWithoutCallingClient covering the documented behavior change.
  • ./gradlew :iceberg-bigquery:check — 126 tests passed (3 new + 123 existing), 0 failures.

BigQueryMetastoreCatalog.removeProperties() checked namespace
existence via namespaceExists() (client.load()) before delegating to
client.removeParameters(), which performs the same existence check
internally (another client.load() call). This doubled the BigQuery
API GET requests for a call that setProperties() and the Glue/Hive
catalogs perform with a single check. Removing the redundant
pre-check makes removeProperties() symmetric with setProperties()
and consistent with GlueCatalog/HiveCatalog.

Behavior change: calling removeProperties() with an empty properties
set on a namespace that does not exist now returns false instead of
throwing NoSuchNamespaceException, since the isEmpty() check now runs
before any existence check. SupportsNamespaces.removeProperties()
documents this exception as optional, so this is not a contract
violation.

Generated-by: Claude Code
@github-actions github-actions Bot added the GCP label Jul 3, 2026
private BigQueryMetastoreCatalog newCatalog(BigQueryMetastoreClient client) {
BigQueryMetastoreCatalog catalog = new BigQueryMetastoreCatalog();
catalog.setConf(new Configuration());
String warehouseLocation = tempFolder.toPath().resolve("hive-warehouse").toString();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hive-warehouse

bigquery-warehouse or just warehouse looks better.

Comment on lines +78 to +79
// client.removeParameters() already checks namespace existence internally, so
// removeProperties() must not perform a separate existence check of its own.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The source of the second removeProperties is unclear. I would rephrase like this:

BigQueryMetastoreClientImpl.removeParameters already checks namespace existence,
so BigQueryMetastoreCatalog.removeProperties should not duplicate that check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GCP: Avoid redundant namespace existence check in removeProperties

2 participants