HIVE-29525: Iceberg partitioned columns are not reflected by RelOptHiveTable - #6600
HIVE-29525: Iceberg partitioned columns are not reflected by RelOptHiveTable#6600kasakrisz wants to merge 5 commits into
Conversation
9cae808 to
40c9252
Compare
40c9252 to
481b616
Compare
481b616 to
726f582
Compare
| TableScan [TS_0] (rows=238 width=89) | ||
| default@srcbucket_mapjoin_part_1_n1,a,Tbl:COMPLETE,Col:COMPLETE,Grouping Num Buckets:2,Grouping Partition Columns:["key"],Output:["key","part"] | ||
| TableScan [TS_0] (rows=238 width=188) | ||
| default@srcbucket_mapjoin_part_1_n1,a,Tbl:COMPLETE,Col:PARTIAL,Grouping Num Buckets:2,Grouping Partition Columns:["key"],Output:["key","part"] |
There was a problem hiding this comment.
Is this (and other tests) moving from Col:COMPLETE to Col:PARTIAL because partitioned columns are now considered, and there are no stats for them? Or is it another reason?
There was a problem hiding this comment.
The explanation fits my understanding. One of the partitioned columns doesn't support statistics. Maybe the bucket(2, key) in srcbucket_mapjoin_part_1_n1.
There was a problem hiding this comment.
In the expression bucket(2, key) currently Hive can't treat key as a partition column. In the first version of the patch I tried but this leads to incomplete stats.
| File Output Operator [FS_32] | ||
| table:{"name:":"default.bucketmapjoin_tmp_result"} | ||
| Select Operator [SEL_31] (rows=785 width=366) | ||
| Select Operator [SEL_31] (rows=238000 width=366) |
| TableScan [TS_3] (rows=238 width=89) | ||
| default@srcbucket_mapjoin_part_2_n4,b,Tbl:COMPLETE,Col:COMPLETE,Output:["key","part"] | ||
| TableScan [TS_3] (rows=238 width=188) | ||
| default@srcbucket_mapjoin_part_2_n4,b,Tbl:COMPLETE,Col:PARTIAL,Output:["key","part"] |
| @@ -306,17 +306,17 @@ STAGE PLANS: | |||
| TableScan | |||
| alias: srcpart_iceberg | |||
| filterExpr: ds is not null (type: boolean) | |||
| Statistics: Num rows: 2000 Data size: 188000 Basic stats: COMPLETE Column stats: COMPLETE | |||
| Statistics: Num rows: 2000 Data size: 368000 Basic stats: COMPLETE Column stats: PARTIAL | |||
There was a problem hiding this comment.
is this expected change? why Column stats is PARTIAL?
| As of version: s1 | ||
| filterExpr: (a > 2) (type: boolean) | ||
| Statistics: Num rows: 1 Data size: 0 Basic stats: PARTIAL Column stats: COMPLETE | ||
| Statistics: Num rows: 1 Data size: 4 Basic stats: COMPLETE Column stats: PARTIAL |
There was a problem hiding this comment.
partitioned by spec (a), where a > 2 why it's PARTIAL ?
| throw new CalciteCteException("Failed to create temporary location", e); | ||
| } | ||
| Table hiveTable = new Table(metaTable); | ||
| hiveTable.setFields(columns.stream() |
There was a problem hiding this comment.
seems unrelated to the PR, do we have tests for this?
There was a problem hiding this comment.
This is called when a CTE is materialized at the CBO level. A temporary table is created to store the CTE result set and the table's fields were not set.
| public static <T> ImmutableMap<Integer, T> getColInfoMap(List<T> hiveCols, | ||
| int startIndx) { | ||
| Builder<Integer, T> bldr = ImmutableMap.<Integer, T> builder(); | ||
| public static ImmutableMap<Integer, ColumnInfo> getColInfoMap(List<ColumnInfo> hiveCols, Table table) { |
There was a problem hiding this comment.
how about
public static ImmutableMap<Integer, ColumnInfo> getColInfoMap(
List<ColumnInfo> hiveCols, ToIntFunction<String> indexByName) {
return Maps.uniqueIndex(hiveCols, ci -> indexByName.applyAsInt(ci.getInternalName()));
}
and then
this.hiveNonPartitionColsMap =
HiveCalciteUtil.getColInfoMap(hiveNonPartitionCols, hiveTblMetadata::getColumnIndexByName);
| int allColCount = tabMetaData.getAllCols().size(); | ||
| List<ColumnInfo> colInfoList = new ArrayList<>(Collections.nCopies(allColCount, null)); | ||
| Set<String> partColNames = new HashSet<>(tabMetaData.getPartColNames()); | ||
| ArrayList<ColumnInfo> nonPartitionColumns = new ArrayList<>(fields.size()); |
There was a problem hiding this comment.
change to
List<ColumnInfo> nonPartitionColumns...
| } | ||
|
|
||
| final TableType tableType = obtainTableType(tabMetaData); | ||
| List<ColumnInfo> partitionColumns = new ArrayList<>(partitionColumnSet); |
There was a problem hiding this comment.
List.copyOf(partitionColumnSet)
| // 3.2 Add column info corresponding to partition columns | ||
| // Normally, the column names in a schema should be unique, but in the case of Iceberg v1 tables, | ||
| // updating the partition spec doesn't remove the existing partition keys, so we can end up with a | ||
| // partition spec containing multiple columns with the same name. |
There was a problem hiding this comment.
can you elaborate? shouldn't the type be void in case column is dropped as part of schema evolution?
726f582 to
9fab0a3
Compare
…a TS is partition column and the stats are available
…a TS is partition column and the stats are available
f7f65ba to
e671c7b
Compare
|



What changes were proposed in this pull request?
Why are the changes needed?
Does this PR introduce any user-facing change?
How was this patch tested?