private void addChildren(ExprNodeGenericFuncDesc node) { for(ExprNodeDesc child: node.getChildren()) { parse(child); } }
public static String arg0Type(ExprNodeGenericFuncDesc expr) { return expr.getChildren().get(0).getTypeString(); }
private long evaluateBetweenExpr(Statistics stats, ExprNodeDesc pred, long currNumRows, AnnotateStatsProcCtx aspCtx, List<String> neededCols, Operator<?> op) throws SemanticException { final ExprNodeGenericFuncDesc fd = (ExprNodeGenericFuncDesc) pred; final boolean invert = Boolean.TRUE.equals( ((ExprNodeConstantDesc) fd.getChildren().get(0)).getValue()); // boolean invert (not) final ExprNodeDesc comparisonExpression = fd.getChildren().get(1); // expression final ExprNodeDesc leftExpression = fd.getChildren().get(2); // left expression final ExprNodeDesc rightExpression = fd.getChildren().get(3); // right expression // Short circuit and return the current number of rows if this is a // synthetic predicate with dynamic values if (leftExpression instanceof ExprNodeDynamicValueDesc) { return currNumRows; } ExprNodeDesc newExpression = rewriteBetweenToIn(comparisonExpression, leftExpression, rightExpression, invert); return evaluateExpression(stats, newExpression, aspCtx, neededCols, op, currNumRows); }
/** * Return the boxed literal at the given position * @param expr the parent node * @param type the type of the expression * @param position the child position to check * @return the boxed literal if found otherwise null */ private static Object getLiteral(Configuration conf, ExprNodeGenericFuncDesc expr, BoxType boxType, int position) { List<ExprNodeDesc> children = expr.getChildren(); ExprNodeDesc child = children.get(position); return getLiteral(conf, child, boxType); }
private void addChildren(ExprNodeGenericFuncDesc node) { for(ExprNodeDesc child: node.getChildren()) { parse(child); } }
public static String arg0Type(ExprNodeGenericFuncDesc expr) { String type = expr.getChildren().get(0).getTypeString(); return type; }
public static ExprNodeDesc foldExpr(ExprNodeGenericFuncDesc funcDesc) { GenericUDF udf = funcDesc.getGenericUDF(); if (!isConstantFoldableUdf(udf, funcDesc.getChildren())) { return funcDesc; } return evaluateFunction(funcDesc.getGenericUDF(),funcDesc.getChildren(), funcDesc.getChildren()); }
public static ExprNodeDesc foldExpr(ExprNodeGenericFuncDesc funcDesc) { GenericUDF udf = funcDesc.getGenericUDF(); if (!isDeterministicUdf(udf, funcDesc.getChildren())) { return funcDesc; } return evaluateFunction(funcDesc.getGenericUDF(),funcDesc.getChildren(), funcDesc.getChildren()); }
@Nullable private Map<TopicPartition, KafkaInputSplit> pushOrOp(ExprNodeGenericFuncDesc expr) { final Map<TopicPartition, KafkaInputSplit> currentScan = new HashMap<>(); for (ExprNodeDesc child : expr.getChildren()) { Map<TopicPartition, KafkaInputSplit> scan = parseAndOptimize(child); if (scan == null) { // if any of the children is unknown bailout return null; } scan.forEach((tp, input) -> { KafkaInputSplit existingSplit = currentScan.get(tp); currentScan.put(tp, KafkaInputSplit.unionRange(input, existingSplit == null ? input : existingSplit)); }); } return currentScan; }
static private void extractColumns(Set<String> colNamesExprs, ExprNodeDesc exprNode) throws SemanticException { if (exprNode instanceof ExprNodeColumnDesc) { colNamesExprs.add(((ExprNodeColumnDesc) exprNode).getColumn()); return; } if (exprNode instanceof ExprNodeGenericFuncDesc) { ExprNodeGenericFuncDesc funcDesc = (ExprNodeGenericFuncDesc) exprNode; for (ExprNodeDesc childExpr : funcDesc.getChildren()) { extractColumns(colNamesExprs, childExpr); } } }
static private void extractColumns(Set<String> colNamesExprs, ExprNodeDesc exprNode) throws SemanticException { if (exprNode instanceof ExprNodeColumnDesc) { colNamesExprs.add(((ExprNodeColumnDesc) exprNode).getColumn()); return; } if (exprNode instanceof ExprNodeGenericFuncDesc) { ExprNodeGenericFuncDesc funcDesc = (ExprNodeGenericFuncDesc) exprNode; for (ExprNodeDesc childExpr : funcDesc.getChildren()) { extractColumns(colNamesExprs, childExpr); } } }
private boolean containsLeadLag(ExprNodeDesc exprNodeDesc) { if (exprNodeDesc instanceof ExprNodeGenericFuncDesc) { ExprNodeGenericFuncDesc genericFuncDesc = (ExprNodeGenericFuncDesc) exprNodeDesc; GenericUDF genFuncClass = genericFuncDesc.getGenericUDF(); if (genFuncClass instanceof GenericUDFLag || genFuncClass instanceof GenericUDFLead) { return true; } return containsLeadLag(genericFuncDesc.getChildren()); } else { // ExprNodeColumnDesc, ExprNodeConstantDesc, ExprNodeDynamicValueDesc, etc do not have // LEAD/LAG inside. return false; } }
private static Boolean evaluateNotNode(final ExprNodeDesc node, final List<String> skewedCols, final List<String> cell, final List<List<String>> uniqSkewedValues) throws SemanticException { List<ExprNodeDesc> children = ((ExprNodeGenericFuncDesc) node).getChildren(); if ((children == null) || (children.size() != 1)) { throw new SemanticException("GenericUDFOPNot should have 1 ExprNodeDesc. Node name : " + node.getName()); } ExprNodeDesc child = children.get(0); return notBoolOperand(recursiveExpr(child, skewedCols, cell, uniqSkewedValues)); }
private static Boolean evaluateOrNode(final ExprNodeDesc node, final List<String> skewedCols, final List<String> cell, final List<List<String>> uniqSkewedValues) throws SemanticException { List<ExprNodeDesc> children = ((ExprNodeGenericFuncDesc) node).getChildren(); if ((children == null) || (children.size() != 2)) { throw new SemanticException("GenericUDFOPOr should have 2 ExprNodeDesc. Node name : " + node.getName()); } ExprNodeDesc left = children.get(0); ExprNodeDesc right = children.get(1); return orBoolOperand(recursiveExpr(left, skewedCols, cell, uniqSkewedValues), recursiveExpr(right, skewedCols, cell, uniqSkewedValues)); }
private static Boolean evaluateAndNode(final ExprNodeDesc node, final List<String> skewedCols, final List<String> cell, final List<List<String>> uniqSkewedValues) throws SemanticException { List<ExprNodeDesc> children = ((ExprNodeGenericFuncDesc) node).getChildren(); if ((children == null) || (children.size() != 2)) { throw new SemanticException("GenericUDFOPAnd should have 2 ExprNodeDesc. Node name : " + node.getName()); } ExprNodeDesc left = children.get(0); ExprNodeDesc right = children.get(1); return andBoolOperand(recursiveExpr(left, skewedCols, cell, uniqSkewedValues), recursiveExpr(right, skewedCols, cell, uniqSkewedValues)); }
private static Boolean evaluateNotNode(final ExprNodeDesc node, final List<String> skewedCols, final List<String> cell, final List<List<String>> uniqSkewedValues) throws SemanticException { List<ExprNodeDesc> children = ((ExprNodeGenericFuncDesc) node).getChildren(); if ((children == null) || (children.size() != 1)) { throw new SemanticException("GenericUDFOPNot should have 1 ExprNodeDesc. Node name : " + node.getName()); } ExprNodeDesc child = children.get(0); return notBoolOperand(recursiveExpr(child, skewedCols, cell, uniqSkewedValues)); }
private static Boolean evaluateOrNode(final ExprNodeDesc node, final List<String> skewedCols, final List<String> cell, final List<List<String>> uniqSkewedValues) throws SemanticException { List<ExprNodeDesc> children = ((ExprNodeGenericFuncDesc) node).getChildren(); if ((children == null) || (children.size() != 2)) { throw new SemanticException("GenericUDFOPOr should have 2 ExprNodeDesc. Node name : " + node.getName()); } ExprNodeDesc left = children.get(0); ExprNodeDesc right = children.get(1); return orBoolOperand(recursiveExpr(left, skewedCols, cell, uniqSkewedValues), recursiveExpr(right, skewedCols, cell, uniqSkewedValues)); }
private static Boolean evaluateAndNode(final ExprNodeDesc node, final List<String> skewedCols, final List<String> cell, final List<List<String>> uniqSkewedValues) throws SemanticException { List<ExprNodeDesc> children = ((ExprNodeGenericFuncDesc) node).getChildren(); if ((children == null) || (children.size() != 2)) { throw new SemanticException("GenericUDFOPAnd should have 2 ExprNodeDesc. Node name : " + node.getName()); } ExprNodeDesc left = children.get(0); ExprNodeDesc right = children.get(1); return andBoolOperand(recursiveExpr(left, skewedCols, cell, uniqSkewedValues), recursiveExpr(right, skewedCols, cell, uniqSkewedValues)); }
private static boolean isWideningCast(ExprNodeGenericFuncDesc engfd) { GenericUDF udf = engfd.getGenericUDF(); if (!FunctionRegistry.isOpCast(udf)) { // It is not a cast return false; } return TypeInfoUtils.implicitConvertible(engfd.getChildren().get(0).getTypeInfo(), engfd.getTypeInfo()); }
private static boolean isWideningCast(ExprNodeGenericFuncDesc engfd) { GenericUDF udf = engfd.getGenericUDF(); if (!FunctionRegistry.isOpCast(udf)) { // It is not a cast return false; } return TypeInfoUtils.implicitConvertible(engfd.getChildren().get(0).getTypeInfo(), engfd.getTypeInfo()); }