You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "Reuben (JIRA)" <ji...@apache.org> on 2015/04/08 22:48:12 UTC
[jira] [Commented] (HIVE-10190) CBO: AST mode checks for
TABLESAMPLE with AST.toString().contains("TOK_TABLESPLITSAMPLE")
[ https://issues.apache.org/jira/browse/HIVE-10190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14485983#comment-14485983 ]
Reuben commented on HIVE-10190:
-------------------------------
I think I maybe have a solution for this, but not sure how to test a 700+ KB query:
{code}
public static boolean validateASTForUnsupportedTokens(ASTNode ast) {
Stack<ASTNode> fringe = new Stack<ASTNode>();
Set<String> unsupportedTokens = new HashSet<String>() {{
add("TOK_CHARSETLITERAL");
add("TOK_TABLESPLITSAMPLE");
}};
// Flat-DFS.
fringe.push(ast);
while (!fringe.isEmpty()) {
ASTNode current = fringe.pop();
if (current.getChildCount() > 0) {
for (Node child : current.getChildren()) {
fringe.push((ASTNode)child);
}
}
if (unsupportedTokens.contains(current.getText())) {
return false;
}
}
}
{code}
> 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: Laljo John Pullokkaran
> Priority: Trivial
> Labels: perfomance
>
> {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)