Ivan-gfan opened a new pull request, #13412:
URL: https://github.com/apache/seatunnel/pull/13412

   ### Purpose of this pull request
   
   Fixes #13411.
   
   A Jdbc source whose `table_path` (or `table_list` entry) names a view is 
rejected at submission on Dameng, Oracle, DB2 and SQL Server with 
`TableNotExistException`, because `getTable` checks `tableExists` first and 
these catalogs answer it from table-only dictionaries. MySQL, PostgreSQL and 
SAP HANA already count views there, so this PR aligns the four catalogs with 
them:
   
   - `DamengCatalog`, `OracleCatalog`: the existence query also looks in 
`ALL_VIEWS` (`UNION ALL`).
   - `DB2Catalog`: the existence query and the table comment accept `TYPE IN 
('T', 'V')`.
   - `SqlServerCatalog`: the existence query accepts `TABLE_TYPE IN ('BASE 
TABLE', 'VIEW')`, and the columns of one named object are read from 
`sys.objects` (`type IN ('U', 'V')`) instead of `sys.tables`, which has no 
views. The schema-wide column template, which the SQL Server CDC connector also 
uses, is unchanged because CDC only captures tables.
   
   `listTables` still lists tables only, so pattern-based table discovery is 
unchanged. The column queries of Dameng, Oracle and DB2 (`ALL_TAB_COLUMNS`, 
`SYSCAT.COLUMNS`) already include view columns.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Previously a source `table_path` naming a view failed on these four 
databases with
   
   ```
   ErrorCode:[API-05], ErrorDescription:[Table not existed] - Table 
SYSDBA.E2E_VIEW_SOURCE does not exist in Catalog Dameng.
   ```
   
   Now the view is read like a table, as it already is on MySQL and PostgreSQL. 
As on those databases, a sink target whose name is taken by a view is now also 
reported as existing.
   
   ### How was this patch tested?
   
   Unit tests (`connector-jdbc`, 1242 tests, all passing):
   - `DamengCatalogTest#existenceCheckCoversTablesAndViews`, 
`OracleCatalogExistenceSqlTest`, 
`DB2CatalogTest#testExistenceCheckCoversTablesAndViews`: the existence SQL 
covers views while the table listing stays tables only.
   - `SqlServerCatalogViewSqlTest`: existence SQL, the per-object column SQL 
reading `sys.objects`, and the CDC column template staying on `sys.tables`.
   
   E2E (`JdbcDmIT`, `JdbcOracleIT`, `JdbcDb2IT`, `JdbcSqlServerIT`), two shared 
helpers in `AbstractJdbcIT`:
   - `testViewAsSourceTablePath`: creates a view over the source table, runs a 
job whose source `table_path` names the view 
(`jdbc_<db>_view_source_to_sink.conf`), and checks that all source rows reach a 
sink table created by save mode. The view and that sink table are dropped 
afterwards, so the shared sink table of the other cases is untouched.
   - `testCatalogResolvesView`: the catalog finds the view by its path and 
returns its columns in order.
   
   Run locally on the Zeta engine (`RUN_ENGINES=SEATUNNEL`), whole classes:
   - `JdbcOracleIT` 11/11 and `JdbcSqlServerIT` 7/7 pass.
   - `JdbcDmIT` 7/8: the new cases pass; the existing 
`testLocalTimeZoneAndIntervalTypeConversion` fails on a host whose default time 
zone observes DST on its test date (one-hour offset) and passes with 
`-Duser.timezone=UTC`, so it is unrelated to this change.
   - `JdbcDb2IT` could not run locally: the `ibmcom/db2:11.5.0.0a` container 
hangs in instance configuration on this Docker Desktop host. It is left to CI; 
the DB2 change is covered by the unit test and was checked by hand against a 
DB2 11.5 database (a view read through `table_path`, all rows and columns 
arriving).
   
   With the `DamengCatalog` change reverted, both new Dameng cases fail: the 
catalog case with `expected: <true> but was: <false>` and the job case with the 
`TableNotExistException` above.
   
   ### Check list
   
   * [x] If any new Jar binary package adding in your PR, please add License 
Notice according
     [New License 
Guide](https://github.com/apache/seatunnel/blob/dev/docs/en/developer/new-license.md)
 (no new dependency)
   * [x] If necessary, please update the documentation to describe the new 
feature. https://github.com/apache/seatunnel/tree/dev/docs (no option changes)
   * [x] If necessary, please update `incompatible-changes.md` to describe the 
incompatibility caused by this PR. (not needed)
   * [ ] If you are contributing the connector code, please check that the 
following files are updated: (not a new connector)


-- 
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]

Reply via email to