Search in sources :

Example 1 with Project

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

the class ProjectAllowDupPrel method getPhysicalOperator.

@Override
public PhysicalOperator getPhysicalOperator(PhysicalPlanCreator creator) throws IOException {
    Prel child = (Prel) this.getInput();
    PhysicalOperator childPOP = child.getPhysicalOperator(creator);
    Project p = new Project(this.getProjectExpressions(new DrillParseContext(PrelUtil.getSettings(getCluster()))), childPOP);
    return creator.addMetadata(this, p);
}
Also used : Project(org.apache.drill.exec.physical.config.Project) PhysicalOperator(org.apache.drill.exec.physical.base.PhysicalOperator) DrillParseContext(org.apache.drill.exec.planner.logical.DrillParseContext)

Example 2 with Project

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

the class BasicPhysicalOpUnitTest method testSimpleProject.

@Test
public void testSimpleProject() {
    Project projectConf = new Project(parseExprs("x+5", "x"), null);
    List<String> jsonBatches = Lists.newArrayList("[{\"x\": 5 },{\"x\": 10 }]", "[{\"x\": 20 },{\"x\": 30 },{\"x\": 40 }]");
    opTestBuilder().physicalOperator(projectConf).inputDataStreamJson(jsonBatches).baselineColumns("x").baselineValues(10l).baselineValues(15l).baselineValues(25l).baselineValues(35l).baselineValues(45l).go();
}
Also used : Project(org.apache.drill.exec.physical.config.Project) Test(org.junit.Test)

Example 3 with Project

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

the class BasicPhysicalOpUnitTest method testProjectComplexOutput.

@Test
public void testProjectComplexOutput() {
    Project projectConf = new Project(parseExprs("convert_from(json_col, 'JSON')", "complex_col"), null);
    List<String> jsonBatches = Lists.newArrayList("[{\"json_col\": \"{ \\\"a\\\" : 1 }\"}]", "[{\"json_col\": \"{ \\\"a\\\" : 5 }\"}]");
    opTestBuilder().physicalOperator(projectConf).inputDataStreamJson(jsonBatches).baselineColumns("complex_col").baselineValues(mapOf("a", 1l)).baselineValues(mapOf("a", 5l)).go();
}
Also used : Project(org.apache.drill.exec.physical.config.Project) Test(org.junit.Test)

Aggregations

Project (org.apache.drill.exec.physical.config.Project)3 Test (org.junit.Test)2 PhysicalOperator (org.apache.drill.exec.physical.base.PhysicalOperator)1 DrillParseContext (org.apache.drill.exec.planner.logical.DrillParseContext)1