Closed fhan688 closed 6 days ago
The current implementation missed database when building hudi config, which will lead to obtain the incorrect table even though the table exists. Such as the case of spark writing data https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/InsertIntoHoodieTableCommand.scala#L97
spark writing data
https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala#L251-L254 Because the value of DATABASE_NAME.key is lost when buildHoodieInsertConfig, so databaseName is empty in tableIdentifier. https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala#L667-L670
DATABASE_NAME.key
buildHoodieInsertConfig
databaseName
tableIdentifier
https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala#L674-L680 Then the table under the databaseName cannot be obtained or the table under the default database is obtained, it is obviously inconsistent with expectation.
default database
this PR fix this bug.
hudi-spark-common
Low
None
@fhan688 Thanks for the contribution, can you check the test failures.
Change Logs
The current implementation missed database when building hudi config, which will lead to obtain the incorrect table even though the table exists. Such as the case of
spark writing data
https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/spark/sql/hudi/command/InsertIntoHoodieTableCommand.scala#L97https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala#L251-L254 Because the value of
DATABASE_NAME.key
is lost whenbuildHoodieInsertConfig
, sodatabaseName
is empty intableIdentifier
. https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala#L667-L670https://github.com/apache/hudi/blob/cea81e82fdeecec4e1d7eb53ae1f8e9eaeede11c/hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala#L674-L680 Then the table under the
databaseName
cannot be obtained or the table under thedefault database
is obtained, it is obviously inconsistent with expectation.this PR fix this bug.
Impact
hudi-spark-common
Risk level (write none, low medium or high below)
Low
Documentation Update
None
Contributor's checklist