Search in sources :

Example 1 with WriterProjection

use of io.crate.planner.projection.WriterProjection in project crate by crate.

the class CopyToPlannerTest method testCopyToWithPartitionedGeneratedColumn.

@Test
public void testCopyToWithPartitionedGeneratedColumn() throws Exception {
    // test that generated partition column is NOT exported
    Merge plan = e.plan("copy parted_generated to directory '/tmp'");
    Collect innerPlan = (Collect) plan.subPlan();
    RoutedCollectPhase node = ((RoutedCollectPhase) innerPlan.collectPhase());
    WriterProjection projection = (WriterProjection) node.projections().get(0);
    assertThat(projection.overwrites().size(), is(0));
}
Also used : WriterProjection(io.crate.planner.projection.WriterProjection) Collect(io.crate.planner.node.dql.Collect) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with WriterProjection

use of io.crate.planner.projection.WriterProjection in project crate by crate.

the class CopyStatementPlanner method planCopyTo.

public Plan planCopyTo(CopyToAnalyzedStatement statement, Planner.Context context) {
    WriterProjection.OutputFormat outputFormat = statement.outputFormat();
    if (outputFormat == null) {
        outputFormat = statement.columnsDefined() ? WriterProjection.OutputFormat.JSON_ARRAY : WriterProjection.OutputFormat.JSON_OBJECT;
    }
    WriterProjection projection = ProjectionBuilder.writerProjection(statement.subQueryRelation().querySpec().outputs(), statement.uri(), statement.compressionType(), statement.overwrites(), statement.outputNames(), outputFormat);
    Plan plan = context.planSubRelation(statement.subQueryRelation(), new ConsumerContext(context));
    if (plan == null) {
        return null;
    }
    plan.addProjection(projection, null, null, 1, null);
    return Merge.ensureOnHandler(plan, context, Collections.singletonList(MergeCountProjection.INSTANCE));
}
Also used : WriterProjection(io.crate.planner.projection.WriterProjection) SourceIndexWriterProjection(io.crate.planner.projection.SourceIndexWriterProjection) ConsumerContext(io.crate.planner.consumer.ConsumerContext) Plan(io.crate.planner.Plan)

Aggregations

WriterProjection (io.crate.planner.projection.WriterProjection)2 Plan (io.crate.planner.Plan)1 ConsumerContext (io.crate.planner.consumer.ConsumerContext)1 Collect (io.crate.planner.node.dql.Collect)1 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)1 SourceIndexWriterProjection (io.crate.planner.projection.SourceIndexWriterProjection)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 Test (org.junit.Test)1