Uh oh!
There was an error while loading. Please reload this page.
[HUDI-6367] Fix NPE in HoodieAvroParquetReader and support complex schema with timestamp - #8955
Conversation
danny0405
commented
Jun 13, 2023
@xicm Hi, can you help with the review ? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| public static boolean supportTimestamp(Configuration conf) { | ||
| List<String> readCols = Arrays.asList(getReadColumnNames(conf)); | ||
| if (readCols.isEmpty()) { | ||
| return getIOColumnTypes(conf).contains("timestamp"); |
There was a problem hiding this comment.
@xicm Here I think it should return false directly, what do you think.
There was a problem hiding this comment.
Agree with you, @cdmikechen do you have any other concern?
There was a problem hiding this comment.
When the readCols can be empty ?
There was a problem hiding this comment.
When the
readColscan be empty ?
As far as I know, such as count(*) which doesn't need to read any cols
There was a problem hiding this comment.
In such case, the timestamp can be read correctly anyway?
There was a problem hiding this comment.
In such case, the timestamp can be read correctly anyway?
yes
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| @@ -50,24 +51,20 @@ public class HoodieAvroParquetReader extends RecordReader<Void, ArrayWritable> { | |||
| private Schema baseSchema; | |||
There was a problem hiding this comment.
In my origin PR HUDI-83 I didn't declare the baseSchema variable and didn't modify the getCurrentValue method.
In fact I would like to know if there is any problem or no NPE if we don't declare the baseSchema?
There was a problem hiding this comment.
In my origin PR HUDI-83 I didn't declare the
baseSchemavariable and didn't modify thegetCurrentValuemethod. In fact I would like to know if there is any problem or no NPE if we don't declare thebaseSchema?
I have tested that baseSchema need to be used in getCurrentValue, otherwise, the result field will be null, like this #7173 (comment)
There was a problem hiding this comment.
@Zouxxyy
I'm having some confusion, I remember doing some situation testing against Hive when I first made the changes (about 1 year ago), including count(*) or specified fields.
I don't know if some subsequent new FEATURE or PR has affected this, I think I'll do another test later this week. Although we have added a separate class to handle timestamp types, my original intention was to use Hive or Hadoop origin method as much as possible for other fields, otherwise it would be costly for us to maintain subsequently.
There was a problem hiding this comment.
@cdmikechen Have you ever tested select id, ts1 from test_ts_1? will return null if don't use baseSchema
Below is my full test, feel free to try
-- spark-sqlcreatetabletest_ts_1(
id int, ts1 timestamp)
using hudi
tblproperties(
type='mor', primaryKey='id'
);
INSERT INTO test_ts_1
SELECT1,
cast ('2021-12-25 12:01:01'astimestamp);
createtabletest_ts_2(
id int, ts1 array<timestamp>, ts2 map<string, timestamp>, ts3 struct<province:timestamp, city:string>)
using hudi
tblproperties(
type='mor', primaryKey='id'
);
INSERT INTO test_ts_2
SELECT1,
array(cast ('2021-12-25 12:01:01'astimestamp)),
map('key', cast ('2021-12-25 12:01:01'astimestamp)),
struct(cast ('2021-12-25 12:01:01'astimestamp), 'test');
-- hiveselect*from test_ts_1;
select id from test_ts_1;
select ts1 from test_ts_1;
select id, ts1 from test_ts_1;
selectcount(*) from test_ts_1;
select*from test_ts_2;
select id from test_ts_2;
select ts1 from test_ts_2;
select id, ts1 from test_ts_2;
selectcount(*) from test_ts_2;Zouxxyy
commented
Jun 14, 2023
@hudi-bot run azure |
1 similar comment
danny0405
commented
Jun 15, 2023
@hudi-bot run azure |
CTTY
commented
Jul 6, 2023
I'm seeing this failure when running unit test, this test seems to be added by this PR. Error message: Looks like only the order of column is wrong, but could you help me understand if this is a valid failure or we should fix the test? |
Zouxxyy
commented
Jul 7, 2023
Are you testing java17? https://github.com/apache/hudi/pull/9136/files#top from assertEquals("Field fake_field not found in log schema. Query cannot proceed! Derived Schema Fields: "
+ "[non_pii_col, _hoodie_commit_time, _row_key, _hoodie_partition_path, _hoodie_record_key, pii_col,"
+ " _hoodie_commit_seqno, _hoodie_file_name, timestamp]",
assertThrows(HoodieException.class, () ->
HoodieAvroUtils.generateProjectionSchema(originalSchema, Arrays.asList("_row_key", "timestamp", "fake_field"))).getMessage());to assertTrue(assertThrows(HoodieException. class, () ->
HoodieAvroUtils.generateProjectionSchema(originalSchema, Arrays.asList("_row_key", "timestamp", "fake_field")))
.getMessage().contains("Field fake_field not found in log schema. Query cannot proceed!")); |
Change Logs
Fix the following two scenarios when use hive to query tables containing timestamp fields
count(*)In this scenario,
HoodieColumnProjectionUtils.getReadColumnNames(conf)will be empty,baseSchemawill not be initialized, and NPE will be throwed when calling:Impact
Fix the above two problems
Risk level (write none, low medium or high below)
low
Documentation Update
None
Contributor's checklist