@Test public final void testGetSortKeysFromJoinQual() { Schema outerSchema = new Schema(); outerSchema.addColumn("employee.id1", CatalogUtil.newSimpleDataType(Type.INT4)); outerSchema.addColumn("employee.id2", CatalogUtil.newSimpleDataType(Type.INT4)); Schema innerSchema = new Schema(); innerSchema.addColumn("people.fid1", CatalogUtil.newSimpleDataType(Type.INT4)); innerSchema.addColumn("people.fid2", CatalogUtil.newSimpleDataType(Type.INT4)); FieldEval f1 = new FieldEval("employee.id1", CatalogUtil.newSimpleDataType(Type.INT4)); FieldEval f2 = new FieldEval("people.fid1", CatalogUtil.newSimpleDataType(Type.INT4)); FieldEval f3 = new FieldEval("employee.id2", CatalogUtil.newSimpleDataType(Type.INT4)); FieldEval f4 = new FieldEval("people.fid2", CatalogUtil.newSimpleDataType(Type.INT4)); EvalNode joinQual = new BinaryEval(EvalType.EQUAL, f1, f2); SortSpec[][] sortSpecs = PlannerUtil.getSortKeysFromJoinQual(joinQual, outerSchema, innerSchema); assertEquals(2, sortSpecs.length); assertEquals(1, sortSpecs[0].length); assertEquals(1, sortSpecs[1].length); assertEquals(outerSchema.getColumn("id1"), sortSpecs[0][0].getSortKey()); assertEquals(innerSchema.getColumn("fid1"), sortSpecs[1][0].getSortKey()); EvalNode joinQual2 = new BinaryEval(EvalType.EQUAL, f3, f4); EvalNode compositedJoinQual = new BinaryEval(EvalType.AND, joinQual, joinQual2); sortSpecs = PlannerUtil.getSortKeysFromJoinQual(compositedJoinQual, outerSchema, innerSchema); assertEquals(2, sortSpecs.length); assertEquals(2, sortSpecs[0].length); assertEquals(2, sortSpecs[1].length); assertEquals(outerSchema.getColumn("id1"), sortSpecs[0][0].getSortKey()); assertEquals(outerSchema.getColumn("id2"), sortSpecs[0][1].getSortKey()); assertEquals(innerSchema.getColumn("fid1"), sortSpecs[1][0].getSortKey()); assertEquals(innerSchema.getColumn("fid2"), sortSpecs[1][1].getSortKey()); }
public static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner) { List<Column []> joinKeyPairs = getJoinKeyPairs(joinQual, outer, inner); SortSpec[] outerSortSpec = new SortSpec[joinKeyPairs.size()]; SortSpec[] innerSortSpec = new SortSpec[joinKeyPairs.size()]; for (int i = 0; i < joinKeyPairs.size(); i++) { outerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[0]); innerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[1]); } return new SortSpec[][] {outerSortSpec, innerSortSpec}; }
PlannerUtil { public static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner) { List<Column []> joinKeyPairs = getJoinKeyPairs(joinQual, outer, inner); SortSpec[] outerSortSpec = new SortSpec[joinKeyPairs.size()]; SortSpec[] innerSortSpec = new SortSpec[joinKeyPairs.size()]; for (int i = 0; i < joinKeyPairs.size(); i++) { outerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[0]); innerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[1]); } return new SortSpec[][] {outerSortSpec, innerSortSpec}; } }
PlannerUtil { public static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner) { List<Column []> joinKeyPairs = getJoinKeyPairs(joinQual, outer, inner); SortSpec[] outerSortSpec = new SortSpec[joinKeyPairs.size()]; SortSpec[] innerSortSpec = new SortSpec[joinKeyPairs.size()]; for (int i = 0; i < joinKeyPairs.size(); i++) { outerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[0]); innerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[1]); } return new SortSpec[][] {outerSortSpec, innerSortSpec}; }  }
PlannerUtil { public static SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner) { List<Column []> joinKeyPairs = getJoinKeyPairs(joinQual, outer, inner); SortSpec[] outerSortSpec = new SortSpec[joinKeyPairs.size()]; SortSpec[] innerSortSpec = new SortSpec[joinKeyPairs.size()]; for (int i = 0; i < joinKeyPairs.size(); i++) { outerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[0]); innerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[1]); } return new SortSpec[][] {outerSortSpec, innerSortSpec}; }  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 SortSpec[][] getSortKeysFromJoinQual(EvalNode joinQual, Schema outer, Schema inner) { List<Column []> joinKeyPairs = getJoinKeyPairs(joinQual, outer, inner); SortSpec[] outerSortSpec = new SortSpec[joinKeyPairs.size()]; SortSpec[] innerSortSpec = new SortSpec[joinKeyPairs.size()]; for (int i = 0; i < joinKeyPairs.size(); i++) { outerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[0]); innerSortSpec[i] = new SortSpec(joinKeyPairs.get(i)[1]); } return new SortSpec[][] {outerSortSpec, innerSortSpec}; }  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);  }