[ https://issues.apache.org/jira/browse/CALCITE-5272?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ian Bertolacci closed CALCITE-5272. ----------------------------------- Resolution: Not A Problem Realized that RelBuilder/RexBuilder actually *does* guard against this, but it requires assertions to be enabled (which, for whatever inane reason, were not enabled by default in my local testing area). > RelBuilder/RexBuilder allow creation of invalid CASE expression > --------------------------------------------------------------- > > Key: CALCITE-5272 > URL: https://issues.apache.org/jira/browse/CALCITE-5272 > Project: Calcite > Issue Type: Bug > Affects Versions: 1.30.0 > Reporter: Ian Bertolacci > Priority: Minor > > It is possible (and easy) to create the invalid CASE expression†{{`CASE ELSE > 1 END`}} using either RelBuilder or RexBuilder. > (†Or at least and expression which Calcite then cannot parse.) > {code:scala} > val relBuilder: RelBuilder = ... > val rexBuilder: RexBuilder = ... > val typeFactory = relBuilder.getTypeFactory > // Invalid case expression that can be built > val caseExprRel = relBuilder.call(SqlStdOperatorTable.CASE, > relBuilder.literal(1)) > val caseExprRex = rexBuilder.makeCall(SqlStdOperatorTable.CASE, rexBuilder. > makeBigintLiteral(BigDecimal.valueOf(1))) > // RelNode tree with project containing invalid case expressions > val node = > relBuilder.values( > java.util.Arrays.asList( java.util.Arrays.asList(relBuilder.literal(0)) ), > typeFactory.builder().add("x", > typeFactory.createSqlType(SqlTypeName.INTEGER)).build() > ) > .project(caseExprRel, caseExprRex) > .build() > {code} > Gives the RelNode tree: > {code} > 1:LogicalProject($f0=[CASE(1)], $f1=[CASE(1:BIGINT)]) > 0:LogicalValues(tuples=[[{ 0 }]]) > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)