Ivan-gfan opened a new issue, #13411: URL: https://github.com/apache/seatunnel/issues/13411
### 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 When the Jdbc source's `table_path` (or a `table_list` entry) names a **view** instead of a table, the job is rejected at submission on Dameng, Oracle, DB2 and SQL Server, although the view exists and the same user can select from it: ``` ErrorCode:[API-05], ErrorDescription:[Table not existed] - Table SYSDBA.E2E_VIEW_SOURCE does not exist in Catalog Dameng. ``` `AbstractJdbcCatalog#getTable` first checks `tableExists`, and these four catalogs answer it from table-only dictionaries: | Catalog | Existence query | Views are in | |---|---|---| | `DamengCatalog` | `ALL_TABLES` | `ALL_VIEWS` | | `OracleCatalog` | `ALL_TABLES` | `ALL_VIEWS` | | `DB2Catalog` | `SYSCAT.TABLES WHERE TYPE = 'T'` | `TYPE = 'V'` | | `SqlServerCatalog` | `INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'` | `TABLE_TYPE = 'VIEW'` | SQL Server has a second gap: even with the existence check passing, the columns of one named object are read from `sys.tables`, which has no views, so a view would come back with no columns. The other catalogs already accept views here: `MySqlCatalog` and `PostgresCatalog` query `information_schema.tables` without a type filter (which lists views as `TABLE_TYPE = 'VIEW'`), and `SapHanaCatalog#tableExists` checks `SYS.VIEWS` explicitly. So only these four reject a view, and `query = "select * from <view>"` works on all of them, which shows that reading a view is otherwise fine. The config below reproduces it on Dameng; the same happens on Oracle (`table_path = "TESTUSER.V_ORDER"`), DB2 (`table_path = "E2E.E2E.V_ORDER"`) and SQL Server (`table_path = "master.dbo.v_order"`). ### SeaTunnel Version 3.1.0, and current `dev` (3.1.1-SNAPSHOT). ### SeaTunnel Config ```conf env { parallelism = 1 job.mode = "BATCH" } source { Jdbc { url = "jdbc:dm://localhost:5236" driver = "dm.jdbc.driver.DmDriver" username = "SYSDBA" password = "******" # E2E_VIEW_SOURCE is a view: CREATE VIEW SYSDBA.E2E_VIEW_SOURCE AS SELECT ... FROM SYSDBA.E2E_TABLE_SOURCE table_path = "SYSDBA.E2E_VIEW_SOURCE" } } sink { Console {} } ``` ### Running Command ```shell ./bin/seatunnel.sh --config view_source.conf -m local ``` ### Error Exception ```log Caused by: org.apache.seatunnel.api.table.catalog.exception.TableNotExistException: ErrorCode:[API-05], ErrorDescription:[Table not existed] - Table SYSDBA.E2E_VIEW_SOURCE does not exist in Catalog Dameng. at org.apache.seatunnel.connectors.seatunnel.jdbc.catalog.AbstractJdbcCatalog.getTable(AbstractJdbcCatalog.java:219) at org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils.getCatalogTable(JdbcCatalogUtils.java:272) at org.apache.seatunnel.connectors.seatunnel.jdbc.utils.JdbcCatalogUtils.getTables(JdbcCatalogUtils.java:100) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSource.<init>(JdbcSource.java:66) at org.apache.seatunnel.connectors.seatunnel.jdbc.source.JdbcSourceFactory.lambda$createSource$0(JdbcSourceFactory.java:67) at org.apache.seatunnel.api.table.factory.FactoryUtil.createAndPrepareSource(FactoryUtil.java:193) ``` ### Zeta or Flink or Spark Version Zeta (the failure is in the catalog while the source is created, so every engine is affected). ### Java or Scala Version Java 11 / 17 ### 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]
