[jira] [Resolved] (CALCITE-5989) Type inference for RPAD and LPAD functions (BIGQUERY) is incorrect

2023-09-29 Thread Ruben Q L (Jira)


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

Ruben Q L resolved CALCITE-5989.

Resolution: Fixed

Fixed via 
[{{3bb7117}}|https://github.com/apache/calcite/commit/3bb71174460d10542c3c9892c6a1a8effb573f9e]

Thanks [~mbudiu] for the patch!

> Type inference for RPAD and LPAD functions (BIGQUERY) is incorrect
> --
>
> Key: CALCITE-5989
> URL: https://issues.apache.org/jira/browse/CALCITE-5989
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Mihai Budiu
>Priority: Minor
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> The type inference uses the type `ReturnTypes.ARG0_NULLABLE_VARYING` for the 
> output.
> This means that the output cannot be longer than arg0. This bug surfaces when 
> the query is optimized.



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


[jira] [Commented] (CALCITE-6009) Add optimization to remove redundant Limit when its input's row number is less or equal to Limit's fetch

2023-09-29 Thread LakeShen (Jira)


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

LakeShen commented on CALCITE-6009:
---

This PR is Ready, the PR link is :[https://github.com/apache/calcite/pull/3449]

if others have time, please help me to review it, thank you very much:)

> Add optimization to remove redundant Limit when its input's row number is 
> less or equal to Limit's fetch
> 
>
> Key: CALCITE-6009
> URL: https://issues.apache.org/jira/browse/CALCITE-6009
> Project: Calcite
>  Issue Type: New Feature
>  Components: core
>Reporter: LakeShen
>Assignee: LakeShen
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> In calcite,Limit would be represented by Sort,such as `LogicalSort[fetch = 
> 5]`.
> When the Limit' source row number is less than the Limit's fetch,we could 
> remove the the redundant Limit.
> For example:
> {code:java}
> SELECT * FROM (VALUES 1,2,3,4,5,6) AS t1 LIMIT 10 {code}
> The plan tree is :
> {code:java}
>  LogicalSort(fetch=[10])
>   LogicalProject(t1=[$0])
>     LogicalValues(tuples=[[{ 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }]]) {code}
> Because the Limit's source max row number is 6,the Limit's fetch is 10,so we 
> could remove the redundant Limit.
> Another example is :
> {code:java}
> SELECT count(*) FROM orders LIMIT 2 {code}
> The plan tree is :
> {code:java}
>  LogicalSort(fetch=[2])
>   LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
>     LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> Because Limit's source max row number is 1,the Limit's fetch is 2, so we 
> could remove the redundant Limit.
> The logic is same as presto's RemoveRedundantLimit 
> rule:https://github.com/prestodb/presto/blob/50fbc07111ecca60a1a5e62755f095fa204120d0/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantLimit.java#L27



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


[jira] [Updated] (CALCITE-6009) Add optimization to remove redundant Limit when its input's row number is less or equal to Limit's fetch

2023-09-29 Thread ASF GitHub Bot (Jira)


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

ASF GitHub Bot updated CALCITE-6009:

Labels: pull-request-available  (was: )

> Add optimization to remove redundant Limit when its input's row number is 
> less or equal to Limit's fetch
> 
>
> Key: CALCITE-6009
> URL: https://issues.apache.org/jira/browse/CALCITE-6009
> Project: Calcite
>  Issue Type: New Feature
>  Components: core
>Reporter: LakeShen
>Assignee: LakeShen
>Priority: Major
>  Labels: pull-request-available
> Fix For: 1.36.0
>
>
> In calcite,Limit would be represented by Sort,such as `LogicalSort[fetch = 
> 5]`.
> When the Limit' source row number is less than the Limit's fetch,we could 
> remove the the redundant Limit.
> For example:
> {code:java}
> SELECT * FROM (VALUES 1,2,3,4,5,6) AS t1 LIMIT 10 {code}
> The plan tree is :
> {code:java}
>  LogicalSort(fetch=[10])
>   LogicalProject(t1=[$0])
>     LogicalValues(tuples=[[{ 1 }, { 2 }, { 3 }, { 4 }, { 5 }, { 6 }]]) {code}
> Because the Limit's source max row number is 6,the Limit's fetch is 10,so we 
> could remove the redundant Limit.
> Another example is :
> {code:java}
> SELECT count(*) FROM orders LIMIT 2 {code}
> The plan tree is :
> {code:java}
>  LogicalSort(fetch=[2])
>   LogicalAggregate(group=[{}], EXPR$0=[COUNT()])
>     LogicalTableScan(table=[[tpch, ORDERS]]) {code}
> Because Limit's source max row number is 1,the Limit's fetch is 2, so we 
> could remove the redundant Limit.
> The logic is same as presto's RemoveRedundantLimit 
> rule:https://github.com/prestodb/presto/blob/50fbc07111ecca60a1a5e62755f095fa204120d0/presto-main/src/main/java/com/facebook/presto/sql/planner/iterative/rule/RemoveRedundantLimit.java#L27



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