Uploaded image for project: 'Spark'
  1. Spark
  2. SPARK-46374

Array Indexing is 1-based via ANSI SQL Standard

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.0.0, 3.5.1, 3.4.3
    • None
    • SQL
    • None

    Description

      SPARK-28402 was closed by the reporter, because he might think it's a postgres specific feature.

       

      <element reference> ::=
          <array value expression>
             <left bracket or trigraph> <numeric value expression> <right bracket or trigraph>
        
      1) If the value of  or  is the null value, then
      the result of  is the null value.
      2) Let the value of  be i.
      Case:
      a) If i is greater than zero and less than or equal to the cardinality of ,
      then the result of  is the value of the i-th element of the value of .
      
       

      The numeric value expression in the range of greater than zero and less than or equal to the cardinality a.k.a., [1, size(array)]

      Who supports?(Incomplete)

      • postgres
      • Oracle
      • trino/presto
      • MySQL

      Who doesn't support?(Incomplete)

      • hive
      • spark sql (ANSI off/on)

      For ANSI compliance, we shall make array indexing 1-based when spark.sql.ansi.enabled=true

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              yao Kent Yao
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: