apache / hudi

Upserts, Deletes And Incremental Processing on Big Data.
https://hudi.apache.org/
Apache License 2.0
5.24k stars 2.39k forks source link

[SUPPORT]Flink writes MOR table, both RO table and RT table read nothing by hive #10465

Open nicholasxu opened 6 months ago

nicholasxu commented 6 months ago

Describe the problem you faced

I use Flink write HUDI MOR table, and Flink read table normally, while RO table and RT table read nothing by hive

To Reproduce

Steps to reproduce the behavior:

  1. Create hive catalog as follows:

CREATE CATALOG hudi_hive_catalog WITH ( 'type'='hudi', 'catalog.path' = 'cosn://bigdata-xxx/user/hive/warehouse', 'hive.conf.dir' = '/usr/local/service/hive/conf', 'mode'='hms', 'table.external' = 'true', 'default-database' = 'hudi_default' );

  1. Use catalog and create table as follows:

use CATALOG hudi_hive_catalog;

CREATE TABLE t1( mid BIGINT PRIMARY KEY NOT ENFORCED, uuid VARCHAR(20), name VARCHAR(10), age INT, ts BIGINT, part INT ) PARTITIONED BY (part) WITH ( 'connector' = 'hudi', 'path' = 'cosn://bigdata-xxx/user/hive/warehouse/hudi_default.db/t1', 'table.type' = 'MERGE_ON_READ', 'hive_sync.enable' = 'true',
'hive_sync.mode' = 'hms',
'hive_sync.metastore.uris' = 'thrift://xxx:9083' )

3.Insert some data by Flink INSERT INTO t1 VALUES (1,'334e26e9-8355-45cc-97c6-c31daf0df330','nick', 18,1695159649087,20230108), (2,'334e26e9-8355-45cc-97c6-c31daf0df330','jack', 18,1695159649087,20230109);

4.Read data by Flink and get right records SELECT * FROM t1; image

  1. Use 'select ' reading data by Hive and get nothing select from t1_rt; image select * from t1_ro; image

  2. Read data with 'order by clause' by Hive and get right results select from t1_rt order by mid; image select from t1_ro order by mid; image

8.Huid files on cos: image

9.Test COW table is ok

Expected behavior Reading nothing from RO table may be OK, because it only has a log file and without parquet base files, but reading nothing from RT table is confused, your help is appreciative.

Environment Description

ad1happy2go commented 6 months ago

@nicholasxu It may be due to caching I guess. Can you restart hive and see if you can query the data using select * from table

nicholasxu commented 6 months ago

@nicholasxu It may be due to caching I guess. Can you restart hive and see if you can query the data using select * from table

Thx, I restart all hive services, and set hive.stats.autogather=false, but it still gets nothing.

ad1happy2go commented 6 months ago

@nicholasxu Can you please also try to give all column names once instead of select *

nicholasxu commented 6 months ago

@nicholasxu Can you please also try to give all column names once instead of select *

  1. select all column names image
  1. select all column names with sort by image image

With 'sort by' clause , it assuredly generates a tez job. I don't know if it affects

ad1happy2go commented 6 months ago

@nicholasxu That probably may be the reason. As with hive simple select * doesn't trigger the TEZ job. you can try adding condition WHERE 1 = 1 which should trigger job.

Flink job directly write log files, Did compaction happened? may be no parquet files generated yet and select * directly reading from parquet.

nicholasxu commented 6 months ago

@nicholasxu That probably may be the reason. As with hive simple select * doesn't trigger the TEZ job. you can try adding condition WHERE 1 = 1 which should trigger job.

Flink job directly write log files, Did compaction happened? may be no parquet files generated yet and select * directly reading from parquet.

Condition 'WHERE 1 = 1' doesn't trigger a job yet and yep no compaction happened. I wanna know RT table(snapshot and Incremental queries) only reads from parquet isn't abnormal?

ad1happy2go commented 6 months ago

It's may be more related to how hive works and when it submits Tez job. As we know there is the data for sure underlying as with Tez job we are getting the data. '

In ideal scenario _rt table should get us know from log files.

xicm commented 6 months ago

https://www.yuque.com/yuzhao-my9fz/kb/kgv2rb. Hive 3.1.0 兼容,

LOG_FILE_PATTERN may be out of date, see the latest LOG_FILE_PATTERN in hudi code.

nicholasxu commented 6 months ago

It's may be more related to how hive works and when it submits Tez job. As we know there is the data for sure underlying as with Tez job we are getting the data. '

In ideal scenario _rt table should get us know from log files.

That's logical.

nicholasxu commented 6 months ago

https://www.yuque.com/yuzhao-my9fz/kb/kgv2rb. Hive 3.1.0 兼容,

LOG_FILE_PATTERN may be out of date, see the latest LOG_FILE_PATTERN in hudi code.

Thx, it maybe the cause!

nicholasxu commented 6 months ago

It's may be more related to how hive works and when it submits Tez job. As we know there is the data for sure underlying as with Tez job we are getting the data. '

In ideal scenario _rt table should get us know from log files.

I have another question about flink async compaction in the same process, whether it needs additional configurations in DDL? Or it is supported default?

danny0405 commented 6 months ago

Supported by default.

nicholasxu commented 6 months ago

Supported by default.

@danny0405 I tried, It is indeed supported by default. I am confused why the log files won't be deleted after compaction!
In my opinion log files should be deleted immediately after compaction to reduce files num. Is it right? image

ad1happy2go commented 6 months ago

@nicholasxu They are deleted as part of cleaning process. We do need them for point in time queries.

nicholasxu commented 6 months ago

@nicholasxu They are deleted as part of cleaning process. We do need them for point in time queries.

Ok, thx!