voonhous opened a new pull request, #9272:
URL: https://github.com/apache/hudi/pull/9272

   … recreating a table with existing hoodie.properties
   
   When recreating a hudi table with an existing hoodie.properties, the name of 
the hudi table will be changed to `topLevelRecord`.
   
   ```scala
    
   
   
   test("Test Create Hoodie Table with existing hoodie.properties") {
     withTempDir { tmp =>
       val tableName = generateTableName
       val tablePath = s"${tmp.getCanonicalPath}"
       spark.sql(
         s"""
            |create table $tableName (
            |  id int,
            |  name string,
            |  price double,
            |  ts long
            |) using hudi
            | location '$tablePath'
            | tblproperties (
            |  primaryKey ='id',
            |  type = 'cow',
            |  preCombineField = 'ts'
            | )
        """.stripMargin)
       // 
hoodie.table.create.schema={"type":"record","name":"h0_record","namespace":"hoodie.h0","fields":[{"name":"id","type":["int","null"]},{"name":"name","type":["string","null"]},{"name":"price","type":["double","null"]},{"name":"ts","type":["long","null"]}]},
 but got 
{"type":"record","name":"topLevelRecord","fields":[{"name":"id","type":["int","null"]},{"name":"name","type":["string","null"]},{"name":"price","type":["double","null"]},{"name":"ts","type":["long","null"]}]}
   
       // drop the table without purging hdfs directory
       spark.sql(s"drop table $tableName".stripMargin)
   
       val tableSchemaAfterCreate1 = HoodieTableMetaClient.builder()
         .setConf(spark.sparkContext.hadoopConfiguration)
         .setBasePath(tablePath).build().getTableConfig.getTableCreateSchema
   
       // avro schema name and namespace should not change should not change
       spark.newSession().sql(
         s"""
            |create table $tableName (
            |  id int,
            |  name string,
            |  price double,
            |  ts long
            |) using hudi
            | location '$tablePath'
            | tblproperties (
            |  primaryKey ='id',
            |  type = 'cow',
            |  preCombineField = 'ts'
            | )
        """.stripMargin)
       /// 
hoodie.table.create.schema={"type":"record","name":"topLevelRecord","fields":[{"name":"id","type":["int","null"]},{"name":"name","type":["string","null"]},{"name":"price","type":["double","null"]},{"name":"ts","type":["long","null"]}]}
   
       val tableSchemaAfterCreate2 = HoodieTableMetaClient.builder()
         .setConf(spark.sparkContext.hadoopConfiguration)
         .setBasePath(tablePath).build().getTableConfig.getTableCreateSchema
   
       assertResult(tableSchemaAfterCreate1.get)(tableSchemaAfterCreate2.get)
     } 
   ```
   
   This ticket is a followup for 
[HUDI-6145](https://issues.apache.org/jira/browse/HUDI-6145) to ensure that the 
name/namespace of the table is standardised accordingly.
   
   ### Change Logs
   
   Table is created with the new database/tableName instead of using 
`topLevelRecord`.
   
   ### Impact
   
   _Describe any public API or user-facing feature change or any performance 
impact._
   None
   
   ### Risk level (write none, low medium or high below)
   
   _If medium or high, explain what verification was done to mitigate the 
risks._
   None
   
   ### Documentation Update
   
   _Describe any necessary documentation update if there is any new feature, 
config, or user-facing change_
   
   - _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](https://hudi.apache.org/contribute/developer-setup#website) to 
make
     changes to the website._
   
   ### Contributor's checklist
   
   - [X] Read through [contributor's 
guide](https://hudi.apache.org/contribute/how-to-contribute)
   - [ ] Change Logs and Impact were stated clearly
   - [ ] Adequate tests were added if applicable
   - [ ] CI passed
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to