You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Mihai Budiu (Jira)" <ji...@apache.org> on 2025/09/04 17:33:00 UTC
[jira] [Created] (CALCITE-7158) NULL cannot be cast to UUID
Mihai Budiu created CALCITE-7158:
------------------------------------
Summary: NULL cannot be cast to UUID
Key: CALCITE-7158
URL: https://issues.apache.org/jira/browse/CALCITE-7158
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.40.0
Reporter: Mihai Budiu
This one is on me; I omitted to do it when I introduced the UUID type.
The bug is in SqlTypeUtil.canCastFrom:
{code:java}
if (toType.getSqlTypeName() == SqlTypeName.UUID) {
return fromType.getSqlTypeName() == SqlTypeName.UUID
|| fromType.getFamily() == SqlTypeFamily.CHARACTER
|| fromType.getFamily() == SqlTypeFamily.BINARY;
{code}
The effect is that code that tries to do for example a UNION between a UUID and a collection with a NULL value will fail with an assertion error:
{code:java}
Caused by: java.lang.AssertionError
at org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion.needToCast(AbstractTypeCoercion.java:309)
at org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion.needToCast(AbstractTypeCoercion.java:260)
at org.apache.calcite.sql.validate.implicit.AbstractTypeCoercion.coerceColumnType(AbstractTypeCoercion.java:202)
at org.apache.calcite.sql.validate.implicit.TypeCoercionImpl.rowTypeCoercion(TypeCoercionImpl.java:101)
at org.apache.calcite.sql.type.SetopOperandTypeChecker.checkOperandTypes(SetopOperandTypeChecker.java:121)
at org.apache.calcite.sql.SqlOperator.checkOperandTypes(SqlOperator.java:784)
at org.apache.calcite.sql.SqlOperator.validateOperands(SqlOperator.java:526)
at org.apache.calcite.sql.SqlOperator.deriveType(SqlOperator.java:630)
at org.apache.calcite.sql.SqlBinaryOperator.deriveType(SqlBinaryOperator.java:180)
at org.apache.calcite.sql.validate.SetopNamespace.validateImpl(SetopNamespace.java:115)
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)