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

Julian Hyde commented on CALCITE-3297:
--------------------------------------

{quote}Hello @julianhyde , the PigToSqlAggregateRule was affected by my 
additional check that I added to rel builder in scope of CALCITE-3138. At that 
time I thought that merging restructuring project (project which collects 
flattened fields back into struct here ) and flattening projects added ,for 
example, on top of scan makes work performed by RelStructuredTypeFlattener 
redundant. Please look at test updates in the PR. The final expressions in 
projects looks really redundant for me, for example ROW($2.OTHERS.A, 
$2.OTHERS.B) could be simply $2.OTHERS, and other results, like flattening and 
collecting back results of ITEM(...) look weird.{quote}

I agree that {{ROW($2.OTHERS.A, $2.OTHERS.B)}} is not optimal. Maybe we should 
rethink whether we should continue to use {{RelStructuredTypeFlattener}} as we 
improve our support for nested data.

But your changes in this PR are all improvements. Your changes are in 
{{SqlToRelConverter}}, so potentially we could optimize later in the planning 
process - for example a {{RelOptRule}} or {{RexSimplify}} function that 
transforms {{ROW($2.OTHERS.A, $2.OTHERS.B)}} into {{$2.OTHERS}} as you suggest.

> PigToSqlAggregateRule should be applied on multi-set projection to produce an 
> optimal plan
> ------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-3297
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3297
>             Project: Calcite
>          Issue Type: Bug
>          Components: piglet
>            Reporter: Khai Tran
>            Assignee: Igor Guzenko
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.21.0
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Fixed testMultisetProjection() in PigRelOpTest.java to make sure the 
> PigToSqlAggregateRule is applied to produce an optimized plan for doing 
> multiset projection after COLLECT() agg func.
> The optimization rule was blocked by change in CALCITE-3138.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to