@Test public final void testIsJoinQual() { FieldEval f1 = new FieldEval("part.p_partkey", CatalogUtil.newSimpleDataType(Type.INT4)); FieldEval f2 = new FieldEval("partsupp.ps_partkey", CatalogUtil.newSimpleDataType(Type.INT4)); BinaryEval [] joinQuals = new BinaryEval[5]; int idx = 0; joinQuals[idx++] = new BinaryEval(EvalType.EQUAL, f1, f2); joinQuals[idx++] = new BinaryEval(EvalType.LEQ, f1, f2); joinQuals[idx++] = new BinaryEval(EvalType.LTH, f1, f2); joinQuals[idx++] = new BinaryEval(EvalType.GEQ, f1, f2); joinQuals[idx] = new BinaryEval(EvalType.GTH, f1, f2); for (int i = 0; i < idx; i++) { assertTrue(PlannerUtil.isJoinQual(joinQuals[idx])); } BinaryEval [] wrongJoinQuals = new BinaryEval[5]; idx = 0; wrongJoinQuals[idx++] = new BinaryEval(EvalType.OR, f1, f2); wrongJoinQuals[idx++] = new BinaryEval(EvalType.PLUS, f1, f2); wrongJoinQuals[idx++] = new BinaryEval(EvalType.LIKE, f1, f2); ConstEval f3 = new ConstEval(DatumFactory.createInt4(1)); wrongJoinQuals[idx] = new BinaryEval(EvalType.EQUAL, f1, f3); for (int i = 0; i < idx; i++) { assertFalse(PlannerUtil.isJoinQual(wrongJoinQuals[idx])); } }
public static boolean isJoinQual(EvalNode qual) { if (AlgebraicUtil.isComparisonOperator(qual)) { List<Column> left = EvalTreeUtil.findAllColumnRefs(qual.getLeftExpr()); List<Column> right = EvalTreeUtil.findAllColumnRefs(qual.getRightExpr()); if (left.size() == 1 && right.size() == 1 && !left.get(0).getQualifier().equals(right.get(0).getQualifier())) return true; } return false; }
PlannerUtil { public static boolean isJoinQual(EvalNode qual) { if (AlgebraicUtil.isComparisonOperator(qual)) { List<Column> left = EvalTreeUtil.findAllColumnRefs(qual.getLeftExpr()); List<Column> right = EvalTreeUtil.findAllColumnRefs(qual.getRightExpr()); if (left.size() == 1 && right.size() == 1 && !left.get(0).getQualifier().equals(right.get(0).getQualifier())) return true; } return false; } }
PlannerUtil { public static boolean isJoinQual(EvalNode qual) { if (AlgebraicUtil.isComparisonOperator(qual)) { List<Column> left = EvalTreeUtil.findAllColumnRefs(qual.getLeftExpr()); List<Column> right = EvalTreeUtil.findAllColumnRefs(qual.getRightExpr()); if (left.size() == 1 && right.size() == 1 && !left.get(0).getQualifier().equals(right.get(0).getQualifier())) return true; } return false; }  }
PlannerUtil { public static boolean isJoinQual(EvalNode qual) { if (AlgebraicUtil.isComparisonOperator(qual)) { List<Column> left = EvalTreeUtil.findAllColumnRefs(qual.getLeftExpr()); List<Column> right = EvalTreeUtil.findAllColumnRefs(qual.getRightExpr()); if (left.size() == 1 && right.size() == 1 && !left.get(0).getQualifier().equals(right.get(0).getQualifier())) return true; } return false; }  static boolean checkIfDDLPlan(LogicalNode node); static String [] getRelationLineage(LogicalNode from); static Collection<String> getRelationLineageWithinQueryBlock(LogicalPlan plan, LogicalNode from); static LogicalNode deleteNode(LogicalNode parent, LogicalNode tobeRemoved); static void replaceNode(LogicalPlan plan, LogicalNode startNode, LogicalNode oldNode, LogicalNode newNode); static void replaceNode(LogicalNode plan, LogicalNode newNode, NodeType type); static T findTopNode(LogicalNode node, NodeType type); static T findMostBottomNode(LogicalNode node, NodeType type); static LogicalNode [] findAllNodes(LogicalNode node, NodeType...type); static T findTopParentNode(LogicalNode node, NodeType type); static void schemaToTargets(Schema schema, Target [] targets); static Target[] schemaToTargets(Schema schema); static Target[] schemaToTargetsWithGeneratedFields(Schema schema); static SortSpec[] schemaToSortSpecs(Schema schema); static SortSpec[] schemaToSortSpecs(Column [] columns); static SortSpec [] columnsToSortSpec(Collection<Column> columns); static Schema sortSpecsToSchema(SortSpec[] sortSpecs); static boolean isJoinQual(EvalNode qual); static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner); static TupleComparator[] getComparatorsFromJoinQual(EvalNode joinQual, Schema leftSchema, Schema rightSchema); static Column [][] joinJoinKeyForEachTable(EvalNode joinQual, Schema leftSchema, Schema rightSchema); static List<Column []> getJoinKeyPairs(EvalNode joinQual, Schema leftSchema, Schema rightSchema); static Schema targetToSchema(Collection<Target> targets); static Schema targetToSchema(Target[] targets); static Target [] stripTarget(Target [] sourceTargets); static T clone(LogicalPlan plan, LogicalNode node); static boolean isCommutativeJoin(JoinType joinType); static boolean existsAggregationFunction(Expr expr); static boolean existsDistinctAggregationFunction(Expr expr); static Collection<String> toQualifiedFieldNames(Collection<String> fieldNames, String qualifier); static SortSpec [] convertSortSpecs(Collection<CatalogProtos.SortSpecProto> sortSpecProtos); static String buildExplainString(LogicalNode node); }
PlannerUtil { public static boolean isJoinQual(EvalNode qual) { if (AlgebraicUtil.isComparisonOperator(qual)) { List<Column> left = EvalTreeUtil.findAllColumnRefs(qual.getLeftExpr()); List<Column> right = EvalTreeUtil.findAllColumnRefs(qual.getRightExpr()); if (left.size() == 1 && right.size() == 1 && !left.get(0).getQualifier().equals(right.get(0).getQualifier())) return true; } return false; }  static boolean checkIfDDLPlan(LogicalNode node); static String [] getRelationLineage(LogicalNode from); static Collection<String> getRelationLineageWithinQueryBlock(LogicalPlan plan, LogicalNode from); static LogicalNode deleteNode(LogicalNode parent, LogicalNode tobeRemoved); static void replaceNode(LogicalPlan plan, LogicalNode startNode, LogicalNode oldNode, LogicalNode newNode); static void replaceNode(LogicalNode plan, LogicalNode newNode, NodeType type); static T findTopNode(LogicalNode node, NodeType type); static T findMostBottomNode(LogicalNode node, NodeType type); static LogicalNode [] findAllNodes(LogicalNode node, NodeType...type); static T findTopParentNode(LogicalNode node, NodeType type); static void schemaToTargets(Schema schema, Target [] targets); static Target[] schemaToTargets(Schema schema); static Target[] schemaToTargetsWithGeneratedFields(Schema schema); static SortSpec[] schemaToSortSpecs(Schema schema); static SortSpec[] schemaToSortSpecs(Column [] columns); static SortSpec [] columnsToSortSpec(Collection<Column> columns); static Schema sortSpecsToSchema(SortSpec[] sortSpecs); static boolean isJoinQual(EvalNode qual); static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner); static TupleComparator[] getComparatorsFromJoinQual(EvalNode joinQual, Schema leftSchema, Schema rightSchema); static Column [][] joinJoinKeyForEachTable(EvalNode joinQual, Schema leftSchema, Schema rightSchema); static List<Column []> getJoinKeyPairs(EvalNode joinQual, Schema leftSchema, Schema rightSchema); static Schema targetToSchema(Collection<Target> targets); static Schema targetToSchema(Target[] targets); static Target [] stripTarget(Target [] sourceTargets); static T clone(LogicalPlan plan, LogicalNode node); static boolean isCommutativeJoin(JoinType joinType); static boolean existsAggregationFunction(Expr expr); static boolean existsDistinctAggregationFunction(Expr expr); static Collection<String> toQualifiedFieldNames(Collection<String> fieldNames, String qualifier); static SortSpec [] convertSortSpecs(Collection<CatalogProtos.SortSpecProto> sortSpecProtos); static String buildExplainString(LogicalNode node);  }