This project has retired. For details please refer to its Attic page.
HQLParser (Lens 2.0.1-beta-incubating API)

org.apache.lens.cube.parse
Class HQLParser

java.lang.Object
  extended by org.apache.lens.cube.parse.HQLParser

public class HQLParser
extends Object


Nested Class Summary
static interface HQLParser.ASTNodeVisitor
           
static class HQLParser.TreeNode
           
 
Field Summary
static Set<Integer> ARITHMETIC_OPERATORS
           
static Set<Integer> BINARY_OPERATORS
           
static Pattern P_WSPACE
           
static Set<Integer> UNARY_OPERATORS
           
 
Constructor Summary
HQLParser()
           
 
Method Summary
static void bft(org.apache.hadoop.hive.ql.parse.ASTNode root, HQLParser.ASTNodeVisitor visitor)
          Breadth first traversal of AST
static org.apache.hadoop.hive.ql.parse.ASTNode copyAST(org.apache.hadoop.hive.ql.parse.ASTNode original)
           
static boolean equalsAST(org.apache.hadoop.hive.ql.parse.ASTNode n1, org.apache.hadoop.hive.ql.parse.ASTNode n2)
           
static org.apache.hadoop.hive.ql.parse.ASTNode findNodeByPath(org.apache.hadoop.hive.ql.parse.ASTNode root, int... path)
          Find a node in the tree rooted at root, given the path of type of tokens from the root's children to the desired node
static String getColName(org.apache.hadoop.hive.ql.parse.ASTNode node)
           
static Map<Integer,String> getHiveTokenMapping()
           
static String getString(org.apache.hadoop.hive.ql.parse.ASTNode tree)
           
static boolean hasAggregate(org.apache.hadoop.hive.ql.parse.ASTNode node)
           
static boolean isAggregateAST(org.apache.hadoop.hive.ql.parse.ASTNode node)
           
static boolean isArithmeticOp(int tokenType)
           
static boolean isSelectASTNode(org.apache.hadoop.hive.ql.parse.ASTNode node)
           
static void main(String[] args)
           
static org.apache.hadoop.hive.ql.parse.ASTNode parseExpr(String expr)
           
static org.apache.hadoop.hive.ql.parse.ASTNode parseHQL(String query)
           
static void printAST(org.apache.hadoop.hive.ql.parse.ASTNode node)
           
static void printAST(Map<Integer,String> tokenMapping, org.apache.hadoop.hive.ql.parse.ASTNode node, int level, int child)
          Debug function for printing query AST to stdout
static void toInfixString(org.apache.hadoop.hive.ql.parse.ASTNode root, StringBuilder buf)
          Recursively reconstruct query string given a query AST
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P_WSPACE

public static final Pattern P_WSPACE

BINARY_OPERATORS

public static final Set<Integer> BINARY_OPERATORS

ARITHMETIC_OPERATORS

public static final Set<Integer> ARITHMETIC_OPERATORS

UNARY_OPERATORS

public static final Set<Integer> UNARY_OPERATORS
Constructor Detail

HQLParser

public HQLParser()
Method Detail

isArithmeticOp

public static boolean isArithmeticOp(int tokenType)

parseHQL

public static org.apache.hadoop.hive.ql.parse.ASTNode parseHQL(String query)
                                                        throws org.apache.hadoop.hive.ql.parse.ParseException
Throws:
org.apache.hadoop.hive.ql.parse.ParseException

parseExpr

public static org.apache.hadoop.hive.ql.parse.ASTNode parseExpr(String expr)
                                                         throws org.apache.hadoop.hive.ql.parse.ParseException
Throws:
org.apache.hadoop.hive.ql.parse.ParseException

printAST

public static void printAST(org.apache.hadoop.hive.ql.parse.ASTNode node)

printAST

public static void printAST(Map<Integer,String> tokenMapping,
                            org.apache.hadoop.hive.ql.parse.ASTNode node,
                            int level,
                            int child)
Debug function for printing query AST to stdout

Parameters:
node -
level -

getHiveTokenMapping

public static Map<Integer,String> getHiveTokenMapping()
                                               throws Exception
Throws:
Exception

findNodeByPath

public static org.apache.hadoop.hive.ql.parse.ASTNode findNodeByPath(org.apache.hadoop.hive.ql.parse.ASTNode root,
                                                                     int... path)
Find a node in the tree rooted at root, given the path of type of tokens from the root's children to the desired node

Parameters:
root -
path - starts at the level of root's children
Returns:

copyAST

public static org.apache.hadoop.hive.ql.parse.ASTNode copyAST(org.apache.hadoop.hive.ql.parse.ASTNode original)

bft

public static void bft(org.apache.hadoop.hive.ql.parse.ASTNode root,
                       HQLParser.ASTNodeVisitor visitor)
                throws org.apache.hadoop.hive.ql.parse.SemanticException
Breadth first traversal of AST

Parameters:
root -
visitor -
Throws:
org.apache.hadoop.hive.ql.parse.SemanticException

toInfixString

public static void toInfixString(org.apache.hadoop.hive.ql.parse.ASTNode root,
                                 StringBuilder buf)
Recursively reconstruct query string given a query AST

Parameters:
root -
buf - preallocated builder where the reconstructed string will be written

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

getString

public static String getString(org.apache.hadoop.hive.ql.parse.ASTNode tree)

getColName

public static String getColName(org.apache.hadoop.hive.ql.parse.ASTNode node)

isAggregateAST

public static boolean isAggregateAST(org.apache.hadoop.hive.ql.parse.ASTNode node)

isSelectASTNode

public static boolean isSelectASTNode(org.apache.hadoop.hive.ql.parse.ASTNode node)
Parameters:
node - an ASTNode
Returns:
true when input node is a SELECT AST Node. Otherwise, false.

hasAggregate

public static boolean hasAggregate(org.apache.hadoop.hive.ql.parse.ASTNode node)

equalsAST

public static boolean equalsAST(org.apache.hadoop.hive.ql.parse.ASTNode n1,
                                org.apache.hadoop.hive.ql.parse.ASTNode n2)


Copyright © 2014–2015 Apache Software Foundation. All rights reserved.