[
https://issues.apache.org/jira/browse/CALCITE-3504?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17190047#comment-17190047
]
Pressenna commented on CALCITE-3504:
------------------------------------
Current internal solution: default to {{null}} component type for empty arrays.
We created a new subclass of SqlArrayValueConstructor, which caters for empty
arrays accordingly and registered it against the operator table.
See subclass below.
{code:java}
public static class SqlArrayValueConstructorAllowingEmpty
extends SqlArrayValueConstructor {
@Override
protected RelDataType getComponentType(
RelDataTypeFactory typeFactory, List<RelDataType> argTypes) {
if (argTypes.isEmpty()) {
return typeFactory.createSqlType(SqlTypeName.NULL);
}
return super.getComponentType(typeFactory, argTypes);
}
@Override
public boolean checkOperandTypes(SqlCallBinding callBinding, boolean
throwOnFailure) {
if (callBinding.operands().isEmpty()) {
return true;
}
return super.checkOperandTypes(callBinding, throwOnFailure);
}
}
{code}
> allow empty ARRAY[] literals
> ----------------------------
>
> Key: CALCITE-3504
> URL: https://issues.apache.org/jira/browse/CALCITE-3504
> Project: Calcite
> Issue Type: Wish
> Affects Versions: 1.21.0
> Reporter: Pressenna
> Priority: Major
>
> Currently an ARRAY expression requires at least one element.
> Please allow empty ARRAY expressions.
> {code:sql}
> SELECT ARRAY[] FROM foo;
> -- or more concise for updates:
> UPDATE food set array_column = ARRAY[];
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)