[ 
https://issues.apache.org/jira/browse/IGNITE-22448?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maksim Zhuravkov updated IGNITE-22448:
--------------------------------------
    Description: 
When the AVG function called with a DATE the validator returns the following 
error:

{noformat}
statement error: Cannot apply 'AVG' to arguments of type 'AVG(<DATE>)'. 
Supported form(s): 'AVG(<NUMERIC>)'
SELECT AVG('2011-01-01'::DATE)
{noformat}

But when AVG is called with UUID we get this: 

{noformat}
statement error: Unable to optimize plan due to internal error
SELECT AVG('c4a0327c-44be-416d-ae90-75c05079789f'::UUID)
{noformat}

As this query is transformed to 

{noformat}
SELECT AVG('c4a0327c-44be-416d-ae90-75c05079789f' :: UUID)

LogicalAggregate(group=[{}], EXPR$0=[AVG($0)]), id = 1048
  LogicalProject($f0=[CAST(_UTF-8'c4a0327c-44be-416d-ae90-75c05079789f'):UUID 
NOT NULL]), id = 1047
    LogicalValues(tuples=[[{ 0 }]]), id = 1044
{noformat}

Underlying cause:

{noformat}
java.lang.AssertionError: SUM is not supported for ANY
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.unsupportedAggregateFunction(Accumulators.java:809)
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.sumFactory(Accumulators.java:138)
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.accumulatorFunctionFactory(Accumulators.java:83)
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.accumulatorFactory(Accumulators.java:66)
        at 
org.apache.ignite.internal.sql.engine.util.PlanUtils.addAccumulatorFields(PlanUtils.java:130)
        at 
org.apache.ignite.internal.sql.engine.util.PlanUtils.createHashAggRowType(PlanUtils.java:118)
        at 
org.apache.ignite.internal.sql.engine.rel.agg.IgniteMapHashAggregate.deriveRowType(IgniteMapHashAggregate.java:93)
        at 
org.apache.calcite.rel.AbstractRelNode.getRowType(AbstractRelNode.java:174)
        at 
org.apache.ignite.internal.sql.engine.rel.agg.MapReduceAggregates.buildAggregates(MapReduceAggregates.java:196)
        at 
org.apache.ignite.internal.sql.engine.rule.HashAggregateConverterRule$MapReduceHashAggregateConverterRule.convert(HashAggregateConverterRule.java:157)
        at 
org.apache.ignite.internal.sql.engine.rule.HashAggregateConverterRule$MapReduceHashAggregateConverterRule.convert(HashAggregateConverterRule.java:91)
        at 
org.apache.ignite.internal.sql.engine.rule.AbstractIgniteConverterRule.convert(AbstractIgniteConverterRule.java:51)
        
{noformat}



  was:
When AVG called with DATE the validator returns the following error:

{noformat}
statement error: Cannot apply 'AVG' to arguments of type 'AVG(<DATE>)'. 
Supported form(s): 'AVG(<NUMERIC>)'
SELECT AVG('2011-01-01'::DATE)
{noformat}

But when AVG is called with UUID we get this: 

{noformat}
statement error: Unable to optimize plan due to internal error
SELECT AVG('c4a0327c-44be-416d-ae90-75c05079789f'::UUID)
{noformat}

As this query is transformed to 

{noformat}
SELECT AVG('c4a0327c-44be-416d-ae90-75c05079789f' :: UUID)

LogicalAggregate(group=[{}], EXPR$0=[AVG($0)]), id = 1048
  LogicalProject($f0=[CAST(_UTF-8'c4a0327c-44be-416d-ae90-75c05079789f'):UUID 
NOT NULL]), id = 1047
    LogicalValues(tuples=[[{ 0 }]]), id = 1044
{noformat}

Underlying cause:

{noformat}
java.lang.AssertionError: SUM is not supported for ANY
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.unsupportedAggregateFunction(Accumulators.java:809)
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.sumFactory(Accumulators.java:138)
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.accumulatorFunctionFactory(Accumulators.java:83)
        at 
org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.accumulatorFactory(Accumulators.java:66)
        at 
org.apache.ignite.internal.sql.engine.util.PlanUtils.addAccumulatorFields(PlanUtils.java:130)
        at 
org.apache.ignite.internal.sql.engine.util.PlanUtils.createHashAggRowType(PlanUtils.java:118)
        at 
org.apache.ignite.internal.sql.engine.rel.agg.IgniteMapHashAggregate.deriveRowType(IgniteMapHashAggregate.java:93)
        at 
org.apache.calcite.rel.AbstractRelNode.getRowType(AbstractRelNode.java:174)
        at 
org.apache.ignite.internal.sql.engine.rel.agg.MapReduceAggregates.buildAggregates(MapReduceAggregates.java:196)
        at 
org.apache.ignite.internal.sql.engine.rule.HashAggregateConverterRule$MapReduceHashAggregateConverterRule.convert(HashAggregateConverterRule.java:157)
        at 
org.apache.ignite.internal.sql.engine.rule.HashAggregateConverterRule$MapReduceHashAggregateConverterRule.convert(HashAggregateConverterRule.java:91)
        at 
org.apache.ignite.internal.sql.engine.rule.AbstractIgniteConverterRule.convert(AbstractIgniteConverterRule.java:51)
        
{noformat}




> Sql. Incorrect error message when aggregate function is called with UUID type
> -----------------------------------------------------------------------------
>
>                 Key: IGNITE-22448
>                 URL: https://issues.apache.org/jira/browse/IGNITE-22448
>             Project: Ignite
>          Issue Type: Bug
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>
> When the AVG function called with a DATE the validator returns the following 
> error:
> {noformat}
> statement error: Cannot apply 'AVG' to arguments of type 'AVG(<DATE>)'. 
> Supported form(s): 'AVG(<NUMERIC>)'
> SELECT AVG('2011-01-01'::DATE)
> {noformat}
> But when AVG is called with UUID we get this: 
> {noformat}
> statement error: Unable to optimize plan due to internal error
> SELECT AVG('c4a0327c-44be-416d-ae90-75c05079789f'::UUID)
> {noformat}
> As this query is transformed to 
> {noformat}
> SELECT AVG('c4a0327c-44be-416d-ae90-75c05079789f' :: UUID)
> LogicalAggregate(group=[{}], EXPR$0=[AVG($0)]), id = 1048
>   LogicalProject($f0=[CAST(_UTF-8'c4a0327c-44be-416d-ae90-75c05079789f'):UUID 
> NOT NULL]), id = 1047
>     LogicalValues(tuples=[[{ 0 }]]), id = 1044
> {noformat}
> Underlying cause:
> {noformat}
> java.lang.AssertionError: SUM is not supported for ANY
>       at 
> org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.unsupportedAggregateFunction(Accumulators.java:809)
>       at 
> org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.sumFactory(Accumulators.java:138)
>       at 
> org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.accumulatorFunctionFactory(Accumulators.java:83)
>       at 
> org.apache.ignite.internal.sql.engine.exec.exp.agg.Accumulators.accumulatorFactory(Accumulators.java:66)
>       at 
> org.apache.ignite.internal.sql.engine.util.PlanUtils.addAccumulatorFields(PlanUtils.java:130)
>       at 
> org.apache.ignite.internal.sql.engine.util.PlanUtils.createHashAggRowType(PlanUtils.java:118)
>       at 
> org.apache.ignite.internal.sql.engine.rel.agg.IgniteMapHashAggregate.deriveRowType(IgniteMapHashAggregate.java:93)
>       at 
> org.apache.calcite.rel.AbstractRelNode.getRowType(AbstractRelNode.java:174)
>       at 
> org.apache.ignite.internal.sql.engine.rel.agg.MapReduceAggregates.buildAggregates(MapReduceAggregates.java:196)
>       at 
> org.apache.ignite.internal.sql.engine.rule.HashAggregateConverterRule$MapReduceHashAggregateConverterRule.convert(HashAggregateConverterRule.java:157)
>       at 
> org.apache.ignite.internal.sql.engine.rule.HashAggregateConverterRule$MapReduceHashAggregateConverterRule.convert(HashAggregateConverterRule.java:91)
>       at 
> org.apache.ignite.internal.sql.engine.rule.AbstractIgniteConverterRule.convert(AbstractIgniteConverterRule.java:51)
>       
> {noformat}



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

Reply via email to