[
https://issues.apache.org/jira/browse/CALCITE-7877?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mihai Budiu resolved CALCITE-7877.
----------------------------------
Fix Version/s: 1.43.0
Resolution: Fixed
Fixed in
[https://github.com/apache/calcite/commit/3f0b7fbe31d5341de7c28dd55023d4b2cb1e27ce]
Thank you for the fix [~linzch3]
Thank you for the review [~rubenql]
> EnumerableDefaults.asOrderedQueryable throws NullPointerException for any
> Enumerable that is not already an OrderedQueryable
> ----------------------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-7877
> URL: https://issues.apache.org/jira/browse/CALCITE-7877
> Project: Calcite
> Issue Type: Bug
> Components: linq4j
> Affects Versions: 1.42.0
> Reporter: Vladimir Sitnikov
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.43.0
>
>
> Calling {{EnumerableDefaults.asOrderedQueryable(source)}} with an
> {{Enumerable}} that is not an {{OrderedQueryable}} throws
> {{NullPointerException}} instead of returning a queryable over {{source}}.
> {code:java}
> EnumerableDefaults.asOrderedQueryable(Linq4j.asEnumerable(java.util.Arrays.asList(1,
> 2)));
> {code}
> On main ({{6ff13eaccd}}, 1.43.0-SNAPSHOT), in jshell with
> {{linq4j/build/classes/java/main}} on the class path:
> {noformat}
> | Exception java.lang.NullPointerException: null
> | at Objects.requireNonNull (Objects.java:259)
> | at EnumerableDefaults.asOrderedQueryable
> (EnumerableDefaults.java:4507)
> {noformat}
> The same exception fails a SQL query against a {{QueryableTable}} whose
> {{asQueryable}} returns {{EnumerableDefaults.asOrderedQueryable(enumerable)}}:
> {noformat}
> java.sql.SQLException: Error while executing SQL "select max("ts"),
> min("tm"), max("dt") from T": null
> ...
> Caused by: java.lang.NullPointerException: null
> at java.base/java.util.Objects.requireNonNull(Objects.java:259)
> at
> org.apache.calcite.linq4j.EnumerableDefaults.asOrderedQueryable(EnumerableDefaults.java:4507)
> at <the table's asQueryable>
> at org.apache.calcite.schema.Schemas.queryable(Schemas.java:256)
> {noformat}
> The method passes {{requireNonNull(null, "null")}} as the {{QueryProvider}}
> argument of {{EnumerableOrderedQueryable}}, so it cannot succeed for any
> input that takes that branch. All four {{EnumerableQueryable.orderBy}} and
> {{orderByDescending}} overloads pass it the result of
> {{EnumerableDefaults.orderBy}} or {{orderByDescending}}, which is a plain
> {{AbstractEnumerable}}, so they always throw too.
> Expected: the call returns an {{OrderedQueryable}} that enumerates {{1, 2}},
> as it did up to 1.26.0, where the provider argument was {{null}}. The
> {{requireNonNull(null)}} came in with CALCITE-4199 (1.27.0), and CALCITE-4431
> only added the message.
> Found while checking PR 971 (CALCITE-1703), whose test table uses this method.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)