Search in sources :

Example 1 with HashJoinPOP

use of org.apache.drill.exec.physical.config.HashJoinPOP in project drill by apache.

the class HashJoinPrel method getHashJoinPop.

private PhysicalOperator getHashJoinPop(PhysicalPlanCreator creator, RelNode left, RelNode right, List<Integer> leftKeys, List<Integer> rightKeys) throws IOException {
    final List<String> fields = getRowType().getFieldNames();
    assert isUnique(fields);
    final List<String> leftFields = left.getRowType().getFieldNames();
    final List<String> rightFields = right.getRowType().getFieldNames();
    PhysicalOperator leftPop = ((Prel) left).getPhysicalOperator(creator);
    PhysicalOperator rightPop = ((Prel) right).getPhysicalOperator(creator);
    JoinRelType jtype = this.getJoinType();
    List<JoinCondition> conditions = Lists.newArrayList();
    buildJoinConditions(conditions, leftFields, rightFields, leftKeys, rightKeys);
    HashJoinPOP hjoin = new HashJoinPOP(leftPop, rightPop, conditions, jtype);
    return creator.addMetadata(this, hjoin);
}
Also used : JoinRelType(org.apache.calcite.rel.core.JoinRelType) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) HashJoinPOP(org.apache.drill.exec.physical.config.HashJoinPOP) JoinCondition(org.apache.drill.common.logical.data.JoinCondition)

Example 2 with HashJoinPOP

use of org.apache.drill.exec.physical.config.HashJoinPOP in project drill by axbaretto.

the class TestNullInputMiniPlan method testHashJoinRightEmpty.

@Test
public void testHashJoinRightEmpty() throws Exception {
    List<String> leftJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
    RecordBatch leftScan = new JsonScanBuilder().jsonBatches(leftJsonBatches).columnsToRead("a", "b").build();
    RecordBatch right = createScanBatchFromJson(SINGLE_EMPTY_JSON);
    RecordBatch joinBatch = new PopBuilder().physicalOperator(new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "a2")), JoinRelType.INNER)).addInput(leftScan).addInput(right).build();
    BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
    new MiniPlanTestBuilder().root(joinBatch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) HashJoinPOP(org.apache.drill.exec.physical.config.HashJoinPOP) Test(org.junit.Test)

Example 3 with HashJoinPOP

use of org.apache.drill.exec.physical.config.HashJoinPOP in project drill by axbaretto.

the class TestNullInputMiniPlan method testRightHashJoinEmptyBoth.

@Test
public void testRightHashJoinEmptyBoth() throws Exception {
    final PhysicalOperator join = new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "b")), JoinRelType.RIGHT);
    testTwoInputNullBatchHandling(join);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) HashJoinPOP(org.apache.drill.exec.physical.config.HashJoinPOP) Test(org.junit.Test)

Example 4 with HashJoinPOP

use of org.apache.drill.exec.physical.config.HashJoinPOP in project drill by axbaretto.

the class TestNullInputMiniPlan method testHashJoinEmptyBoth.

@Test
public void testHashJoinEmptyBoth() throws Exception {
    final PhysicalOperator join = new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "b")), JoinRelType.INNER);
    testTwoInputNullBatchHandling(join);
}
Also used : PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) HashJoinPOP(org.apache.drill.exec.physical.config.HashJoinPOP) Test(org.junit.Test)

Example 5 with HashJoinPOP

use of org.apache.drill.exec.physical.config.HashJoinPOP in project drill by axbaretto.

the class TestNullInputMiniPlan method testLeftHashJoinLeftEmpty.

@Test
public void testLeftHashJoinLeftEmpty() throws Exception {
    RecordBatch left = createScanBatchFromJson(SINGLE_EMPTY_JSON);
    List<String> rightJsonBatches = Lists.newArrayList("[{\"a\": 50, \"b\" : 10 }]");
    RecordBatch rightScan = new JsonScanBuilder().jsonBatches(rightJsonBatches).columnsToRead("a", "b").build();
    RecordBatch joinBatch = new PopBuilder().physicalOperator(new HashJoinPOP(null, null, Lists.newArrayList(joinCond("a", "EQUALS", "a2")), JoinRelType.LEFT)).addInput(left).addInput(rightScan).build();
    BatchSchema expectedSchema = new SchemaBuilder().addNullable("a", TypeProtos.MinorType.BIGINT).addNullable("b", TypeProtos.MinorType.BIGINT).withSVMode(BatchSchema.SelectionVectorMode.NONE).build();
    new MiniPlanTestBuilder().root(joinBatch).expectSchema(expectedSchema).expectZeroRow(true).go();
}
Also used : BatchSchema(org.apache.drill.exec.record.BatchSchema) RecordBatch(org.apache.drill.exec.record.RecordBatch) SchemaBuilder(org.apache.drill.test.rowSet.schema.SchemaBuilder) HashJoinPOP(org.apache.drill.exec.physical.config.HashJoinPOP) Test(org.junit.Test)

Aggregations

HashJoinPOP (org.apache.drill.exec.physical.config.HashJoinPOP)34 Test (org.junit.Test)30 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)11 RecordBatch (org.apache.drill.exec.record.RecordBatch)10 BatchSchema (org.apache.drill.exec.record.BatchSchema)8 OperatorTest (org.apache.drill.categories.OperatorTest)6 LegacyOperatorTestBuilder (org.apache.drill.test.LegacyOperatorTestBuilder)6 SlowTest (org.apache.drill.categories.SlowTest)5 JoinCondition (org.apache.drill.common.logical.data.JoinCondition)5 BatchSchemaBuilder (org.apache.drill.exec.record.BatchSchemaBuilder)4 SchemaBuilder (org.apache.drill.exec.record.metadata.SchemaBuilder)4 SchemaBuilder (org.apache.drill.test.rowSet.schema.SchemaBuilder)4 ArrayList (java.util.ArrayList)3 JoinRelType (org.apache.calcite.rel.core.JoinRelType)3 RuntimeFilterDef (org.apache.drill.exec.work.filter.RuntimeFilterDef)3 MockRecordBatch (org.apache.drill.exec.physical.impl.MockRecordBatch)2 BloomFilterDef (org.apache.drill.exec.work.filter.BloomFilterDef)2 RowSet (org.apache.drill.exec.physical.rowSet.RowSet)1 VectorContainer (org.apache.drill.exec.record.VectorContainer)1