You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "damccorm (via GitHub)" <gi...@apache.org> on 2026/06/09 15:55:28 UTC

[PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

damccorm opened a new pull request, #38868:
URL: https://github.com/apache/beam/pull/38868

   (no comment)


-- 
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: github-unsubscribe@beam.apache.org

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


Re: [PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

Posted by "Abacn (via GitHub)" <gi...@apache.org>.
Abacn commented on code in PR #38868:
URL: https://github.com/apache/beam/pull/38868#discussion_r3398850016


##########
sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslJoinTest.java:
##########
@@ -325,6 +325,54 @@ private PCollection<Row> ordersUnbounded() {
         .buildUnbounded();
   }
 
+  @Test
+  public void testLeftOuterJoinWithNestedRows() {

Review Comment:
   I ran the test reverting BeamCoGBKJoinRel.java‎ change it still passes
   



-- 
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: github-unsubscribe@beam.apache.org

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


Re: [PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #38868:
URL: https://github.com/apache/beam/pull/38868#discussion_r3398622735


##########
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/rel/BeamCoGBKJoinRel.java:
##########
@@ -193,11 +194,41 @@ private PCollection<Row> standardJoin(
     }
 
     // Flatten the lhs and rhs fields into a single row.
+    FieldAccessDescriptor flattenFields =
+        FieldAccessDescriptor.withFieldNames(
+            org.apache.beam.sdk.schemas.transforms.Join.LHS_TAG + ".*",
+            org.apache.beam.sdk.schemas.transforms.Join.RHS_TAG + ".*");
+
+    // Reconcile the desired output schema (which carries the Calcite-derived field names and the
+    // correct top-level, outer-join-aware nullability) with the types the data actually carries.
+    // Calcite's join row-type derivation can report a different nullability than the rows hold --
+    // in particular it can mark the fields nested inside a struct column as nullable even when the
+    // joined rows still keep them NOT NULL. Forcing the Calcite schema verbatim then trips Select's
+    // type-equality guard. The flatten emits the lhs struct's fields followed by the rhs struct's
+    // fields, so walk the Calcite output positionally against those data fields, keeping Calcite's
+    // names and top-level nullability but adopting the data's (possibly deeper) field types.
+    Schema calciteSchema = CalciteUtils.toSchema(getRowType());
+    Schema joinedSchema = joinedRows.getSchema();
+    List<Schema.Field> dataFields = new java.util.ArrayList<>();
+    dataFields.addAll(
+        Preconditions.checkArgumentNotNull(joinedSchema.getField(0).getType().getRowSchema())
+            .getFields());
+    dataFields.addAll(
+        Preconditions.checkArgumentNotNull(joinedSchema.getField(1).getType().getRowSchema())
+            .getFields());
+    Schema.Builder reconciled = Schema.builder();
+    for (int i = 0; i < calciteSchema.getFieldCount(); i++) {

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   To prevent an unexpected `IndexOutOfBoundsException` during the loop, it is safer to defensively check that the field count of `calciteSchema` matches the size of `dataFields` before iterating.
   
   ```suggestion
       if (calciteSchema.getFieldCount() != dataFields.size()) {
         throw new IllegalStateException(
             String.format(
                 "Field count mismatch: Calcite schema has %d fields, but data schema has %d fields",
                 calciteSchema.getFieldCount(), dataFields.size()));
       }
   
       Schema.Builder reconciled = Schema.builder();
       for (int i = 0; i < calciteSchema.getFieldCount(); i++) {
   ```



-- 
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: github-unsubscribe@beam.apache.org

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


Re: [PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

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

   Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`


-- 
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: github-unsubscribe@beam.apache.org

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


Re: [PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on code in PR #38868:
URL: https://github.com/apache/beam/pull/38868#discussion_r3399016447


##########
sdks/java/extensions/sql/src/test/java/org/apache/beam/sdk/extensions/sql/BeamSqlDslJoinTest.java:
##########
@@ -325,6 +325,54 @@ private PCollection<Row> ordersUnbounded() {
         .buildUnbounded();
   }
 
+  @Test
+  public void testLeftOuterJoinWithNestedRows() {

Review Comment:
   Yeah, you're right - I think we don't actually need this backport after all, thanks



-- 
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: github-unsubscribe@beam.apache.org

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


Re: [PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm closed pull request #38868: Reconcile schema nullability in BeamCoGBKJoinRel
URL: https://github.com/apache/beam/pull/38868


-- 
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: github-unsubscribe@beam.apache.org

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


Re: [PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #38868:
URL: https://github.com/apache/beam/pull/38868#issuecomment-4684204203

   ## Summary of Changes
   
   Hello, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
   
   This pull request resolves a schema mismatch issue encountered during outer joins involving nested row structures. By reconciling the Calcite-derived schema with the actual underlying data schema, the changes ensure that nested field nullability is respected while maintaining correct top-level nullability for outer join operations. This prevents unnecessary type-guard exceptions during the execution of Beam SQL joins.
   
   ### Highlights
   
   * **Schema Reconciliation**: Implemented a reconciliation process in BeamCoGBKJoinRel to align Calcite-derived schema nullability with actual data schema, specifically addressing nested struct fields.
   * **Type Compatibility Guard**: Fixed a bug where overly aggressive nullability marking by Calcite caused schema compatibility failures in Beam's physical join transforms.
   * **Regression Testing**: Added a new test case in BeamSqlDslJoinTest to verify that left outer joins with nested rows handle nullability correctly.
   
   <details>
   <summary><b>New Features</b></summary>
   
   🧠 You can now enable **Memory** (public preview) to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
   </details>
   
   <details>
   <summary><b>Using Gemini Code Assist</b></summary>
   <br>
   
   The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
   
   <b>Invoking Gemini</b>
   
   You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
   
   Feature | Command | Description
   --- | --- | ---
   Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
   Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
   Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
   Help | `/gemini help` | Displays a list of available commands.
   
   <b>Customization</b>
   
   To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   <b>Limitations & Feedback</b>
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   </details>
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
   


-- 
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: github-unsubscribe@beam.apache.org

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


Re: [PR] Reconcile schema nullability in BeamCoGBKJoinRel [beam]

Posted by "damccorm (via GitHub)" <gi...@apache.org>.
damccorm commented on PR #38868:
URL: https://github.com/apache/beam/pull/38868#issuecomment-4684184031

   R: @Abacn 


-- 
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: github-unsubscribe@beam.apache.org

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