ROOBALJINDAL commented on issue #14306:
URL: https://github.com/apache/hudi/issues/14306#issuecomment-3611733758

   Defining steps to reproduce it.
   Please note, we are ingesting xmls, hence we are using databricks spark-xml 
library : https://github.com/databricks/spark-xml/tree/v0.17.0
   
   **schema.xml**
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <echcf:Company xmlns:echcf="http://xml.edifecs.com/schema/ECHCF"; 
xmlns:ucf="http://xml.edifecs.com/schema/UCF"; 
xmlns:ucfd="http://xml.edifecs.com/schema/UCFD"; 
xmlns:hcfd="http://xml.edifecs.com/schema/HCFD"; version="1.1.1.4">
     <echcf:TotalPay>
         <hcfd:Pay>
           <hcfd:Rate value="999999999999999.99999"/>
           <hcfd:Basis value="sqiqspuaxn"/>
         </hcfd:Pay>
          <hcfd:BasisCalculation>
           <hcfd:Pay>999999999999999.99999</hcfd:Pay>
         </hcfd:BasisCalculation>
     </echcf:TotalPay>
   </echcf:Company>
   ```
   
   **input1.xml**
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <echcf:Company xmlns:echcf="http://xml.edifecs.com/schema/ECHCF"; 
xmlns:ucf="http://xml.edifecs.com/schema/UCF"; 
xmlns:ucfd="http://xml.edifecs.com/schema/UCFD"; 
xmlns:hcfd="http://xml.edifecs.com/schema/HCFD"; version="1.1.1.4">
     <echcf:TotalPay>
         <hcfd:Pay>
           <hcfd:Rate value="999999999999999.99999"/>
           <hcfd:Basis value="sqiqspuaxn"/>
         </hcfd:Pay>
          <hcfd:BasisCalculation>
           <hcfd:Pay>999999999999999.99999</hcfd:Pay>
         </hcfd:BasisCalculation>
     </echcf:TotalPay>
   </echcf:Company>
   ```
   
   **input2.xml**
   ```
   <?xml version="1.0" encoding="UTF-8"?>
   <echcf:Company xmlns:echcf="http://xml.edifecs.com/schema/ECHCF"; 
xmlns:ucf="http://xml.edifecs.com/schema/UCF"; 
xmlns:ucfd="http://xml.edifecs.com/schema/UCFD"; 
xmlns:hcfd="http://xml.edifecs.com/schema/HCFD"; version="1.1.1.4">
     <echcf:TotalPay>
         <hcfd:Pay>
           <hcfd:Rate value="999999999999999.99999"/>
           <hcfd:Basis value="sqiqspuaxn"/>
         </hcfd:Pay>
          <hcfd:BasisCalculation>
           <hcfd:Pay>999999999999999.99999</hcfd:Pay>
         </hcfd:BasisCalculation>
     </echcf:TotalPay>
   </echcf:Company>
   ```
   
   High level code:
   ```
   Dataset<Row> cloudDf = spark.read().format("com.databricks.spark.xml")
                       .....
                                        .option("rowTag", "Company")
                                        .option("valueTag", "defvalue")
                       .load(schema.xml);
           StructType schema = cloudDf.schema();
                
           DataFrameReader sparkReader = sparkReader.option("rowTag", 
ecfExtractETL.getRowTag())
                                .schema(schema)
                                .option("rowTag", "Company")
                   .option("valueTag", "defvalue")
                   .option("awsRegion", "us-west-2")
                                .option("compression", "gzip");
                
                Dataset<Row> dfInitial = finalSparkReader.load("input1.xml");
                //save dataset to hudi with UPSERT :: successful
                
                Dataset<Row> dfInitial = finalSparkReader.load("input2.xml");
                //save dataset to hudi with UPSERT :: failed
   
   ```
   
   First ingestion is successful but second fails with error: 
   `Caused by: org.apache.avro.SchemaParseException: Can't redefine: Pay 
   Caused by: org.apache.hudi.exception.HoodieException: 
   org.apache.avro.SchemaParseException: Can't redefine: Pay 
   Caused by: org.apache.hudi.exception.HoodieUpsertException: Error upserting 
bucketType UPDATE for partition :0`
   
   We can see the first record in hive as :
   ```
   Totalpay: 
   {basiscalculation={pay=999999999999999.99999}, 
pay={basis={_value=sqiqspuaxn, defvalue=null}, 
rate={_value=999999999999999.99999, defvalue=null}}}
   ```
   Schema in trino/hive: 
   
   <img width="918" height="59" alt="Image" 
src="https://github.com/user-attachments/assets/9b85b95a-a0b4-4108-8788-ce14dc983d75";
 />
   
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to