/** * Generates an expression node descriptors for the expression and children of it * with default TypeCheckCtx. */ public Map<ASTNode, ExprNodeDesc> genAllExprNodeDesc(ASTNode expr, RowResolver input) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input); return genAllExprNodeDesc(expr, input, tcCtx); }
public ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input, boolean useCaching, boolean foldExpr) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, foldExpr); return genExprNodeDesc(expr, input, tcCtx); }
public ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input, boolean useCaching, boolean foldExpr) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, foldExpr); return genExprNodeDesc(expr, input, tcCtx); }
/** * Generates an expression node descriptors for the expression and children of it * with default TypeCheckCtx. */ public Map<ASTNode, ExprNodeDesc> genAllExprNodeDesc(ASTNode expr, RowResolver input) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input); return genAllExprNodeDesc(expr, input, tcCtx); }
private void setupSelectListInputInfo() throws SemanticException { selectListInputTypeCheckCtx = new TypeCheckCtx(selectListInputRowResolver); selectListInputTypeCheckCtx.setUnparseTranslator(null); /* * create SelectListOI */ selectListInputOI = PTFTranslator.getStandardStructOI(selectListInputRowResolver); }
private void setupSelectListInputInfo() throws SemanticException { selectListInputTypeCheckCtx = new TypeCheckCtx(selectListInputRowResolver); selectListInputTypeCheckCtx.setUnparseTranslator(null); /* * create SelectListOI */ selectListInputOI = PTFTranslator.getStandardStructOI(selectListInputRowResolver); }
private List<RexNode> getPartitionKeys(PartitionSpec ps, RexNodeConverter converter, RowResolver inputRR) throws SemanticException { List<RexNode> pKeys = new ArrayList<RexNode>(); if (ps != null) { List<PartitionExpression> pExprs = ps.getExpressions(); for (PartitionExpression pExpr : pExprs) { TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR); tcCtx.setAllowStatefulFunctions(true); ExprNodeDesc exp = genExprNodeDesc(pExpr.getExpression(), inputRR, tcCtx); pKeys.add(converter.convert(exp)); } } return pKeys; }
private List<RexNode> getPartitionKeys(PartitionSpec ps, RexNodeConverter converter, RowResolver inputRR) throws SemanticException { List<RexNode> pKeys = new ArrayList<RexNode>(); if (ps != null) { List<PartitionExpression> pExprs = ps.getExpressions(); for (PartitionExpression pExpr : pExprs) { TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR); tcCtx.setAllowStatefulFunctions(true); ExprNodeDesc exp = genExprNodeDesc(pExpr.getExpression(), inputRR, tcCtx); pKeys.add(converter.convert(exp)); } } return pKeys; }
public ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input, RowResolver outerRR, Map<ASTNode, RelNode> subqueryToRelNode, boolean useCaching) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, false); tcCtx.setOuterRR(outerRR); tcCtx.setSubqueryToRelNode(subqueryToRelNode); return genExprNodeDesc(expr, input, tcCtx); }
public ExprNodeDesc genExprNodeDesc(ASTNode expr, RowResolver input, RowResolver outerRR, Map<ASTNode, RelNode> subqueryToRelNode, boolean useCaching) throws SemanticException { TypeCheckCtx tcCtx = new TypeCheckCtx(input, useCaching, false); tcCtx.setOuterRR(outerRR); tcCtx.setSubqueryToRelNode(subqueryToRelNode); return genExprNodeDesc(expr, input, tcCtx); }
private List<RexFieldCollation> getOrderKeys(OrderSpec os, RexNodeConverter converter, RowResolver inputRR) throws SemanticException { List<RexFieldCollation> oKeys = new ArrayList<RexFieldCollation>(); if (os != null) { List<OrderExpression> oExprs = os.getExpressions(); for (OrderExpression oExpr : oExprs) { TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR); tcCtx.setAllowStatefulFunctions(true); ExprNodeDesc exp = genExprNodeDesc(oExpr.getExpression(), inputRR, tcCtx); RexNode ordExp = converter.convert(exp); Set<SqlKind> flags = new HashSet<SqlKind>(); if (oExpr.getOrder() == org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order.DESC) { flags.add(SqlKind.DESCENDING); } if (oExpr.getNullOrder() == org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.NullOrder.NULLS_FIRST) { flags.add(SqlKind.NULLS_FIRST); } else if (oExpr.getNullOrder() == org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.NullOrder.NULLS_LAST) { flags.add(SqlKind.NULLS_LAST); } else { throw new SemanticException( "Unexpected null ordering option: " + oExpr.getNullOrder()); } oKeys.add(new RexFieldCollation(ordExp, flags)); } } return oKeys; }
private static boolean getPartExprNodeDesc(ASTNode astNode, HiveConf conf, Map<ASTNode, ExprNodeDesc> astExprNodeMap) throws SemanticException { if (astNode == null) { return true; } else if ((astNode.getChildren() == null) || (astNode.getChildren().size() == 0)) { return astNode.getType() != HiveParser.TOK_PARTVAL; } TypeCheckCtx typeCheckCtx = new TypeCheckCtx(null); String defaultPartitionName = HiveConf.getVar(conf, HiveConf.ConfVars.DEFAULTPARTITIONNAME); boolean result = true; for (Node childNode : astNode.getChildren()) { ASTNode childASTNode = (ASTNode)childNode; if (childASTNode.getType() != HiveParser.TOK_PARTVAL) { result = getPartExprNodeDesc(childASTNode, conf, astExprNodeMap) && result; } else { boolean isDynamicPart = childASTNode.getChildren().size() <= 1; result = !isDynamicPart && result; if (!isDynamicPart) { ASTNode partVal = (ASTNode)childASTNode.getChildren().get(1); if (!defaultPartitionName.equalsIgnoreCase(unescapeSQLString(partVal.getText()))) { astExprNodeMap.put((ASTNode)childASTNode.getChildren().get(0), TypeCheckProcFactory.genExprNode(partVal, typeCheckCtx).get(partVal)); } } } } return result; }
private List<RexFieldCollation> getOrderKeys(OrderSpec os, RexNodeConverter converter, RowResolver inputRR) throws SemanticException { List<RexFieldCollation> oKeys = new ArrayList<RexFieldCollation>(); if (os != null) { List<OrderExpression> oExprs = os.getExpressions(); for (OrderExpression oExpr : oExprs) { TypeCheckCtx tcCtx = new TypeCheckCtx(inputRR); tcCtx.setAllowStatefulFunctions(true); ExprNodeDesc exp = genExprNodeDesc(oExpr.getExpression(), inputRR, tcCtx); RexNode ordExp = converter.convert(exp); Set<SqlKind> flags = new HashSet<SqlKind>(); if (oExpr.getOrder() == org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.Order.DESC) { flags.add(SqlKind.DESCENDING); } if (oExpr.getNullOrder() == org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.NullOrder.NULLS_FIRST) { flags.add(SqlKind.NULLS_FIRST); } else if (oExpr.getNullOrder() == org.apache.hadoop.hive.ql.parse.PTFInvocationSpec.NullOrder.NULLS_LAST) { flags.add(SqlKind.NULLS_LAST); } else { throw new SemanticException( "Unexpected null ordering option: " + oExpr.getNullOrder()); } oKeys.add(new RexFieldCollation(ordExp, flags)); } } return oKeys; }
private static boolean getPartExprNodeDesc(ASTNode astNode, HiveConf conf, Map<ASTNode, ExprNodeDesc> astExprNodeMap) throws SemanticException { if (astNode == null) { return true; } else if ((astNode.getChildren() == null) || (astNode.getChildren().size() == 0)) { return astNode.getType() != HiveParser.TOK_PARTVAL; } TypeCheckCtx typeCheckCtx = new TypeCheckCtx(null); String defaultPartitionName = HiveConf.getVar(conf, HiveConf.ConfVars.DEFAULTPARTITIONNAME); boolean result = true; for (Node childNode : astNode.getChildren()) { ASTNode childASTNode = (ASTNode)childNode; if (childASTNode.getType() != HiveParser.TOK_PARTVAL) { result = getPartExprNodeDesc(childASTNode, conf, astExprNodeMap) && result; } else { boolean isDynamicPart = childASTNode.getChildren().size() <= 1; result = !isDynamicPart && result; if (!isDynamicPart) { ASTNode partVal = (ASTNode)childASTNode.getChildren().get(1); if (!defaultPartitionName.equalsIgnoreCase(unescapeSQLString(partVal.getText()))) { astExprNodeMap.put((ASTNode)childASTNode.getChildren().get(0), TypeCheckProcFactory.genExprNode(partVal, typeCheckCtx).get(partVal)); } } } } return result; }
protected ColumnInfo resolveDot(ASTNode node) { try { TypeCheckCtx tcCtx = new TypeCheckCtx(parentQueryRR); String str = BaseSemanticAnalyzer.unescapeIdentifier(node.getChild(1).getText()); ExprNodeDesc idDesc = new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, str.toLowerCase()); Object desc = defaultExprProcessor.process(node, stack, tcCtx, (Object) null, idDesc); if (desc != null && desc instanceof ExprNodeColumnDesc) { ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc) desc; String[] qualName = parentQueryRR.reverseLookup(colDesc.getColumn()); return parentQueryRR.get(qualName[0], qualName[1]); } } catch(SemanticException se) { } return null; }
protected ColumnInfo resolveDot(ASTNode node) { try { TypeCheckCtx tcCtx = new TypeCheckCtx(parentQueryRR); String str = BaseSemanticAnalyzer.unescapeIdentifier(node.getChild(1).getText()); ExprNodeDesc idDesc = new ExprNodeConstantDesc(TypeInfoFactory.stringTypeInfo, str.toLowerCase()); Object desc = defaultExprProcessor.process(node, stack, tcCtx, (Object) null, idDesc); if (desc != null && desc instanceof ExprNodeColumnDesc) { ExprNodeColumnDesc colDesc = (ExprNodeColumnDesc) desc; String[] qualName = parentQueryRR.reverseLookup(colDesc.getColumn()); return parentQueryRR.get(qualName[0], qualName[1]); } } catch(SemanticException se) { } return null; }
private ShapeDetails setupShape(StructObjectInspector OI, List<String> columnNames, RowResolver rr) throws SemanticException { Map<String, String> serdePropsMap = new LinkedHashMap<String, String>(); AbstractSerDe serde = null; ShapeDetails shp = new ShapeDetails(); try { serde = PTFTranslator.createLazyBinarySerDe(hCfg, OI, serdePropsMap); StructObjectInspector outOI = PTFPartition.setupPartitionOutputOI(serde, OI); shp.setOI(outOI); } catch (SerDeException se) { throw new SemanticException(se); } shp.setRr(rr); shp.setSerde(serde); shp.setSerdeClassName(serde.getClass().getName()); shp.setSerdeProps(serdePropsMap); shp.setColumnNames(columnNames); TypeCheckCtx tCtx = new TypeCheckCtx(rr); tCtx.setUnparseTranslator(unparseT); shp.setTypeCheckCtx(tCtx); return shp; }
private ShapeDetails setupShapeForNoop(ShapeDetails inpShape, StructObjectInspector OI, List<String> columnNames, RowResolver rr) throws SemanticException { ShapeDetails shp = new ShapeDetails(); shp.setRr(rr); shp.setOI(inpShape.getOI()); shp.setSerde(inpShape.getSerde()); shp.setSerdeClassName(inpShape.getSerde().getClass().getName()); shp.setSerdeProps(inpShape.getSerdeProps()); shp.setColumnNames(columnNames); TypeCheckCtx tCtx = new TypeCheckCtx(rr); tCtx.setUnparseTranslator(unparseT); shp.setTypeCheckCtx(tCtx); return shp; }
private ShapeDetails setupShape(StructObjectInspector OI, List<String> columnNames, RowResolver rr) throws SemanticException { Map<String, String> serdePropsMap = new LinkedHashMap<String, String>(); AbstractSerDe serde = null; ShapeDetails shp = new ShapeDetails(); try { serde = PTFTranslator.createLazyBinarySerDe(hCfg, OI, serdePropsMap); StructObjectInspector outOI = PTFPartition.setupPartitionOutputOI(serde, OI); shp.setOI(outOI); } catch (SerDeException se) { throw new SemanticException(se); } shp.setRr(rr); shp.setSerde(serde); shp.setSerdeClassName(serde.getClass().getName()); shp.setSerdeProps(serdePropsMap); shp.setColumnNames(columnNames); TypeCheckCtx tCtx = new TypeCheckCtx(rr); tCtx.setUnparseTranslator(unparseT); shp.setTypeCheckCtx(tCtx); return shp; }
private ShapeDetails setupShapeForNoop(ShapeDetails inpShape, StructObjectInspector OI, List<String> columnNames, RowResolver rr) throws SemanticException { ShapeDetails shp = new ShapeDetails(); shp.setRr(rr); shp.setOI(inpShape.getOI()); shp.setSerde(inpShape.getSerde()); shp.setSerdeClassName(inpShape.getSerde().getClass().getName()); shp.setSerdeProps(inpShape.getSerdeProps()); shp.setColumnNames(columnNames); TypeCheckCtx tCtx = new TypeCheckCtx(rr); tCtx.setUnparseTranslator(unparseT); shp.setTypeCheckCtx(tCtx); return shp; }