[ https://issues.apache.org/jira/browse/HIVE-26737?focusedWorklogId=827822&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-827822 ]
ASF GitHub Bot logged work on HIVE-26737: ----------------------------------------- Author: ASF GitHub Bot Created on: 22/Nov/22 00:45 Start Date: 22/Nov/22 00:45 Worklog Time Spent: 10m Work Description: scarlin-cloudera closed pull request #3794: HIVE-26737: experimenting URL: https://github.com/apache/hive/pull/3794 Issue Time Tracking ------------------- Worklog Id: (was: 827822) Time Spent: 1h 40m (was: 1.5h) > Subquery returning wrong results when database has materialized views > --------------------------------------------------------------------- > > Key: HIVE-26737 > URL: https://issues.apache.org/jira/browse/HIVE-26737 > Project: Hive > Issue Type: Bug > Components: HiveServer2 > Reporter: Steve Carlin > Priority: Major > Labels: pull-request-available > Time Spent: 1h 40m > Remaining Estimate: 0h > > When HS2 has materialized views in its registry, subqueries with correlated > variables may return wrong results. > An example of this: > > {code:java} > CREATE TABLE t_test1( > id int, > int_col int, > year int, > month int > ); > CREATE TABLE t_test2( > id int, > int_col int, > year int, > month int > ); > CREATE TABLE dummy ( > id int > ) stored as orc TBLPROPERTIES ('transactional'='true'); > CREATE MATERIALIZED VIEW need_a_mat_view_in_registry AS > SELECT * FROM dummy where id > 5; > INSERT INTO t_test1 VALUES (1, 1, 2009, 1), (10,0, 2009, 1); > INSERT INTO t_test2 VALUES (1, 1, 2009, 1); > select id, int_col, year, month from t_test1 s where s.int_col = (select > count(*) from t_test2 t where s.id = t.id) order by id; > {code} > The select statement should produce 2 rows, but it is only producing one. > The CBO plan produced has an inner join instead of a left join. > {code:java} > HiveSortLimit(sort0=[$0], dir0=[ASC]) > HiveProject(id=[$0], int_col=[$1], year=[$2], month=[$3]) > HiveJoin(condition=[AND(=($0, $5), =($4, $6))], joinType=[inner], > algorithm=[none], cost=[not available]) > HiveProject(id=[$0], int_col=[$1], year=[$2], month=[$3], > CAST=[CAST($1):BIGINT]) > HiveFilter(condition=[AND(IS NOT NULL($0), IS NOT > NULL(CAST($1):BIGINT))]) > HiveTableScan(table=[[default, t_test1]], table:alias=[s]) > HiveProject(id=[$0], $f1=[$1]) > HiveFilter(condition=[IS NOT NULL($1)]) > HiveAggregate(group=[{0}], agg#0=[count()]) > HiveFilter(condition=[IS NOT NULL($0)]) > HiveTableScan(table=[[default, t_test2]], table:alias=[t]){code} > -- This message was sent by Atlassian Jira (v8.20.10#820010)