Skip to content

Comments

[HUDI-9141] Handle the case that dbName is empty in HoodieFileIndex#12885

Merged
danny0405 merged 4 commits intoapache:masterfrom
CTTY:ctty/minor-dbnamefix
Mar 12, 2025
Merged

[HUDI-9141] Handle the case that dbName is empty in HoodieFileIndex#12885
danny0405 merged 4 commits intoapache:masterfrom
CTTY:ctty/minor-dbnamefix

Conversation

@CTTY
Copy link
Contributor

@CTTY CTTY commented Feb 27, 2025

Change Logs

Database name can be null or empty, but in either case they should use the default value default. Handle this corner case in HoodieFileIndex

Issue this can cause:

Caused by: org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to fetch table basic_hudi_test_cow_glue_enabled_d7f80d5c_37ef_4c0a_a2bf_f2777b080a93. dbName cannot be null or empty
	at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:131)
	at org.apache.spark.sql.hive.HiveExternalCatalog.tableExists(HiveExternalCatalog.scala:917)
	at org.apache.spark.sql.catalyst.catalog.ExternalCatalogWithListener.tableExists(ExternalCatalogWithListener.scala:146)
	at org.apache.spark.sql.catalyst.catalog.SessionCatalog.tableExists(SessionCatalog.scala:524)
	at org.apache.spark.sql.internal.CatalogImpl.tableExists(CatalogImpl.scala:536)
	at org.apache.hudi.HoodieFileIndex$.getConfigProperties(HoodieFileIndex.scala:542)
	at org.apache.hudi.HoodieFileIndex.<init>(HoodieFileIndex.scala:97)
	at org.apache.hudi.HoodieMergeOnReadSnapshotHadoopFsRelationFactory.<init>(HoodieHadoopFsRelationFactory.scala:267)
	at org.apache.hudi.HoodieCopyOnWriteSnapshotHadoopFsRelationFactory.<init>(HoodieHadoopFsRelationFactory.scala:355)
	at org.apache.hudi.DefaultSource$.createRelation(DefaultSource.scala:346)
	at org.apache.hudi.DefaultSource.createRelation(DefaultSource.scala:158)
	at org.apache.spark.sql.execution.datasources.DataSource.$anonfun$resolveRelation$6(DataSource.scala:366)
	at org.apache.spark.util.FileAccessContext$.withContext(FileAccessContext.scala:41)
	at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:363)
	at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:345)
	at org.apache.spark.sql.execution.datasources.FindDataSourceTable$$anon$1.call(DataSourceStrategy.scala:268)
	at org.apache.spark.sql.execution.datasources.FindDataSourceTable$$anon$1.call(DataSourceStrategy.scala:255)
	at org.sparkproject.guava.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4792)
	at org.sparkproject.guava.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3599)
	at org.sparkproject.guava.cache.LocalCache$Segment.loadSync(LocalCache.java:2379)
	... 146 more
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: Unable to fetch table basic_hudi_test_cow_glue_enabled_d7f80d5c_37ef_4c0a_a2bf_f2777b080a93. dbName cannot be null or empty
	at org.apache.hadoop.hive.ql.metadata.Hive.getTable(Hive.java:1307)
	at org.apache.spark.sql.hive.client.Shim_v0_12.getTable(HiveShim.scala:628)
	at org.apache.spark.sql.hive.client.HiveClientImpl.getRawTableOption(HiveClientImpl.scala:414)
	at org.apache.spark.sql.hive.client.HiveClientImpl.$anonfun$tableExists$1(HiveClientImpl.scala:429)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
	at org.apache.spark.sql.hive.client.HiveClientImpl.$anonfun$withHiveState$1(HiveClientImpl.scala:303)
	at org.apache.spark.sql.hive.client.HiveClientImpl.liftedTree1$1(HiveClientImpl.scala:234)
	at org.apache.spark.sql.hive.client.HiveClientImpl.retryLocked(HiveClientImpl.scala:233)
	at org.apache.spark.sql.hive.client.HiveClientImpl.withHiveState(HiveClientImpl.scala:283)
	at org.apache.spark.sql.hive.client.HiveClientImpl.tableExists(HiveClientImpl.scala:429)
	at org.apache.spark.sql.hive.HiveExternalCatalog.$anonfun$tableExists$1(HiveExternalCatalog.scala:917)
	at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.java:23)
	at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:102)
	... 165 more
Caused by: java.lang.IllegalArgumentException: dbName cannot be null or empty
	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:92)
	at com.amazonaws.glue.catalog.metastore.GlueMetastoreClientDelegate.getTable(GlueMetastoreClientDelegate.java:556)
	at com.amazonaws.glue.catalog.metastore.AWSCatalogMetastoreClient.getTable(AWSCatalogMetastoreClient.java:1104)
	at org.apache.hadoop.hive.ql.metadata.Hive.getTable(Hive.java:1299)
	... 177 more

Impact

None

Risk level (write none, low medium or high below)

None

Documentation Update

none

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@github-actions github-actions bot added the size:S PR with lines of changes in (10, 100] label Feb 27, 2025
@CTTY CTTY mentioned this pull request Feb 28, 2025
4 tasks
Copy link
Contributor

@yihua yihua left a comment

Choose a reason for hiding this comment

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

LGTM. Could you add a test case?

@yihua
Copy link
Contributor

yihua commented Mar 4, 2025

Also, this is a bug fix so it's better to file and attach a JIRA ticket.

@CTTY CTTY changed the title [MINOR] Handle the case that dbName is empty in HoodieFileIndex [HUDI-9141] Handle the case that dbName is empty in HoodieFileIndex Mar 8, 2025
@CTTY CTTY force-pushed the ctty/minor-dbnamefix branch from 93102a5 to bf6f649 Compare March 8, 2025 05:59
@danny0405
Copy link
Contributor

@CTTY Can you take care of the test failures?

@CTTY CTTY force-pushed the ctty/minor-dbnamefix branch from dadcf60 to 1ce9d01 Compare March 11, 2025 21:14
@hudi-bot
Copy link
Collaborator

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

@danny0405 danny0405 merged commit ca24ab4 into apache:master Mar 12, 2025
43 checks passed
voonhous pushed a commit to voonhous/hudi that referenced this pull request Apr 8, 2025
voonhous pushed a commit to voonhous/hudi that referenced this pull request Apr 9, 2025
voonhous pushed a commit to voonhous/hudi that referenced this pull request Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-1.0.2 size:S PR with lines of changes in (10, 100]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants