ggangadharan commented on code in PR #6990:
URL: https://github.com/apache/hive/pull/6990#discussion_r4740119407
##########
iceberg/iceberg-handler/src/test/queries/positive/iceberg_virtual_column_pushdown.q:
##########
@@ -0,0 +1,65 @@
+-- The filter Hive pushes to an Iceberg table prunes its data files; a virtual
column cannot be evaluated there.
+-- Each insert writes one file, and RECORDS_IN_Map_1 counts the rows of the
files that were read.
+set hive.fetch.task.conversion=none;
+set hive.vectorized.execution.enabled=true;
+
+create external table ice_vc (a int) stored by iceberg stored as parquet;
+insert into ice_vc values (1), (2);
+insert into ice_vc values (10), (11);
+insert into ice_vc values (20), (21);
+
+explain cbo select a from ice_vc where a = 1 or file__path is not null;
+
+-- Group the splits into one task, so the counters below do not depend on the
slots available to the cluster
+set tez.grouping.split-count=1;
+set
hive.exec.post.hooks=org.apache.hadoop.hive.ql.hooks.PostExecTezSummaryPrinter;
+
+-- under OR: every row qualifies, so every file must be read
+select a from ice_vc where a = 1 or file__path is not null order by a;
+select a from ice_vc where a = 1 or partition__spec__id = 0 order by a;
+select a from ice_vc where a = 1 or a = 10 or partition__spec__id = 0 order by
a;
Review Comment:
Added all of them. One thing I found while adding them: `SNAPSHOT__ID` reads
as NULL in a regular scan, so `snapshot__id is not null` is false for every
row. The results are therefore:
- `a = 1 or snapshot__id is not null`: reads every file (RECORDS_IN_Map_1:
6) and returns only row 1. I placed it with the false-branch OR case.
- `a = 1 and snapshot__id is not null`: returns no rows, and the scan still
prunes on `a = 1`.
- `delete from ice_vc_del where a = 1 and snapshot__id = 0` (format-version
2): both rows remain.
- Unit tests:
- a `SNAPSHOT__ID` OR case in
`testDecomposePredicatePushesNothingForNonConjunctionReadingVirtualColumn`;
- a `SNAPSHOT__ID` conjunct in
`testDecomposePredicateLeavesOutConjunctsReadingVirtualColumns`.
Note: the `SNAPSHOT__ID` queries run in row mode, because the Vectorizer
reports "Virtual column SNAPSHOT__ID is not supported". In row mode the Iceberg
reader applies the pushed filter per record, so their RECORDS_IN /
RAW_INPUT_SPLITS counters differ from the FILE__PATH queries. The results are
correct.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]