@Test public void testSqlInsertWithStaticPartition() { final String sql = "insert into t1 partition(a=1) select b, c, d from t2"; FlinkPlannerImpl planner = getPlannerBySqlDialect(SqlDialect.HIVE); SqlNode node = planner.parse(sql); assert node instanceof RichSqlInsert; Operation operation = SqlToOperationConverter.convert(planner, node); assert operation instanceof CatalogSinkModifyOperation; CatalogSinkModifyOperation sinkModifyOperation = (CatalogSinkModifyOperation) operation; final Map<String, String> expectedStaticPartitions = new HashMap<>(); expectedStaticPartitions.put("a", "1"); assertEquals(expectedStaticPartitions, sinkModifyOperation.getStaticPartitions()); }
public static Operation convert(FlinkPlannerImpl flinkPlanner, SqlNode sqlNode) { final SqlNode validated = flinkPlanner.validate(sqlNode); SqlToOperationConverter converter = new SqlToOperationConverter(flinkPlanner); if (validated instanceof SqlCreateTable) { return converter.convertCreateTable((SqlCreateTable) validated); } if (validated instanceof SqlDropTable) { return converter.convertDropTable((SqlDropTable) validated); } else if (validated instanceof RichSqlInsert) { return converter.convertSqlInsert((RichSqlInsert) validated); } else if (validated.getKind().belongsTo(SqlKind.QUERY)) { return converter.convertSqlQuery(validated); } else { throw new TableException("Unsupported node type " + validated.getClass().getSimpleName()); } }
SqlToOperationConverter { public static Operation convert(FlinkPlannerImpl flinkPlanner, SqlNode sqlNode) { final SqlNode validated = flinkPlanner.validate(sqlNode); SqlToOperationConverter converter = new SqlToOperationConverter(flinkPlanner); if (validated instanceof SqlCreateTable) { return converter.convertCreateTable((SqlCreateTable) validated); } if (validated instanceof SqlDropTable) { return converter.convertDropTable((SqlDropTable) validated); } else if (validated instanceof RichSqlInsert) { return converter.convertSqlInsert((RichSqlInsert) validated); } else if (validated.getKind().belongsTo(SqlKind.QUERY)) { return converter.convertSqlQuery(validated); } else { throw new TableException("Unsupported node type " + validated.getClass().getSimpleName()); } } }
SqlToOperationConverter { public static Operation convert(FlinkPlannerImpl flinkPlanner, SqlNode sqlNode) { final SqlNode validated = flinkPlanner.validate(sqlNode); SqlToOperationConverter converter = new SqlToOperationConverter(flinkPlanner); if (validated instanceof SqlCreateTable) { return converter.convertCreateTable((SqlCreateTable) validated); } if (validated instanceof SqlDropTable) { return converter.convertDropTable((SqlDropTable) validated); } else if (validated instanceof RichSqlInsert) { return converter.convertSqlInsert((RichSqlInsert) validated); } else if (validated.getKind().belongsTo(SqlKind.QUERY)) { return converter.convertSqlQuery(validated); } else { throw new TableException("Unsupported node type " + validated.getClass().getSimpleName()); } } private  SqlToOperationConverter(FlinkPlannerImpl flinkPlanner); }
SqlToOperationConverter { public static Operation convert(FlinkPlannerImpl flinkPlanner, SqlNode sqlNode) { final SqlNode validated = flinkPlanner.validate(sqlNode); SqlToOperationConverter converter = new SqlToOperationConverter(flinkPlanner); if (validated instanceof SqlCreateTable) { return converter.convertCreateTable((SqlCreateTable) validated); } if (validated instanceof SqlDropTable) { return converter.convertDropTable((SqlDropTable) validated); } else if (validated instanceof RichSqlInsert) { return converter.convertSqlInsert((RichSqlInsert) validated); } else if (validated.getKind().belongsTo(SqlKind.QUERY)) { return converter.convertSqlQuery(validated); } else { throw new TableException("Unsupported node type " + validated.getClass().getSimpleName()); } } private  SqlToOperationConverter(FlinkPlannerImpl flinkPlanner); static Operation convert(FlinkPlannerImpl flinkPlanner, SqlNode sqlNode); }
SqlToOperationConverter { public static Operation convert(FlinkPlannerImpl flinkPlanner, SqlNode sqlNode) { final SqlNode validated = flinkPlanner.validate(sqlNode); SqlToOperationConverter converter = new SqlToOperationConverter(flinkPlanner); if (validated instanceof SqlCreateTable) { return converter.convertCreateTable((SqlCreateTable) validated); } if (validated instanceof SqlDropTable) { return converter.convertDropTable((SqlDropTable) validated); } else if (validated instanceof RichSqlInsert) { return converter.convertSqlInsert((RichSqlInsert) validated); } else if (validated.getKind().belongsTo(SqlKind.QUERY)) { return converter.convertSqlQuery(validated); } else { throw new TableException("Unsupported node type " + validated.getClass().getSimpleName()); } } private  SqlToOperationConverter(FlinkPlannerImpl flinkPlanner); static Operation convert(FlinkPlannerImpl flinkPlanner, SqlNode sqlNode);  }