[ https://issues.apache.org/jira/browse/HIVE-26737?focusedWorklogId=827785&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-827785 ]
ASF GitHub Bot logged work on HIVE-26737: ----------------------------------------- Author: ASF GitHub Bot Created on: 21/Nov/22 21:55 Start Date: 21/Nov/22 21:55 Worklog Time Spent: 10m Work Description: sonarcloud[bot] commented on PR #3794: URL: https://github.com/apache/hive/pull/3794#issuecomment-1322701145 Kudos, SonarCloud Quality Gate passed! [![Quality Gate passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png 'Quality Gate passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=3794) [![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png 'Bug')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=BUG) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=BUG) [0 Bugs](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=BUG) [![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png 'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=VULNERABILITY) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=VULNERABILITY) [0 Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=VULNERABILITY) [![Security Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png 'Security Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=3794&resolved=false&types=SECURITY_HOTSPOT) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=3794&resolved=false&types=SECURITY_HOTSPOT) [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=3794&resolved=false&types=SECURITY_HOTSPOT) [![Code Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png 'Code Smell')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=CODE_SMELL) [![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png 'A')](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=CODE_SMELL) [18 Code Smells](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=3794&resolved=false&types=CODE_SMELL) [![No Coverage information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/NoCoverageInfo-16px.png 'No Coverage information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=3794&metric=coverage&view=list) No Coverage information [![No Duplication information](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/NoDuplicationInfo-16px.png 'No Duplication information')](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=3794&metric=duplicated_lines_density&view=list) No Duplication information Issue Time Tracking ------------------- Worklog Id: (was: 827785) Time Spent: 1h 20m (was: 1h 10m) > 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 20m > 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)