xiedeyantu opened a new pull request, #4897: URL: https://github.com/apache/calcite/pull/4897
<!-- Thanks for sending a pull request! Here are some critical tips for you: 1. READ THE GUIDE FIRST: https://calcite.apache.org/develop/#contributing *For significant contributions, please discuss on the dev mailing list or Jira BEFORE coding.* 2. JIRA IS USUALLY MANDATORY: Ensure you have created an issue on the Calcite Jira: https://issues.apache.org/jira/projects/CALCITE/issues *Check existing issues first to avoid duplicates.* *Note: A Jira is NOT required for typos and cosmetic changes (i.e., changes that are neither bugs nor features).* 3. TIMING: Strongly recommended to create the Jira BEFORE you start writing code (e.g., a day or so before posting a PR). This gives others a chance to weigh in on your specification. 4. CRITICAL CONSISTENCY RULE The following three items MUST match exactly in wording and meaning: (A) The Jira Issue Title (B) This Pull Request Title (C) Your Git Commit Message Format: [CALCITE-XXXX] <Description> Example: [CALCITE-0000] Add IF NOT EXISTS clause to CREATE TABLE Guidelines for a good Title: - Illustrate using SQL keywords (in ALL-CAPS) rather than Java method names. - Focus on the specification and user experience, not the implementation. - Make it clear whether it is a bug or a feature. - Use words like "should" to indicate desired behavior vs. current behavior (e.g., "Validator should not close model file"). 5. REPRODUCTION: If fixing a bug, please provide a concise SQL example or test case to reproduce the issue for a faster review. 6. TESTING: Ensure `./gradlew build` passes and appropriate tests are added/updated. --> ## Jira Link [CALCITE-6451](https://issues.apache.org/jira/browse/CALCITE-6451) ## Changes Proposed <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. If possible, please consider writing useful notes for better and faster reviews in your PR. --> SetOp overrides `deriveRowType()` and computes the output row type to be the least restrictive across all inputs [here](https://github.com/apache/calcite/blob/8ab0b03326730aa2cc6b476b2cbd8f99799bdacb/core/src/main/java/org/apache/calcite/rel/core/SetOp.java#L116-L127). So for example given Input 1: (I64, I64, I64?, I64?) Input 2: (I64, I64?, I64, I64?) where ? denotes nullable, the least restrictive output computes: Output: (I64, I64?, I64?, I64?) For UNION operations, these nullabilities are accurate. However for MINUS and INTERSECT there is room for improvement. MINUS only returns rows from the first input, as such its output nullability should always match that of its first input: Output: (I64, I64, I64?, I64?) INTERSECT only returns rows that match across all inputs. If a column is not nullable in any of the inputs, then it is not nullable in the output because no rows can be emitted in which that column is null: Output: (I64, I64, I64, I64?) -- 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]
