Skip to content

[CALCITE-5345] UnionPullUpConstantsRule could also pull up constants requiring a cast - #5437

Open
xuzifu666 wants to merge 1 commit into
apache:mainfrom
xuzifu666:calcite-5435
Open

xuzifu666 wants to merge 1 commit into
apache:mainfrom
xuzifu666:calcite-5435

Conversation

@xuzifu666

Copy link
Copy Markdown
Member

jira: https://issues.apache.org/jira/browse/CALCITE-5345

As described in Jira, this issue should already be fixed by https://issues.apache.org/jira/browse/CALCITE-6169; this PR adds the relevant tests.

@xuzifu666 xuzifu666 closed this Nov 23, 2026
@xuzifu666 xuzifu666 reopened this Nov 23, 2026

@asolimando asolimando left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks a lot for chasing this old ticket and making sure it's fixed now!

Can you add a negative test along these lines?

  @Test void testPullConstantThroughUnionWithCastFractionalConstant() {
    // 1.5 cannot be represented exactly as an INT, so the cast is not
    // folded and the rule bails out.
    final String sql = "select deptno, ename from emp where deptno = 1.5\n"
        + "union all\n"
        + "select deptno, ename from emp where deptno = 1.5";
    sql(sql)
        .withTrim(true)
        .withRule(CoreRules.UNION_PULL_UP_CONSTANTS,
            CoreRules.PROJECT_MERGE)
        .checkUnchanged();
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants