hudi icon indicating copy to clipboard operation
hudi copied to clipboard

Reading Merge_on_read table| Failing SchemaParseException: Empty name

Open sidnakoppa opened this issue 7 years ago • 7 comments

Hi ,

I have created hudi data-set passing below option.

.option(DataSourceWriteOptions.STORAGE_TYPE_OPT_KEY,"MERGE_ON_READ").

When I create table in hive with below serde properies i am getting exception while reading.

Exception : Failed with exception java.io.IOException:org.apache.avro.SchemaParseException: Empty name

ROW FORMAT SERDE  'com.uber.hoodie.hadoop.realtime.HoodieParquetSerde'
STORED AS INPUTFORMAT   'com.uber.hoodie.hadoop.realtime.HoodieRealtimeInputFormat'

If I create with below serde properties.I am unable to read the updated records.

ROW FORMAT SERDE  'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT 'com.uber.hoodie.hadoop.HoodieInputFormat'

I am able to read copy_on_write table's latest view

  1. Could you guide in reading the merge_on_read table's view to fetch the updated records.
  2. Also when I runsync tool for merge_on_read it is creating the table with serde HoodieInputFormat,but I have to create a realtime view

sidnakoppa avatar Apr 24 '19 13:04 sidnakoppa

@sidnakoppa When you run the HiveSyncTool, it registers the RealTime table with a suffix like : <your_table_name>_rt. You can query this table for real time queries.

Just let the hive sync tool register the table in the metastore instead of manually registering anything. Once you have some data written into the table, the "_rt" should give you results in merge_on_read.

n3nash avatar Apr 24 '19 16:04 n3nash

Thanks for the quick response. I have written the data as below

s.write.format("com.uber.hoodie") .option(HoodieWriteConfig.TABLE_NAME,"emp_mor") .option(DataSourceWriteOptions.STORAGE_TYPE_OPT_KEY,"MERGE_ON_READ") .option(DataSourceWriteOptions.RECORDKEY_FIELD_OPT_KEY,"emp_id") .option("hoodie.upsert.shuffle.parallelism",4) .mode(SaveMode.Append) .save("/apps/hive/warehouse/emp_mor")

Run Syntool with below params

