[ 
https://issues.apache.org/jira/browse/CALCITE-7325?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18044344#comment-18044344
 ] 

Jinkun Liu edited comment on CALCITE-7325 at 12/11/25 4:48 AM:
---------------------------------------------------------------

I have reviewed the relevant implementation in Calcite. In 
org.apache.calcite.runtime.variant.VariantNonNull#item, VARIANT values of type 
MAP currently only support access via String or Integer keys.

I also checked Snowflake, which has a similar VARIANT type. In Snowflake, 
VARIANT contain a value of any other data type, including MAP and OBJECT. 
However, both MAP and OBJECT only allow STRING or INTEGER as keys at Snowflake, 
and therefore only support item access using STRING or INTEGER.
[https://docs.snowflake.com/en/sql-reference/data-types-semistructured#object|https://docs.snowflake.com/en/sql-reference/data-types-semistructured#object]
 
[https://docs.snowflake.com/en/sql-reference/data-types-structured#label-structured-types-specifying-map|https://docs.snowflake.com/en/sql-reference/data-types-structured#label-structured-types-specifying-map]

Based on this, I think we should change getAllowedSignatures from 
<VARIANT>[<ANY>] to <VARIANT>[<CHARACTER>|<INTEGER>].

If you agree with this change, I would appreciate it if you could assign this 
issue to me. I would be happy to submit a PR later.[~mbudiu]


was (Author: JIRAUSER308530):
I have reviewed the relevant implementation in Calcite. In 
org.apache.calcite.runtime.variant.VariantNonNull#item, VARIANT values of type 
MAP currently only support access via String or Integer keys.

I also checked Snowflake, which has a similar VARIANT concept. In Snowflake, 
VARIANT contain a value of any other data type, including MAP and OBJECT. 
However, both MAP and OBJECT only allow STRING or INTEGER as keys at Snowflake, 
and therefore only support item access using STRING or INTEGER.
[https://docs.snowflake.com/en/sql-reference/data-types-semistructured#object|https://docs.snowflake.com/en/sql-reference/data-types-semistructured#object]
 
[https://docs.snowflake.com/en/sql-reference/data-types-structured#label-structured-types-specifying-map|https://docs.snowflake.com/en/sql-reference/data-types-structured#label-structured-types-specifying-map]

Based on this, I think we should change getAllowedSignatures from 
<VARIANT>[<ANY>] to <VARIANT>[<CHARACTER>|<INTEGER>].

If you agree with this change, I would appreciate it if you could assign this 
issue to me. I would be happy to submit a PR later.[~mbudiu]

> Inconsistent handling of VARIANT between getAllowedSignatures and getChecker 
> in SqlItemOperator
> -----------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-7325
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7325
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jinkun Liu
>            Assignee: Mihai Budiu
>            Priority: Trivial
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> In core/src/main/java/org/apache/calcite/sql/fun/SqlItemOperator.java, the 
> behavior and the documented signatures for VARIANT are inconsistent between 
> getAllowedSignatures and getChecker:
>  * getAllowedSignatures declares the following signature for ITEM:
>  ** <VARIANT>[<ANY>]
>  * However, getChecker currently returns:
>  ** 
> OperandTypes.family(SqlTypeFamily.INTEGER).or(OperandTypes.family(SqlTypeFamily.CHARACTER))
>  for VARIANT , effectively allowing only integer or character indexes.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to