use of org.apache.flink.table.planner.calcite.FlinkPlannerImpl in project flink by apache.
the class SqlToOperationConverterTest method testSqlInsertWithDynamicTableOptions.
@Test
public void testSqlInsertWithDynamicTableOptions() {
final String sql = "insert into t1 /*+ OPTIONS('k1'='v1', 'k2'='v2') */\n" + "select a, b, c, d from t2";
FlinkPlannerImpl planner = getPlannerBySqlDialect(SqlDialect.DEFAULT);
final CalciteParser parser = getParserBySqlDialect(SqlDialect.DEFAULT);
Operation operation = parse(sql, planner, parser);
assertThat(operation).isInstanceOf(SinkModifyOperation.class);
SinkModifyOperation sinkModifyOperation = (SinkModifyOperation) operation;
Map<String, String> dynamicOptions = sinkModifyOperation.getDynamicOptions();
assertThat(dynamicOptions).isNotNull();
assertThat(dynamicOptions.size()).isEqualTo(2);
assertThat(dynamicOptions.toString()).isEqualTo("{k1=v1, k2=v2}");
}
use of org.apache.flink.table.planner.calcite.FlinkPlannerImpl in project flink by apache.
the class SqlToOperationConverterTest method parseAndConvert.
private Operation parseAndConvert(String sql) {
final FlinkPlannerImpl planner = getPlannerBySqlDialect(SqlDialect.DEFAULT);
final CalciteParser parser = getParserBySqlDialect(SqlDialect.DEFAULT);
SqlNode node = parser.parse(sql);
return SqlToOperationConverter.convert(planner, catalogManager, node).get();
}
use of org.apache.flink.table.planner.calcite.FlinkPlannerImpl in project flink by apache.
the class SqlToOperationConverterTest method testSqlInsertWithStaticPartition.
@Test
public void testSqlInsertWithStaticPartition() {
final String sql = "insert into t1 partition(a=1) select b, c, d from t2";
FlinkPlannerImpl planner = getPlannerBySqlDialect(SqlDialect.DEFAULT);
final CalciteParser parser = getParserBySqlDialect(SqlDialect.DEFAULT);
Operation operation = parse(sql, planner, parser);
assertThat(operation).isInstanceOf(SinkModifyOperation.class);
SinkModifyOperation sinkModifyOperation = (SinkModifyOperation) operation;
final Map<String, String> expectedStaticPartitions = new HashMap<>();
expectedStaticPartitions.put("a", "1");
assertThat(sinkModifyOperation.getStaticPartitions()).isEqualTo(expectedStaticPartitions);
}
use of org.apache.flink.table.planner.calcite.FlinkPlannerImpl in project flink by apache.
the class SqlToOperationConverterTest method testSqlExecuteWithStatementSet.
@Test
public void testSqlExecuteWithStatementSet() {
final String sql = "execute statement set begin " + "insert into t1 select a, b, c, d from t2 where a > 1;" + "insert into t1 select a, b, c, d from t2 where a > 2;" + "end";
FlinkPlannerImpl planner = getPlannerBySqlDialect(SqlDialect.DEFAULT);
final CalciteParser parser = getParserBySqlDialect(SqlDialect.DEFAULT);
Operation operation = parse(sql, planner, parser);
assertThat(operation).isInstanceOf(StatementSetOperation.class);
}
use of org.apache.flink.table.planner.calcite.FlinkPlannerImpl in project flink by apache.
the class SqlToOperationConverterTest method testSqlRichExplainWithInsert.
@Test
public void testSqlRichExplainWithInsert() {
final String sql = "explain plan for insert into t1 select a, b, c, d from t2";
FlinkPlannerImpl planner = getPlannerBySqlDialect(SqlDialect.DEFAULT);
final CalciteParser parser = getParserBySqlDialect(SqlDialect.DEFAULT);
Operation operation = parse(sql, planner, parser);
assertThat(operation).isInstanceOf(ExplainOperation.class);
}
Aggregations