qinbo78 opened a new issue, #9908: URL: https://github.com/apache/seatunnel/issues/9908
### Search before asking - [x] I had searched in the [issues](https://github.com/apache/seatunnel/issues?q=is%3Aissue+label%3A%22bug%22) and found no similar issues. ### What happened 自动建表模式提示找不到主键,但是上游source是有主键的,提示必须自己写模版来覆盖 ### SeaTunnel Version 2.3.8 ### SeaTunnel Config ```conf env { parallelism = 3 job.mode = "BATCH" } source { Jdbc { result_table_name = "a" url="jdbc:mysql://${jdbc.host}/stat_db" driver="com.mysql.cj.jdbc.Driver" user="${jdbc.user}" password="${jdbc.password}" query="SELECT * FROM t_cdc_test2" partition_column = "id" split.size = 1000 } } transform { DynamicCompile { source_table_name = "a" result_table_name = "b" compile_language="JAVA" compile_pattern="SOURCE_CODE" source_code=""" import org.apache.seatunnel.api.configuration.util.ConfigUtil; import org.apache.seatunnel.api.table.catalog.Column; import org.apache.seatunnel.transform.common.SeaTunnelRowAccessor; import org.apache.seatunnel.api.table.catalog.*; import org.apache.seatunnel.api.table.type.*; import java.util.List; private String[] fieldNames; public Column[] getInlineOutputColumns(CatalogTable inputCatalogTable) { List<Column> columns = inputCatalogTable.getTableSchema().getColumns(); fieldNames = new String[columns.size()]; for (int i = 0; i < columns.size(); i++) { Column col = (Column) columns.get(i); fieldNames[i] = col.getName(); System.out.println("==========================================================================================" + fieldNames[i]); } PhysicalColumn col1 = PhysicalColumn.of( "fields", BasicType.STRING_TYPE, 0L, false, null, ""); PhysicalColumn col2 = PhysicalColumn.of( "create_time", BasicType.LONG_TYPE, 0L, false, 0, ""); PhysicalColumn col3 = PhysicalColumn.of( "field_names", BasicType.STRING_TYPE, 0L, false, null, ""); return new Column[]{ col1, col2, col3 }; } public Object[] getInlineOutputFieldValues(SeaTunnelRowAccessor inputRow) { Object[] fieldValues = new Object[3]; fieldValues[0] = ConfigUtil.convertToJsonString(inputRow.getFields()); fieldValues[1] = System.currentTimeMillis(); fieldValues[2] = "test" + ConfigUtil.convertToJsonString(fieldNames); return fieldValues; } """ } Filter { source_table_name = "b" result_table_name = "c" include_fields = [id, fields, field_names, create_time] } } sink { Doris { source_table_name = "c" fenodes = "${doris.fenodes}" username = "${doris.username}" password = "${doris.password}" database = "${doris.database}" table = "t_cdc_test_init" sink.enable-2pc = "true" sink.enable-delete = "true" schema_save_mode = "CREATE_SCHEMA_WHEN_NOT_EXIST" data_save_mode="DROP_DATA" doris.config { format = "json" read_json_by_line = "true" } } } ``` ### Running Command ```shell $SEATUNNEL_HOME/bin/seatunnel.sh --config ${config} --variable $secret ``` ### Error Exception ```log Caused by: org.apache.seatunnel.common.exception.SeaTunnelRuntimeException: ErrorCode:[COMMON-24], ErrorDescription:[The table of test_ods.t_cdc_test_init has no primary keys, but the template CREATE TABLE IF NOT EXISTS `${database}`.`${table}` ( ${rowtype_primary_key}, ${rowtype_fields} ) ENGINE=OLAP UNIQUE KEY (${rowtype_primary_key}) DISTRIBUTED BY HASH (${rowtype_primary_key}) PROPERTIES ( "replication_allocation" = "tag.location.default: 1", "in_memory" = "false", "storage_format" = "V2", "disable_auto_compaction" = "false" ) which has the place holder named ${rowtype_primary_key}. Please use the option named save_mode_create_template to specify sql template] at org.apache.seatunnel.common.exception.CommonError.sqlTemplateHandledError(CommonError.java:230) at org.apache.seatunnel.connectors.seatunnel.common.sql.template.SqlTemplate.canHandledByTemplateWithPlaceholder(SqlTemplate.java:33) at org.apache.seatunnel.connectors.doris.util.DorisCatalogUtil.getCreateTableStatement(DorisCatalogUtil.java:153) at org.apache.seatunnel.connectors.doris.catalog.DorisCatalog.previewAction(DorisCatalog.java:512) at org.apache.seatunnel.api.sink.DefaultSaveModeHandler.createTablePreCheck(DefaultSaveModeHandler.java:178) at org.apache.seatunnel.api.sink.DefaultSaveModeHandler.createTable(DefaultSaveModeHandler.java:188) at org.apache.seatunnel.api.sink.DefaultSaveModeHandler.createSchemaWhenNotExist(DefaultSaveModeHandler.java:115) at org.apache.seatunnel.api.sink.DefaultSaveModeHandler.handleSchemaSaveMode(DefaultSaveModeHandler.java:74) at org.apache.seatunnel.api.sink.SaveModeHandler.handleSaveMode(SaveModeHandler.java:40) at org.apache.seatunnel.api.sink.SaveModeExecuteWrapper.execute(SaveModeExecuteWrapper.java:36) at org.apache.seatunnel.engine.server.master.JobMaster.handleSaveMode(JobMaster.java:376) ... 21 more at org.apache.seatunnel.engine.server.CoordinatorService.lambda$submitJob$4(CoordinatorService.java:518) at org.apache.seatunnel.api.tracing.MDCRunnable.run(MDCRunnable.java:39) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) ``` ### Zeta or Flink or Spark Version _No response_ ### Java or Scala Version _No response_ ### Screenshots _No response_ ### Are you willing to submit PR? - [ ] Yes I am willing to submit a PR! ### Code of Conduct - [x] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
