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

Type comparision should respect case-sensitive SQL conf

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.3.0
    • Component/s: SQL
    • Labels:
      None

      Description

      Spark supports case-sensitivity in columns. Especially, for Struct types, with case sensitive option, the following is supported.

      scala> sql("select named_struct('a', 1, 'A', 2).a").show
      +--------------------------+
      |named_struct(a, 1, A, 2).a|
      +--------------------------+
      |                         1|
      +--------------------------+
      
      scala> sql("select named_struct('a', 1, 'A', 2).A").show
      +--------------------------+
      |named_struct(a, 1, A, 2).A|
      +--------------------------+
      |                         2|
      +--------------------------+
      

      And vice versa, with case sensitive `false`, the following is supported.

      scala> sql("select named_struct('a', 1).A, named_struct('A', 1).a").show
      +--------------------+--------------------+
      |named_struct(a, 1).A|named_struct(A, 1).a|
      +--------------------+--------------------+
      |                   1|                   1|
      +--------------------+--------------------+
      

      This issue aims to support case-insensitive type comparisions in Set operation. Currently, SET operations fail due to case-sensitive type comparision failure .

      scala> sql("SELECT struct(1 a) UNION ALL (SELECT struct(2 A))").show
      org.apache.spark.sql.AnalysisException: Union can only be performed on tables with the compatible column types. struct<A:int> <> struct<a:int> at the first column of the second table;;
      'Union
      :- Project [named_struct(a, 1) AS named_struct(a, 1 AS `a`)#2]
      :  +- OneRowRelation$
      +- Project [named_struct(A, 2) AS named_struct(A, 2 AS `A`)#3]
         +- OneRowRelation$
      

        Attachments

          Activity

            People

            • Assignee:
              dongjoon Dongjoon Hyun
              Reporter:
              dongjoon Dongjoon Hyun
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: