You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Krisztian Kasa (Jira)" <ji...@apache.org> on 2020/08/07 08:12:00 UTC

[jira] [Commented] (CALCITE-4166) UnsupportedOperationException when getting distribution in metadata quey

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

Krisztian Kasa commented on CALCITE-4166:
-----------------------------------------

When I replaced the call *Project.getPartialMapping* to *Project.getMapping* here
https://github.com/apache/calcite/blob/b3b3e06eef7eeedf2de32b44d061af7867633be6/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistribution.java#L164
attached test passed.

> UnsupportedOperationException when getting distribution in metadata quey
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-4166
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4166
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.21.0, 1.24.0
>            Reporter: Krisztian Kasa
>            Priority: Major
>         Attachments: RelMdDistributionTest.java, cbo_query74_stacktrace.txt
>
>
> The RelDistribution is calculated by:
> 1. Get the Project input's RelDistribution. If it is a TableScan which scans a partitioned table the returned RelDistribution object contains the indexes of partition columns like:  RelDistribution(hash[0, 4])
> 2. If the project contains these columns we need a mapping to map the key indexes in the RelDistribution.
> Mapping is generated here:
> https://github.com/apache/calcite/blob/b3b3e06eef7eeedf2de32b44d061af7867633be6/core/src/main/java/org/apache/calcite/rel/metadata/RelMdDistribution.java#L164
> This mapping is an INVERSE_FUNCTION
> [https://github.com/apache/calcite/blob/2088488ac8327b19512a76a122cae2961fc551c3/core/src/main/java/org/apache/calcite/rel/core/Project.java#L375]
> which does not support *getTargetOpt*
> Stack trace from UT ( [^RelMdDistributionTest.java] ) I created to reproduce the issue in Calcite:
> {code}
> [0;31;1mFAILURE   2.1sec, org.apache.calcite.rel.metadata.RelMdDistributionTest > test()
>     java.lang.UnsupportedOperationException
>         at org.apache.calcite.util.mapping.Mappings$AbstractMapping.getSourceOpt(Mappings.java:913)
>         at org.apache.calcite.util.mapping.Mappings$InverseMapping.getTargetOpt(Mappings.java:1800)
>         at org.apache.calcite.rel.RelDistributions$RelDistributionImpl.apply(RelDistributions.java:145)
>         at org.apache.calcite.rel.metadata.RelMdDistribution.project(RelMdDistribution.java:166)
>         at org.apache.calcite.rel.metadata.RelMdDistribution.distribution(RelMdDistribution.java:98)
>         at org.apache.calcite.rel.metadata.RelMdDistributionTest.test(RelMdDistributionTest.java:76)
> {code}
> And a stacktrace from Hive where we hit this issue:  [^cbo_query74_stacktrace.txt] 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)