You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by "zhangqs0205 (via GitHub)" <gi...@apache.org> on 2026/04/03 09:13:26 UTC
[PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
zhangqs0205 opened a new pull request, #10706:
URL: https://github.com/apache/seatunnel/pull/10706
## What
- add a JDBC dialect extension point for partition key detection
- detect Hive partition keys from `DESCRIBE <table>` metadata
- propagate detected partition keys into JDBC `CatalogTable` metadata paths
- add regression tests for Hive partition-key parsing and metadata propagation
## Why
JDBC metadata currently hardcodes `partitionKeys` as empty in the relevant catalog-table construction path, which loses Hive partition information.
## Validation
- added `HiveDialectTest` for parsing partition keys from Hive `DESCRIBE` output
- added `CatalogUtilsTest` coverage for partition-key propagation into `CatalogTable`
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "zhangqs0205 (via GitHub)" <gi...@apache.org>.
zhangqs0205 commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4478581029
@DanielLeens
Thanks for the review and the follow-up.
While adding the `JdbcHiveIT` coverage for the `JdbcCatalogUtils.getTables()` path, I found a few Hive JDBC metadata gaps that were hidden before, so I fixed them together with the regression coverage:
1. Hive partition keys are not exposed reliably through standard JDBC table/column metadata.
I added a Hive-specific `DESCRIBE <table>` partition parser and wired `dialect.getPartitionKeys(...)` into the real `getTables()` / `CatalogTable` metadata path, so `CatalogTable.partitionKeys` can now carry `dt/hr` correctly.
2. Hive primary-key metadata is not reliable through `DatabaseMetaData#getPrimaryKeys()`.
I added the dialect capability `supportsPrimaryKeyMetadata()` and made Hive skip PK metadata lookup explicitly in `getTableSchema()`. This avoids treating Hive’s unsupported PK metadata path as a real table failure, while preserving the normal SQLException behavior for dialects that do support PK metadata.
3. Some Hive JDBC metadata capability methods for identifier case are unsupported.
I narrowed the fallback in `JdbcIdentifierUtils.identifierCaseStrategy(...)` to only handle `SQLFeatureNotSupportedException` and fall back to case-insensitive matching. Other real `SQLException`s are still propagated.
I also fixed the new Hive E2E assert config to match the 6 inserted partition rows and kept explicit `field_value = []` entries for type-only checks, because the assert executor expects a non-null rule list when `field_rules` are configured.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo merged PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "zhangqs0205 (via GitHub)" <gi...@apache.org>.
zhangqs0205 commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4438221519
> Thanks for working on this. I re-reviewed the full current head locally on `seatunnel-review-10706` against `upstream/dev`. This was a source-level review only; I did not run local Maven in this round.
>
> # What This PR Fixes
> * User pain: Hive/Inceptor metadata discovery is inconsistent through standard JDBC APIs, especially around partition keys and sometimes primary-key metadata.
> * Fix approach: the PR parses Hive partition keys from `DESCRIBE` output and also adds a fallback around `DatabaseMetaData.getPrimaryKeys()`.
> * One-line summary: the Hive-specific direction is reasonable, but the shared primary-key fallback is currently too broad and changes behavior for every JDBC dialect, not just Hive.
>
> # 1. Code Review
> ## 1.1 Core Logic Analysis
> * Exact change scope:
>
> * `seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/catalog/utils/CatalogUtils.java:130-163`
> * `seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/hive/HiveDialect.java:78-112`
> * Before / after:
>
> ```java
> // before
> try (ResultSet rs = metaData.getPrimaryKeys(...)) {
> while (rs.next()) {
> primaryKeyColumns.add(...);
> }
> }
> ```
>
> ```java
> // after
> try (ResultSet rs = metaData.getPrimaryKeys(...)) {
> while (rs.next()) {
> primaryKeyColumns.add(...);
> }
> } catch (SQLException e) {
> log.warn("Failed to get primary key info for table {}, returning empty primary key. Error: {}", tablePath, e.getMessage());
> return Optional.empty();
> }
> ```
>
> * Key findings:
>
> 1. The Hive `DESCRIBE` parsing path is on the real runtime path and looks directionally correct.
> 2. The shared `CatalogUtils.getPrimaryKey()` helper is not Hive-only. Other JDBC catalogs also go through it.
> 3. Catching every `SQLException` here means a real metadata failure now becomes "this table has no primary key".
> 4. That is not just a logging choice. It changes downstream schema / constraint semantics.
> * Runtime chain I checked:
>
> ```
> JDBC catalog introspection
> -> CatalogUtils.getPrimaryKey(DatabaseMetaData, TablePath)
> -> DatabaseMetaData.getPrimaryKeys(...)
> -> Optional<PrimaryKey>
> -> CatalogTable / TableSchema assembly
> -> downstream save-mode / upsert / constraint decisions use that PK signal
>
> Hive-specific partition path
> -> HiveDialect.getPartitionKeys(Connection, TablePath)
> -> DESCRIBE table
> -> parse "# Partition Information" section
> ```
>
> ## 1.2 Compatibility Impact
> * Verdict: partially incompatible.
> * API/config/defaults/protocol/serialization are unchanged.
> * The incompatible part is behavior: a shared JDBC metadata failure is now downgraded to "no primary key", which is broader than the Hive problem this PR is trying to fix.
>
> ## 1.3 Performance / Side Effects
> * No meaningful CPU or memory regression from the Hive parser itself.
> * The main side effect is semantic, not performance-related: real metadata failures are now silently flattened into a different business meaning.
>
> ## 1.4 Error Handling and Logs
> Issue 1: The shared primary-key fallback is too broad
>
> * Location: `CatalogUtils.java:144`
> * Why this is a problem:
> this code sits on the normal JDBC metadata path. Right now any `SQLException` from `getPrimaryKeys()` becomes `Optional.empty()`, even when the driver should have returned real PK metadata and something actually went wrong.
> * Risk:
> downstream logic can now treat a metadata failure as "this table genuinely has no primary key", which can mislead save-mode, upsert, or catalog-sync behavior.
> * Suggested fix:
> narrow the fallback to dialects or exception types that are explicitly known to mean "primary key metadata is unsupported" instead of swallowing every `SQLException`.
> * Severity: High
>
> Issue 2: The current Build is still red
>
> * Location: GitHub `Build`
> * Why this matters:
> the latest Apache-side `Build` is still failing, and the linked fork run currently shows failures including `unit-test (8, ubuntu-latest)` and `updated-modules-integration-test-part-4 (11, ubuntu-latest)`.
> * Severity: Medium
>
> # 2. Code Quality
> * The new Hive partition parsing is readable and scoped correctly.
> * Test coverage is moving in the right direction, but I would still add one regression case proving that a non-Hive JDBC metadata failure is not silently downgraded to "empty PK".
>
> # 3. Architecture
> * The Hive dialect part is a precise fix.
> * The shared fallback in `CatalogUtils` is not. It broadens the behavior boundary beyond the original problem.
>
> # 4. Issue Summary
> No. Issue Location Severity
> 1 Shared PK metadata failures are downgraded too broadly `CatalogUtils.java:144` High
> 2 Current Build is still red GitHub `Build` Medium
> # 5. Merge Conclusion
> ### Conclusion: merge after fixes
> 1. Blocking items
>
> * Issue 1 must be fixed. The fallback needs to be narrowed so it does not change behavior for every JDBC dialect.
> * Issue 2 also needs to be cleared by getting the latest Build green.
>
> 2. Suggested non-blocking follow-up
>
> * Add one non-Hive regression test around shared PK metadata failures so this boundary does not widen again later.
>
> The Hive-specific direction still looks good to me. The blocker is that the current shared fallback changes the semantics for all JDBC catalogs, not just Hive.
@DanielLeens
Thanks for the review. I agree that catching SQLException in the shared CatalogUtils.getPrimaryKey() is too broad and may change behavior for non-Hive JDBC catalogs. The original scope of this PR is Hive partition key detection, so I will remove this fallback from CatalogUtils and keep the change scoped to the Hive partition-key metadata path.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4318621845
Hi @zhangqs0205, I rechecked the current head locally after the latest review activity.
The blocker from my earlier review is addressed on the current head:
- the Hive partition keys are no longer only parsed in isolation
- they are now carried into the real `CatalogTable` construction path
- the current Build is green
Runtime chain I rechecked
```text
Hive JDBC metadata
-> HiveDialect.getPartitionKeys(connection, tablePath)
-> parse DESCRIBE <table> partition section
-> JdbcCatalogUtils.getCatalogTable(...)
-> CatalogUtils.getCatalogTable(..., partitionKeys)
-> CatalogTable.partitionKeys
```
The important difference from the older blocked version is that the partition keys are now passed through the reachable metadata path instead of only being tested at the parser/helper level.
### Conclusion: can merge
Blocking items:
- None from my side.
Non-blocking follow-up:
- If you want even stronger confidence later, a more integration-style check against a real Hive-compatible driver output would still be nice hardening, but I would not block this PR on that.
Thanks for the fix. The current head looks good to me now.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4483463911
Hi @zhangqs0205, thanks for the detailed write-up — that context helps. The current Daniel approval already covers head `d848475555ff1976ba906561c46a1f05941781a6`, and the points you listed match the paths I traced on this same head through `JdbcCatalogUtils.getTables()`, `JdbcCatalogUtils.getTableSchema()`, and `JdbcIdentifierUtils.identifierCaseStrategy(...)`. Since there is no new commit after that approval, I am treating this as a reply-only follow-up rather than starting another full review on unchanged code. On CI, the current `Build` result looks like a cancelled run rather than a source-level regression signal, so rerunning that check on the same head is the right next step.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "davidzollo (via GitHub)" <gi...@apache.org>.
davidzollo commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4478716677
> By the way, CI in this project usually needs to be rerun several times before all checks pass.
Yes, you can only retry the failed CI tasks
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "DanielLeens (via GitHub)" <gi...@apache.org>.
DanielLeens commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4503863961
Thanks for the update, and good to hear CI is green now.
I checked the current PR head `d848475555ff1976ba906561c46a1f05941781a6`, and it is still the same revision I already reviewed earlier, so there is no new code delta for me to re-review in this round.
If you push another commit later, feel free to ping me again and I will take another pass.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "zhangqs0205 (via GitHub)" <gi...@apache.org>.
zhangqs0205 commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4498968525
Hi @davidzollo ,CI is passed
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [Fix][Connector-V2][JDBC] Detect Hive partition keys in metadata [seatunnel]
Posted by "zhangqs0205 (via GitHub)" <gi...@apache.org>.
zhangqs0205 commented on PR #10706:
URL: https://github.com/apache/seatunnel/pull/10706#issuecomment-4478628106
By the way, CI in this project usually needs to be rerun several times before all checks pass.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org