public ASTNode parse(String command, Context ctx) throws ParseException { return parse(command, ctx, null); }
String whereStr = "field5=1 and field6 in ('a', 'b')"; String havingStr = "sum(field7) > 11"; ASTNode tree = parseDriver.parse(selectStr + " from table1 where " + whereStr + " group by field1, field2 having " + havingStr); assertEquals(tree.getType(), 0);
public ASTNode parse(String command) throws ParseException { return parse(command, null); }
public ASTNode parse(String command, Context ctx) throws ParseException { return parse(command, ctx, null); }
public ASTNode parse(String command) throws ParseException { return parse(command, null); }
ASTNode parse(String query) throws ParseException { ASTNode nd = pd.parse(query); return (ASTNode) nd.getChild(0); } @Test
@Test public void atFirstWarmup() throws Exception { // this test method is here to do an initial call to parsedriver; and prevent any tests with timeouts to be the first. parseDriver.parse("select 1"); }
/** Parses the Hive query. */ public static ASTNode parse( String command, Context ctx, String viewFullyQualifiedName) throws ParseException { ParseDriver pd = new ParseDriver(); ASTNode tree = pd.parse(command, ctx, viewFullyQualifiedName); tree = findRootNonNullToken(tree); handleSetColRefs(tree); return tree; }
@Test(timeout = 1000) public void testNestedFunctionCalls() throws Exception { // Expectation here is not to run into a timeout parseDriver.parse( "select greatest(1,greatest(1,greatest(1,greatest(1,greatest(1,greatest(1,greatest(1," + "greatest(1,greatest(1,greatest(1,greatest(1,greatest(1,greatest(1,greatest(1," + "greatest(1,greatest(1,(greatest(1,greatest(1,2)))))))))))))))))))"); }
ASTNode parse(String query) throws ParseException { ASTNode nd = pd.parse(query); return (ASTNode) nd.getChild(0); }
private static ASTNode parse(String command) throws ParseException { return (ASTNode) driver.parse(command).getChild(0); }
/** Parses the Hive query. */ public static ASTNode parse( String command, Context ctx, String viewFullyQualifiedName) throws ParseException { ParseDriver pd = new ParseDriver(); ASTNode tree = pd.parse(command, ctx, viewFullyQualifiedName); tree = findRootNonNullToken(tree); handleSetColRefs(tree); return tree; }
protected Set<TableName> findTableNames(final String query) { final ASTNode node; try { node = new ParseDriver().parse(normalize(query)); } catch (ParseException e) { // If failed to parse the query, just log a message, but continue. getLogger().debug("Failed to parse query: {} due to {}", new Object[]{query, e}, e); return Collections.emptySet(); } final HashSet<TableName> tableNames = new HashSet<>(); findTableNames(node, tableNames); return tableNames; }
protected Set<TableName> findTableNames(final String query) { final ASTNode node; try { node = new ParseDriver().parse(normalize(query)); } catch (ParseException e) { // If failed to parse the query, just log a message, but continue. getLogger().debug("Failed to parse query: {} due to {}", new Object[]{query, e}, e); return Collections.emptySet(); } final HashSet<TableName> tableNames = new HashSet<>(); findTableNames(node, tableNames); return tableNames; }
static ASTNode parse(String query, ParseDriver pd, HiveConf conf) throws ParseException { ASTNode nd = null; try { nd = pd.parse(query, new Context(conf)); } catch (IOException e) { e.printStackTrace(); } return (ASTNode) nd.getChild(0); }
ASTNode parse(String query) throws ParseException { ASTNode nd = null; try { nd = pd.parse(query, new Context(conf)); } catch (IOException e) { e.printStackTrace(); } return (ASTNode) nd.getChild(0); }
ASTNode parse(String query) throws ParseException { ASTNode nd = null; try { nd = pd.parse(query, new Context(conf)); } catch (IOException e) { e.printStackTrace(); } return (ASTNode) nd.getChild(0); }
@Test(timeout = 1000) public void testHIVE18624() throws Exception { parseDriver.parse("EXPLAIN\n" + "SELECT DISTINCT\n" + "\n" +
@Test public void parseInterval() throws Exception { ASTNode root = parseDriver.parse(query); assertNotNull("failed: " + query, findFunctionNode(root)); System.out.println(root.dump()); }
private AlterTableSimpleDesc parseAndAnalyze(String query) throws Exception { ParseDriver hd = new ParseDriver(); ASTNode head = (ASTNode)hd.parse(query).getChild(0); BaseSemanticAnalyzer a = SemanticAnalyzerFactory.get(queryState, head); a.analyze(head, new Context(conf)); List<Task<?>> roots = a.getRootTasks(); Assert.assertEquals(1, roots.size()); return ((DDLWork)roots.get(0).getWork()).getAlterTblSimpleDesc(); }