[ https://issues.apache.org/jira/browse/HIVE-22208?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16938384#comment-16938384 ]
Zoltan Matyus commented on HIVE-22208: -------------------------------------- [~jcamachorodriguez] I though I was pretty clever and solved this by calling {{SemanticAnalyzer.getQueryStringFromAst}} instead of {{TokenRewriteStream.toString}}. It seemed to be exactly for this purpose. But I broke masking and accidentally committed the results (running the tests with overwrite). Could you take a look at the patch (the code change only, disregard the modified q.out files) and give any hints? It seems it's not the parsing but the rewrite that needs to be fixed, right? (Based on this: bq. // The Tokens have no distinction between Identifiers and QuotedIdentifiers. > Column name with reserved keyword is unescaped when query including join on > table with mask column is re-written > ---------------------------------------------------------------------------------------------------------------- > > Key: HIVE-22208 > URL: https://issues.apache.org/jira/browse/HIVE-22208 > Project: Hive > Issue Type: Bug > Components: Hive > Affects Versions: 3.1.0, 4.0.0 > Reporter: Riju Trivedi > Assignee: Zoltan Matyus > Priority: Critical > Attachments: HIVE-22208.01.patch > > > Join query involving table with mask column and other having reserved > keyword as column name fails with SemanticException during parsing re-written > query : > Original Query : > {code:java} > select a.`date`, b.nm > from sample_keyword a > join sample_mask b > on b.id = a.id; > {code} > Re-written Query : > > {code:java} > select a.date, b.nm > from sample_keyword a > join (SELECT `id`, CAST(mask_hash(nm) AS string) AS `nm`, > BLOCK__OFFSET__INSIDE__FILE, INPUT__FILE__NAME, ROW__ID FROM > `default`.`sample_mask` )`b` > on b.id = a.id; > {code} > Re-written query does not have escape quotes for date column which cause > SemanticException while parsing : > {code:java} > org.apache.hadoop.hive.ql.parse.ParseException: line 1:9 cannot recognize > input near 'a' '.' 'date' in selection target > > at > org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.rewriteASTWithMaskAndFilter( > SemanticAnalyzer.java:12084) > at > org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal( > SemanticAnalyzer.java:12298) > at org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal( > CalcitePlanner.java:360) > at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze( > BaseSemanticAnalyzer.java:289) > at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:664) > at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1869) > {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)