[jira] [Assigned] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-29 Thread ShenDa (Jira)


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

ShenDa reassigned CALCITE-6376:
---

Assignee: ShenDa

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Assignee: ShenDa
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Comment Edited] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa edited comment on CALCITE-6376 at 4/26/24 3:37 AM:
--

The problem encountered is due to the fact that when there are six or fewer 
elements, Calcite creates a collection called Flat6List, which implements its 
own compareTo method, thereby sidestepping the requirement that the elements 
must be Comparable.

In your case, you have exactly seven columns queried, exceeding the limit of 
six, so it uses ComparableListImpl, which ultimately leads to this issue in 
your sample.

I can submit a PR to help resolve the problem you are currently facing.


was (Author: dadashen):
The problem encountered is due to the fact that when there are six or fewer 
elements, Calcite creates a collection called Flat6List, which implements its 
own compareTo method, thereby sidestepping the requirement that the elements 
must be Comparable.

In your case, you have exactly seven columns queried, exceeding the limit of 
six, so it uses ComparableListImpl, which ultimately leads to this issue in 
your sample.

I can submit a PR to help resolve the problem you're currently facing.

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Comment Edited] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa edited comment on CALCITE-6376 at 4/26/24 3:37 AM:
--

The problem encountered is due to the fact that when there are six or fewer 
elements, Calcite creates a collection called Flat6List, which implements its 
own compareTo method, thereby sidestepping the requirement that the elements 
must be Comparable.

In your case, you have exactly seven columns queried, exceeding the limit of 
six, so it uses ComparableListImpl, which ultimately leads to this issue in 
your sample.

I can submit a PR to help resolve the problem you're currently facing.


was (Author: dadashen):
The problem encountered is due to the fact that when there are six or fewer 
elements, Calcite creates a collection called Flat6List, which implements its 
own compareTo method, thereby sidestepping the requirement that the elements 
must be Comparable.

In your case, you have exactly seven columns queried, exceeding the limit of 
six, so it uses ComparableListImpl, which ultimately leads to this issue in 
your sample. 

I can now submit a PR to help resolve the problem you're currently facing.
 
 
 
 
 
 
 

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Comment Edited] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa edited comment on CALCITE-6376 at 4/26/24 3:38 AM:
--

Yep, I reproduced.
And I also found the root cause of this issus. This is because Calcite has a 
class called
ComparableListImpl, which requires its elements to implement Comparable. If 
elements are not comparable, then a ClassCastException will be thrown at 
runtime. 


was (Author: dadashen):
Yep, I reproduced.
And I also found the root cause of this issus. This is because Calcite has a 
class called
ComparableListImpl, which requires its elements to implement Comparable. If the 
elements are not comparable, then a ClassCastException will be thrown at 
runtime. 

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Commented] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa commented on CALCITE-6376:
-

The problem encountered is due to the fact that when there are six or fewer 
elements, Calcite creates a collection called Flat6List, which implements its 
own compareTo method, thereby sidestepping the requirement that the elements 
must be Comparable.

In your case, you have exactly seven columns queried, exceeding the limit of 
six, so it uses ComparableListImpl, which ultimately leads to this issue in 
your sample. 

I can now submit a PR to help resolve the problem you're currently facing.
 
 
 
 
 
 
 

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Comment Edited] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa edited comment on CALCITE-6376 at 4/26/24 3:28 AM:
--

Yep, I reproduced.
And I also found the root cause of this issus. This is because Calcite has a 
class called
ComparableListImpl, which requires its elements to implement Comparable. If the 
elements are not comparable, then a ClassCastException will be thrown at 
runtime. 


was (Author: dadashen):
Yep, I reproduced.
And I also found the root cause of this issus. This is because Calcite has a 
class called ComparableList, which requires its elements to implement 
Comparable. If the elements are not comparable, then a ClassCastException will 
be thrown at runtime. 

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Comment Edited] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa edited comment on CALCITE-6376 at 4/26/24 3:23 AM:
--

