You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "rangareddy (via GitHub)" <gi...@apache.org> on 2025/01/08 16:35:55 UTC

Re: [I] [SUPPORT] `CREATE TABLE ... USING hudi` DDL does not preserve partitioning order when syncing to AWS Glue [hudi]

rangareddy commented on issue #10182:
URL: https://github.com/apache/hudi/issues/10182#issuecomment-2578119288

   Hi @sayanpaul-plaid 
   
   Could you please try the following code
   
   ```python
   df = spark.createDataFrame([{"a": 1, "b": 1, "c": 1, "d": 1}, {"a": 2, "b": 2, "c": 2, "d": 1}])
   df.show(truncate=False)
   
   table_name = "test_nonalpha_partitioning"
   database_name = "default"
   location = f"s3a://warehouse/{table_name}"
   
   hudi_options = {
       'hoodie.datasource.write.keygenerator.class': 'org.apache.hudi.keygen.CustomKeyGenerator',
       'hoodie.datasource.write.operation': 'upsert',
       'hoodie.datasource.write.partitionpath.field': 'c:SIMPLE,a:SIMPLE,b:SIMPLE',
       'hoodie.datasource.write.precombine.field': 'd',
       'hoodie.datasource.write.recordkey.field': 'd',
       'hoodie.database.name' : database_name,
       'hoodie.table.name' : table_name,
       'hoodie.datasource.write.table.name': table_name,
       'hoodie.datasource.write.table.type': 'COPY_ON_WRITE',
       'hoodie.datasource.write.hive_style_partitioning': 'true',
       'hoodie.datasource.meta.sync.enable': 'true',
       'hoodie.datasource.hive_sync.mode': 'hms',
       'hoodie.datasource.hive_sync.table' : table_name,
       'hoodie.datasource.hive_sync.database' : database_name,
       'hoodie.datasource.hive_sync.metastore.uris': 'thrift://hive-metastore:9083',
       'hoodie.datasource.hive_sync.partition_fields' : 'c:SIMPLE,a:SIMPLE,b:SIMPLE',
       'hoodie.datasource.hive_sync.partition_value_extractor':'org.apache.hudi.hive.MultiPartKeysValueExtractor'
   }
   
   df.write.format("hudi").options(**hudi_options).mode("overwrite").save(location)
   
   spark.sql(f"""create table {database_name}.{table_name} using hudi location '{location}'""")
   spark.sql(f"""create table {database_name}.{table_name}_new using hudi location '{location}'""")
   ```
   
   ```


-- 
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-unsubscribe@hudi.apache.org

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