[
https://issues.apache.org/jira/browse/HIVE-10190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14492382#comment-14492382
]
Reuben Kuhnert commented on HIVE-10190:
---------------------------------------
Ah I see, I misunderstood your comment. I thought what you were after was
something more straightforward. But you really just want:
(1) Some simple utility class that will perform traversal (rather than hand
rolling code to do so).
(2) Use the actual Tokens rather than their {{toString}} representations.
#2 Is easy to fix, I see what you're after now, I just misread it.
#1 Is less easy. It looks like there is a way to offload traversal to ANTLR,
but after a lot of searching, it looks like the only way to do this is to use
'Tree Pattern Matching'
(https://theantlrguy.atlassian.net/wiki/display/ANTLR3/Tree+pattern+matching),
which is certainly doable, but requires modifying the parser grammar in
addition to applying the pattern matcher class within the
{{validateASTForUnsupportedTokens}}).If that's the correct path here, then I
can go ahead and get something put together. Just let me know what you think.
> CBO: AST mode checks for TABLESAMPLE with
> AST.toString().contains("TOK_TABLESPLITSAMPLE")
> -----------------------------------------------------------------------------------------
>
> Key: HIVE-10190
> URL: https://issues.apache.org/jira/browse/HIVE-10190
> Project: Hive
> Issue Type: Bug
> Components: CBO
> Affects Versions: 1.2.0
> Reporter: Gopal V
> Assignee: Pengcheng Xiong
> Priority: Trivial
> Labels: perfomance
> Attachments: HIVE-10190-querygen.py, HIVE-10190.01.patch,
> HIVE-10190.02.patch, HIVE-10190.03.patch
>
>
> {code}
> public static boolean validateASTForUnsupportedTokens(ASTNode ast) {
> String astTree = ast.toStringTree();
> // if any of following tokens are present in AST, bail out
> String[] tokens = { "TOK_CHARSETLITERAL", "TOK_TABLESPLITSAMPLE" };
> for (String token : tokens) {
> if (astTree.contains(token)) {
> return false;
> }
> }
> return true;
> }
> {code}
> This is an issue for a SQL query which is bigger in AST form than in text
> (~700kb).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)