public Schema getOutputSchema() { return getRootNode().getOutSchema(); }
public Schema getOutputSchema() { return getRootNode().getOutSchema(); }
@Test public final void testAlias2() throws TajoException { QueryContext qc = createQueryContext(); Expr expr = sqlAnalyzer.parse(ALIAS[1]); LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot(); LogicalRootNode root = (LogicalRootNode) plan; Schema finalSchema = root.getOutSchema(); Iterator<Column> it = finalSchema.getRootColumns().iterator(); Column col = it.next(); assertEquals("id", col.getSimpleName()); col = it.next(); assertEquals("total", col.getSimpleName()); }
@Test public final void testAlias1() throws TajoException { QueryContext qc = createQueryContext(); Expr expr = sqlAnalyzer.parse(ALIAS[0]); LogicalNode plan = planner.createPlan(qc, expr).getRootBlock().getRoot(); LogicalRootNode root = (LogicalRootNode) plan; Schema finalSchema = root.getOutSchema(); Iterator<Column> it = finalSchema.getRootColumns().iterator(); Column col = it.next(); assertEquals("deptname", col.getSimpleName()); col = it.next(); assertEquals("total", col.getSimpleName()); expr = sqlAnalyzer.parse(ALIAS[1]); plan = planner.createPlan(qc, expr).getRootBlock().getRoot(); root = (LogicalRootNode) plan; finalSchema = root.getOutSchema(); it = finalSchema.getRootColumns().iterator(); col = it.next(); assertEquals("id", col.getSimpleName()); col = it.next(); assertEquals("total", col.getSimpleName()); }
public static TableDesc getOutputTableDesc(LogicalPlan plan) { LogicalNode [] found = findAllNodes(plan.getRootNode().getChild(), NodeType.CREATE_TABLE, NodeType.INSERT); if (found.length == 0) { return new TableDesc(null, plan.getRootNode().getOutSchema(), "TEXT", new KeyValueSet(), null); } else { StoreTableNode storeNode = (StoreTableNode) found[0]; return new TableDesc( storeNode.getTableName(), storeNode.getOutSchema(), storeNode.getStorageType(), storeNode.getOptions(), storeNode.getUri()); } }
public static TableDesc getOutputTableDesc(LogicalPlan plan) { LogicalNode [] found = findAllNodes(plan.getRootNode().getChild(), NodeType.CREATE_TABLE, NodeType.INSERT); if (found.length == 0) { return new TableDesc(null, plan.getRootNode().getOutSchema(), "TEXT", new KeyValueSet(), null); } else { StoreTableNode storeNode = (StoreTableNode) found[0]; return new TableDesc( storeNode.getTableName(), storeNode.getOutSchema(), storeNode.getStorageType(), storeNode.getOptions(), storeNode.getUri()); } }
@Test public final void testExprNode() throws TajoException { QueryContext qc = createQueryContext(); Expr expr = sqlAnalyzer.parse(QUERIES[10]); LogicalPlan rootNode = planner.createPlan(qc, expr); LogicalNode plan = rootNode.getRootBlock().getRoot(); assertEquals(NodeType.ROOT, plan.getType()); LogicalRootNode root = (LogicalRootNode) plan; assertEquals(NodeType.EXPRS, root.getChild().getType()); Schema out = root.getOutSchema(); Iterator<Column> it = out.getRootColumns().iterator(); Column col = it.next(); assertEquals("res1", col.getSimpleName()); col = it.next(); assertEquals("res2", col.getSimpleName()); col = it.next(); assertEquals("res3", col.getSimpleName()); }
.build(); for (int i = 0; i < expectedSchema.size(); i++) { Column found = root.getOutSchema().getColumn(expectedSchema.getColumn(i).getSimpleName()); assertEquals(expectedSchema.getColumn(i).getDataType(), found.getDataType());