java -cp /home/designer/hoodie/hoodie-hive-bundle-0.4.5-SNAPSHOT.jar::runsyn/* com.uber.hoodie.hive.HiveSyncTool --user root --database default --jdbc-url jdbc:hive2://10.20.0.10:10000 --pass root --table emp_mor --base-path hdfs://nn10.htrunk.com/apps/hive/warehouse/emp_mor/

Output

Trying to sync hoodie table emp_mor with base path /apps/hive/warehouse/emp_mor/ of type MERGE_ON_READ
 Found the last compaction commit as Optional.empty
 Found the last delta commit Optional[[20190424193634__deltacommit__COMPLETED]]
 - Table emp_mor is not found. Creating it

Table is created as below emp_mor but was expecting it be created as emp_mor_rt

CREATE EXTERNAL TABLE emp_mor( _hoodie_commit_time string COMMENT '', _hoodie_commit_seqno string COMMENT '', _hoodie_record_key string COMMENT '', _hoodie_partition_path string COMMENT '', _hoodie_file_name string COMMENT '', emp_id int COMMENT '', emp_name string COMMENT '', ts long COMMENT '') ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe' STORED AS INPUTFORMAT 'com.uber.hoodie.hadoop.HoodieInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat' LOCATION 'hdfs://nn10.htrunk.com:8020/apps/hive/warehouse/emp_mor/default'

So created realtime table as below in hive but facing the exception as Failing SchemaParseException: Empty name

CREATE EXTERNAL TABLE `emp_mor_rt`(
  `_hoodie_commit_time` string COMMENT '',
  `_hoodie_commit_seqno` string COMMENT '',
  `_hoodie_record_key` string COMMENT '',
  `_hoodie_partition_path` string COMMENT '',
  `_hoodie_file_name` string COMMENT '',
  `emp_id` int COMMENT '',
  `emp_name` string COMMENT '',
  `ts` long COMMENT '')
ROW FORMAT SERDE
  'com.uber.hoodie.hadoop.realtime.HoodieParquetSerde'
STORED AS INPUTFORMAT
  'com.uber.hoodie.hadoop.realtime.HoodieRealtimeInputFormat'
OUTPUTFORMAT
  'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
  'hdfs://nn10.htrunk.com:8020/apps/hive/warehouse/emp_mor/default'

sidnakoppa avatar Apr 25 '19 05:04 sidnakoppa

read is working in 0.4.6 version,but updated records are not fetched

  1. Realtime table is not created by hivesync tool. So, manually created Realtime table and records are fetched successfully. But even after multiple updates the fetched records are not the recent ones.

for instance

1st run - write record 1,"hudi_045",current_timestamp as ts read result -- 1, hudi_045 2nd run - write record 1,"hudi_046",current_timestamp as ts read result -- 1,hudi_046 3rd run -- write record 1, "hoodie_123",current_timestamp as ts read result --- 1,hudi_046 4th run -- write record 1, "hdie_1232324",current_timestamp as ts read result --- 1,hudi_046

So is there any compaction to be enabled before reading or while writing .

FYI - Failures reported were for 0.4.5V

sidnakoppa avatar Apr 25 '19 10:04 sidnakoppa

@sidnakoppa Something could be wrong with the setup for the realtime table to not be created by the hive sync tool automatically. if you take a look at the quickstart here : https://hudi.apache.org/docker_demo.html#step-3-sync-with-hive, it shows how both the tables should be created.

Can you create a new table with MERGE_ON_READ storage type and try syncing it again just to confirm that it doesn't work ?

On a side note, since you've anyways made the realtime table work, let me explain why you might not be seeing the latest records. Compaction process is just used to convert the delta files into a columnar file format such as parquet. You should be able to query the latest records from the "_rt" table, like "select * from your_table_rt" even without running compaction. My suspicion is that you are creating new partitions every time you insert new records. You can confirm this by performing a ls on the base path. If you see a new folder for every new record, this is the case. If there are new partitions created, you will need to run the hive sync tool everytime to register the hive partitions against the hive metastore. So try doing the following :

// insert records // call hive sync tool // inser records // call hive sync tool

Ideally, you can just write a wrapper job that invokes insert and hive sync tool one after another to avoid doing this manually. Hope this helps.

Also, let's try to resolve this ticket here but going forward, please ask questions on the mailing list for faster responses (https://hudi.apache.org/community.html)

n3nash avatar Apr 26 '19 00:04 n3nash

Thank you ,I was able to create tables using sync tool and I have posted the followup query in mailing list.

As suggested I run the set again.Below are the result

ds.withColumn("emp_name",lit("upd1 Emily")).withColumn("ts",current_timestamp).write.format("com.uber.hoodie") .option(HoodieWriteConfig.TABLE_NAME,"emp_mor_26") .option(DataSourceWriteOptions.RECORDKEY_FIELD_OPT_KEY,"emp_id") .option(DataSourceWriteOptions.STORAGE_TYPE_OPT_KEY,"MERGE_ON_READ") .option(DataSourceWriteOptions.PARTITIONPATH_FIELD_OPT_KEY, "part_by") .option("hoodie.upsert.shuffle.parallelism",4) .mode(SaveMode.Append) .save("/apps/hive/warehouse/emp_mor_26")

after multiple updates to same record ,the generated log.1 has multiple instances of the same record. At this point the updated record is not fetched.(n-1)th record is fetched.

14:45 /apps/hive/warehouse/emp_mor_26/2019/09/22/.278a46f9--87a_20190426144153.log.1 - has record that was updated in run 1
15:00 /apps/hive/warehouse/emp_mor_26/2019/09/22/.278a46f9--87a_20190426144540.log.1 - has record that was updated in run 2 and run 3
14:41 /apps/hive/warehouse/emp_mor_26/2019/09/22/.hoodie_partition_metadata
14:41 /apps/hive/warehouse/emp_mor_26/2019/09/22/278a46f9--87a_0_20190426144153.parquet

PS : I tried the same set running the sync tool after each run. same result.

sidnakoppa avatar Apr 26 '19 10:04 sidnakoppa

@sidnakoppa is this still relevant?

vinothchandar avatar Dec 02 '19 19:12 vinothchandar

Closing this due to inactivity.

bvaradar avatar Mar 06 '20 22:03 bvaradar