You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "waterWang (via GitHub)" <gi...@apache.org> on 2026/08/16 05:18:41 UTC

[PR] fix: handle empty struct in CompareSchemasVisitor.struct() [iceberg]

waterWang opened a new pull request, #17683:
URL: https://github.com/apache/iceberg/pull/17683

   Fixes #17650
   
   ## Problem
   
   `CompareSchemasVisitor.struct()` computes its result as:
   
   ```java
   Result result = fields.stream().reduce(Result::merge).orElse(Result.SCHEMA_UPDATE_NEEDED);
   ```
   
   For a struct with zero fields, the `reduce` is empty, so `orElse(SCHEMA_UPDATE_NEEDED)` always fires. Consequently any schema containing an empty struct (e.g. derived from an Avro union whose branch is a zero-field marker record) can never compare `SAME` with any table schema — including a table created from that exact schema.
   
   In the Dynamic Sink this is fatal: `TableUpdater.findOrCreateSchema` sees `SCHEMA_UPDATE_NEEDED`, applies `EvolveSchemaVisitor` (a no-op here), commits, re-compares — still `SCHEMA_UPDATE_NEEDED` — and `TableMetadataCache.schema()` caches and returns `NOT_FOUND`, whose `resolvedTableSchema()` is null.
   
   ## Fix
   
   Change `orElse(Result.SCHEMA_UPDATE_NEEDED)` to `orElse(Result.SAME)` — when both structs have zero fields, they are semantically identical.
   
   ## Changes
   
   - `flink/v1.20/flink/src/main/java/.../CompareSchemasVisitor.java`
   - `flink/v2.0/flink/src/main/java/.../CompareSchemasVisitor.java`
   - `flink/v2.1/flink/src/main/java/.../CompareSchemasVisitor.java`
   
   All three versions had the same bug (identical content).
   


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: handle empty struct in CompareSchemasVisitor.struct() [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17683:
URL: https://github.com/apache/iceberg/pull/17683#issuecomment-5706538216

   This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the dev@iceberg.apache.org list. Thank you for your contributions.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: handle empty struct in CompareSchemasVisitor.struct() [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #17683:
URL: https://github.com/apache/iceberg/pull/17683#issuecomment-5824570898

   This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org


Re: [PR] fix: handle empty struct in CompareSchemasVisitor.struct() [iceberg]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #17683: fix: handle empty struct in CompareSchemasVisitor.struct()
URL: https://github.com/apache/iceberg/pull/17683


-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org