inference in Calcite is still mysterious to me. Here it infers the type of the argument of UPPER to be NULL instead of VARCHAR. That's why the result type of UPPER is also NULL. The fact that UPPER has an OperandTypeChecker of "OperandTypes.CHARACTER" is completely ignored:
public static final SqlFunction UPPER = SqlBasicFunction.create("UPPER", ReturnTypes.ARG0_NULLABLE, OperandTypes.CHARACTER, SqlFunctionCategory.STRING); Mihai ________________________________ From: stanilovsky evgeny <estanilovs...@gridgain.com> Sent: Friday, January 12, 2024 4:23 AM To: dev@calcite.apache.org <dev@calcite.apache.org> Subject: [Question] Derived type from string expression with NULL parameter Plz help me to understand is it a bug ? From standard: 6.18 <string value function> ...cut... <fold> ::= { UPPER | LOWER } <left paren> <character value expression> <right paren> 6)If <fold> is specified, then: a) The declared type of the result of <fold> is the declared type of the !!!<character value expression>!!!. thus i expect that return type from: SELECT UPPER(null) will be VARCHAR but calcite show : SqlValidatorTest @Test void testTypeOfUpper() { sql("SELECT UPPER(NULL)") .columnType("???"); } Expected: is "???" but: was "NULL" I think it need to be fixed ? Thanks !