I'm getting error while reading PARQUET file from S3, and the reason comes that "final_height" column got String and Double types in a same partition. For information, there are over 20 columns in parquet file. The errors I'm getting are:
ERROR 1: Failed merging schema of file ".../part1.gz.parquet":
ERROR 2: Caused by: org.apache.spark.SparkException:
Failed to merge fields 'final_height' and 'final_height'. Failed to merge incompatible data types double and string
ERROR 3: com.databricks.sql.io.FileReadException:
Error while reading file ".../part1.gz.parquet".
Parquet column cannot be converted. Column: [final_height], Expected: StringType, Found: DOUBLE
ERROR 4: com.databricks.sql.io.FileReadException:
Error while reading file ".../part1.gz.parquet".
Parquet column cannot be converted. Column: [final_height], Expected: DoubleType, Found: BINARY
ERROR 5: org.apache.spark.sql.execution.datasources.SchemaColumnConvertNotSupportedException
Found some solutions when "part1.gz.parquet" has String data for X column, and "part2.gz.parquet" has Double data in a same column. But they aren't working when different types in a same column found in a same partition.
Tried:
- reading with mergeSchema and inferSchema options (got ERROR 1 & 2)
- reading with predefined manual schema with type String for "final_height" column (got ERROR 3 & 5)
- reading with predefined manual schema with type Double for "final_height" column (got ERROR 4 & 5)
Hoping for some solution :)
Thanks!