You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "benj (Jira)" <ji...@apache.org> on 2019/10/04 09:12:00 UTC

[jira] [Created] (DRILL-7396) Exception when trying to access last element of an array with repeated_count

benj created DRILL-7396:
---------------------------

             Summary: Exception when trying to access last element of an array with repeated_count
                 Key: DRILL-7396
                 URL: https://issues.apache.org/jira/browse/DRILL-7396
             Project: Apache Drill
          Issue Type: Bug
          Components: Functions - Drill
    Affects Versions: 1.16.0
            Reporter: benj


Use of array in drill is not friendly
{code:sql}
SELECT (split('a,b,c',','))[0]; /*NOK */
Error: SYSTEM ERROR: ClassCastException: org.apache.drill.common.expression.FunctionCall cannot be cast to org.apache.drill.common.expression.SchemaPath

/* outer SELECT needed*/
SELECT x[0] FROM (SELECT split('a,b,c',',') x); /* OK */
{code}
And access last element of an array is worse
{code:sql}
SELECT x[repeated_count(x) - 1] AS lasteltidx FROM (SELECT split('a,b,c',',') x);
Error: SYSTEM ERROR: ClassCastException: org.apache.calcite.rex.RexCall cannot be cast to org.apache.calcite.rex.RexLiteral

/* while */
SELECT x[2] lastelt, (repeated_count(x) - 1) AS lasteltidx FROM (SELECT split('a,b,c',',') x);
+---------+------------+
| lastelt | lasteltidx |
+---------+------------+
| c       | 2          |
+---------+------------+
{code}



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