Yep, I reproduced.
And I also found the root cause of this issus. This is because Calcite has a 
class called ComparableList, which requires its elements to implement 
Comparable. If the elements are not comparable, then a ClassCastException will 
be thrown at runtime. 


was (Author: dadashen):
Yep,  I reproduced.
And I also found the root cause of this issus. This is because Calcite has a 
class called ComparableList, which requires its elements to implement 
Comparable. If the elements are not comparable, then a ClassCastException will 
be thrown at runtime. 
```java
  /** List that is also comparable.
   *
   * You can create an instance whose type
   * parameter {@code T} does not extend {@link Comparable}, but you will get a
   * {@link ClassCastException} at runtime when you call
   * {@link #compareTo(Object)} if the elements of the list do not implement
   * {@code Comparable}.
   *
   * @param  element type
   */
```

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Commented] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa commented on CALCITE-6376:
-

Yep,  I reproduced.
And I also found the root cause of this issus. This is because Calcite has a 
class called ComparableList, which requires its elements to implement 
Comparable. If the elements are not comparable, then a ClassCastException will 
be thrown at runtime. 
```java
  /** List that is also comparable.
   *
   * You can create an instance whose type
   * parameter {@code T} does not extend {@link Comparable}, but you will get a
   * {@link ClassCastException} at runtime when you call
   * {@link #compareTo(Object)} if the elements of the list do not implement
   * {@code Comparable}.
   *
   * @param  element type
   */
```

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


[jira] [Commented] (CALCITE-6376) Filtering CTE of at least 6 columns with QUALIFY operation results in exception

2024-04-25 Thread ShenDa (Jira)


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

ShenDa commented on CALCITE-6376:
-

Can you please tell me how to reproduce the issue you're facing?

> Filtering CTE of at least 6 columns with QUALIFY operation results in 
> exception
> ---
>
> Key: CALCITE-6376
> URL: https://issues.apache.org/jira/browse/CALCITE-6376
> Project: Calcite
>  Issue Type: Bug
>Affects Versions: 1.36.0
>Reporter: Austin Richardson
>Priority: Major
>
> Example query:
>  
> {code:java}
> WITH MyCTE AS (
> SELECT 
> column1,
> column2,
> column3,
> column4,
> column5,
> column6
> FROM (
> VALUES 
> ('value1', 10, 5.0, 'data1', 'info1', 'test1'),
> ('value2', 20, 4.0, 'data2', 'info2', 'test2'),
> ('value3', 30, 3.0, 'data3', 'info3', 'test3'),
> ('value4', 40, 2.0, 'data4', 'info4', 'test4'),
> ('value5', 50, 1.0, 'data5', 'info5', 'test5')
> ) AS t(column1, column2, column3, column4, column5, column6)
> )
> SELECT *
> FROM MyCTE
> QUALIFY RANK() OVER (ORDER BY column3) = 1{code}
>  
> And exception snippet:
>  
> {code:java}
> Caused by: java.lang.ClassCastException: class 
> org.apache.calcite.rex.RexInputRef cannot be cast to class 
> java.lang.Comparable (org.apache.calcite.rex.RexInputRef is in unnamed module 
> of loader org.springframework.boot.loader.LaunchedURLClassLoader @257f30f7; 
> java.lang.Comparable is in module java.base of loader 'bootstrap')
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1319)
>   at 
> org.apache.calcite.runtime.FlatLists$ComparableListImpl.get(FlatLists.java:1309)
>   at 
> java.base/java.util.AbstractList$Itr.next(AbstractList.java:373){code}
>  
> Either removing one of the columns or the QUALIFY filter results in a 
> successful query.



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


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

2023-03-16 Thread ShenDa (Jira)


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

ShenDa commented on CALCITE-4166:
-

Does anyone still try to solve problem?  I meet same exception.

> 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.20.10#820010)