niumy0701 opened a new issue, #13405: URL: https://github.com/apache/seatunnel/issues/13405
### 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 ### 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 A batch job that reads a PostgreSQL partitioned table fails during split generation, seconds after submission, with `No result returned after running query [SELECT reltuples FROM pg_class r WHERE relkind = 'r' AND relname = 'balance';]`. A declarative partitioned table parent is stored in `pg_class` with `relkind = 'p'`, but `PostgresDialect#approximateRowCntStatement` (connector-jdbc) filters on `relkind = 'r'`, so the lookup returns no row and the dialect throws. The table itself is readable — a plain `SELECT * FROM` the parent scans all partitions — the failure is only in the approximate row count used to plan splits. The job uses the `table_list` mode with table-level `query` and `partition_column`. The `isOldVersion` check in `JdbcSourceConfig` only looks at the **top-level** `query`/`partition_column` options, which are empty here, so the source still selects the dynamic splitter and reaches the lookup. Multi-table (`table_list`) jobs therefore hit this on every partitioned table. Affected versions: 2.3.13 and dev (same code, `PostgresDialect#approximateRowCntStatement`). ### SeaTunnel Version 2.3.13 (the same code exists on dev) ### SeaTunnel Config ```hocon env { execution.parallelism = 32 job.mode = "BATCH" job.name = "balance_sync" } source { Jdbc { url = "jdbc:postgresql://<host>:<port>/testdb?tcpKeepAlive=true&socketTimeout=60&loginTimeout=10" driver = "org.postgresql.Driver" user = "<user>" password = "<password>" fetch_size = 20000 decimal_type_narrowing = false table_list = [ { table_path = "public.balance" partition_column = "balance_id" query = "SELECT * FROM public.balance" } ] } } ### SeaTunnel Version 2.3.13 ### SeaTunnel Config ```conf env { execution.parallelism = 32 job.mode = "BATCH" job.name = "balance" } source { Jdbc { url = "jdbc:postgresql://<host>:<port>/db?tcpKeepAlive=true&socketTimeout=60&loginTimeout=10" driver = "org.postgresql.Driver" user = "<user>" password = "<password>" fetch_size = 20000 decimal_type_narrowing = false table_list = [ { table_path = "public.balance" partition_column = "balance_id" query = "SELECT * FROM public.balance" } ] } } ``` ### Running Command ```shell ### 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 A batch job that reads a PostgreSQL partitioned table fails during split generation, seconds after submission, with `No result returned after running query [SELECT reltuples FROM pg_class r WHERE relkind = 'r' AND relname = 'balance';]`. A declarative partitioned table parent is stored in `pg_class` with `relkind = 'p'`, but `PostgresDialect#approximateRowCntStatement` (connector-jdbc) filters on `relkind = 'r'`, so the lookup returns no row and the dialect throws. The table itself is readable — a plain `SELECT * FROM` the parent scans all partitions — the failure is only in the approximate row count used to plan splits. The job uses the `table_list` mode with table-level `query` and `partition_column`. The `isOldVersion` check in `JdbcSourceConfig` only looks at the **top-level** `query`/`partition_column` options, which are empty here, so the source still selects the dynamic splitter and reaches the lookup. Multi-table (`table_list`) jobs therefore hit this on every partitioned table. Affected versions: 2.3.13 and dev (same code, `PostgresDialect#approximateRowCntStatement`). ### SeaTunnel Version 2.3.13 (the same code exists on dev) ### SeaTunnel Config env { execution.parallelism = 32 job.mode = "BATCH" job.name = "balance_sync" } source { Jdbc { url = "jdbc:postgresql://<host>:<port>/testdb?tcpKeepAlive=true&socketTimeout=60&loginTimeout=10" driver = "org.postgresql.Driver" user = "<user>" password = "<password>" fetch_size = 20000 decimal_type_narrowing = false table_list = [ { table_path = "public.balance" partition_column = "balance_id" query = "SELECT * FROM public.balance" } ] } } ``` ### Error Exception ```log org.apache.flink.util.FlinkException: Global failure triggered by OperatorCoordinator for 'Source: Jdbc-Source -> MultiTableSink-Sink: Writer' (operator cbc357ccb763df2852fee8c4fc7d55f2). at org.apache.flink.runtime.operators.coordination.OperatorCoordinatorHolder$LazyInitializedCoordinatorContext.failJob(OperatorCoordinatorHolder.java:651) at org.apache.flink.runtime.operators.coordination.RecreateOnResetOperatorCoordinator$QuiesceableContext.failJob(RecreateOnResetOperatorCoordinator.java:259) at org.apache.flink.runtime.source.coordinator.SourceCoordinatorContext.failJob(SourceCoordinatorContext.java:432) ... Caused by: java.lang.RuntimeException: java.sql.SQLException: No result returned after running query [SELECT reltuples FROM pg_class r WHERE relkind = 'r' AND relname = 'balance';] at org.apache.seatunnel.translation.flink.source.FlinkSourceEnumerator.addReader(FlinkSourceEnumerator.java:113) ... Caused by: java.sql.SQLException: No result returned after running query [SELECT reltuples FROM pg_class r WHERE relkind = 'r' AND relname = 'balance';] at org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.psql.PostgresDialect.approximateRowCntStatement(PostgresDialect.java:269) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.DynamicChunkSplitter.queryApproximateRowCnt(DynamicChunkSplitter.java:329) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.DynamicChunkSplitter.evenlyColumnSplitChunks(DynamicChunkSplitter.java:254) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.DynamicChunkSplitter.splitTableIntoChunks(DynamicChunkSplitter.java:130) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.DynamicChunkSplitter.createDynamicSplits(DynamicChunkSplitter.java:52) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.DynamicChunkSplitter.createSplits(DynamicChunkSplitter.java:69) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.ChunkSplitter.generateSplits(ChunkSplitter.java:113) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceSplitEnumerator.run(JdbcSourceSplitEnumerator.java:81) at org.apache.seatunnel.translation.flink.source.FlinkSourceEnumerator.addReader(FlinkSourceEnumerator.java:111) ... 11 more ``` ### Zeta or Flink or Spark Version Flink 1.20 — SeaTunnel 2.3.13, submitted through the Flink Client API. ### Java or Scala Version _No response_ ### Screenshots _No response_ ### Are you willing to submit PR? - [x] 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]
