This is related to https://issues.apache.org/jira/browse/CALCITE-5987
Casts for NULLs are meaningful, they should not be removed in general. Mihai ________________________________ From: Guillaume Masse <masse.guilla...@narrative.io.INVALID> Sent: Tuesday, July 8, 2025 10:06 AM To: dev@calcite.apache.org <dev@calcite.apache.org> Subject: unparse for NULL with a type Hi, I'm having issues unparsing `NULL` with a certain type T. My goal is to have: `CAST(NULL AS T)` when I unparse my RexNode. If I create a null literal with: `rexBuilder.makeNullLiteral(myTypeT)`, `RelToSqlConverter` will simply drop the type and render NULL. If I explicitly create a cast null with `rexBuilder.makeCast(myTypeT, rexBuilder.makeNullLiteral(myTypeT))`, RexSimplify will remove the cast see https://github.com/apache/calcite/blob/calcite-1.40.0/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L278 https://github.com/apache/calcite/blob/calcite-1.40.0/core/src/main/java/org/apache/calcite/rex/RexSimplify.java#L2223 should I create a Jira ticket? -- Guillaume Massé [Gee-OHM] (马赛卫)