Unable to write the Array with null values
While saving this data of type Array
In current use case the Array[null] is expected scenario. Could you please guide
can you paste the schema or stacktrace to go on?
ds_030001161010.select("at_unique_id","id","multicomp").printSchema root |-- at_unique_id: array (nullable = true) | |-- element: string (containsNull = true) |-- id: string (nullable = true) |-- multicomp: string (nullable = true)
scala> ds_030001161010.select("at_unique_id","id","multicomp").show
+------------+--------------+---------+
|at_unique_id| id|multicomp|
+------------+--------------+---------+
| [null]|030001161010 |KI00110T00|
+------------+--------------+---------+
scala> ds_030001161010.select("at_unique_id","id","multicomp").write.format("com.uber.hoodie").option(HoodieWriteConfig.TABLE_NAME,"hoodie_full_account").option(DataSourceWriteOptions.RECORDKEY_FIELD_OPT_KEY,"id") .option(DataSourceWriteOptions.PARTITIONPATH_FIELD_OPT_KEY, "multicomp").option(DataSourceWriteOptions.PRECOMBINE_FIELD_OPT_KEY, "multicomp").mode(SaveMode.Append).save("/apps/hive/warehouse/hoodie_full_account");
ERROR HoodieCreateHandle: Error writing record from HoodieRecord{key=HoodieKey { recordKey=030001161010 partitionPath=KI00110T00}, currentLocation='null', newLocation='null'} java.lang.NullPointerException at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport.fromAvroString(AvroWriteSupport.java:281) at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport.writeValue(AvroWriteSupport.java:260) at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport.access$400(AvroWriteSupport.java:46) at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport$TwoLevelListWriter.writeCollection(AvroWriteSupport.java:456) at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport$ListWriter.writeList(AvroWriteSupport.java:305) at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport.writeValue(AvroWriteSupport.java:266) at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport.writeRecordFields(AvroWriteSupport.java:167) at com.uber.hoodie.org.apache.parquet.avro.AvroWriteSupport.write(AvroWriteSupport.java:142) at com.uber.hoodie.org.apache.parquet.hadoop.InternalParquetRecordWriter.write(InternalParquetRecordWriter.java:121) at com.uber.hoodie.org.apache.parquet.hadoop.ParquetWriter.write(ParquetWriter.java:288) at com.uber.hoodie.io.storage.HoodieParquetWriter.writeAvroWithMetadata(HoodieParquetWriter.java:90) at com.uber.hoodie.io.HoodieCreateHandle.write(HoodieCreateHandle.java:100) at com.uber.hoodie.func.CopyOnWriteLazyInsertIterable$CopyOnWriteInsertHandler.consumeOneRecord(CopyOnWriteLazyInsertIterable.java:146) at com.uber.hoodie.func.CopyOnWriteLazyInsertIterable$CopyOnWriteInsertHandler.consumeOneRecord(CopyOnWriteLazyInsertIterable.java:119) at com.uber.hoodie.common.util.queue.BoundedInMemoryQueueConsumer.consume(BoundedInMemoryQueueConsumer.java:38) at com.uber.hoodie.common.util.queue.BoundedInMemoryExecutor.lambda$null$2(BoundedInMemoryExecutor.java:124) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
The
AvroConversionUtils.scala
can be edited to manage the datatypes/values thanks
do you mind sharing your change? if its generally applicable, we can incorporate it back to the project @sidnakoppa
We have not changed yet ,but the planned change is to mock the null String value to empty. To mock null for other types default to be determined. def createConverterToAvro:
case ArrayType(elementType, _) =>
val elementConverter = createConverterToAvro( elementType, structName, getNewRecordNamespace(elementType, recordNamespace, structName)) (item: Any) => { //check element type if string if (item == null) { "null" or "any default " } else { //existing flow } }
but put on hold as the date and timestamp types are converted to long.
Hi , Just try changing the value of WRITE_OLD_LIST_STRUCTURE_DEFAULT parameter from true to false in AvroWriteSupport class. static final boolean WRITE_OLD_LIST_STRUCTURE_DEFAULT = false; It will allow array with null values.
@anchalkataria interesting.. there also seems to be a flag to flip it? https://github.com/apache/parquet-mr/blob/master/parquet-avro/src/main/java/org/apache/parquet/avro/AvroWriteSupport.java#L60
Closing due to inactivity