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

Dongjoon Hyun updated SPARK-21247:
----------------------------------
    Description: 
Spark supports case-sensitivity in columns. Especially, for Struct types, with 
case sensitive option, the following is supported.

{code}
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|
+--------------------------+
{code}

And vice versa, with case sensitive `false`, the following is supported.
{code}
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|
+--------------------+--------------------+
{code}

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

{code}
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$
{code}

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

{code}
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|
+--------------------------+
{code}

And vice versa, with case sensitive `false`, the following is supported.
{code}
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|
+--------------------+--------------------+
{code}

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

{code}
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$
{code}

Please note that this issue does not aim to change all type comparison 
semantics.


> Type comparision should respect case-sensitive SQL conf
> -------------------------------------------------------
>
>                 Key: SPARK-21247
>                 URL: https://issues.apache.org/jira/browse/SPARK-21247
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.1.1
>            Reporter: Dongjoon Hyun
>
> Spark supports case-sensitivity in columns. Especially, for Struct types, 
> with case sensitive option, the following is supported.
> {code}
> 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|
> +--------------------------+
> {code}
> And vice versa, with case sensitive `false`, the following is supported.
> {code}
> 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|
> +--------------------+--------------------+
> {code}
> This issue aims to support case-insensitive type comparisions in Set 
> operation. Currently, SET operations fail due to case-sensitive type 
> comparision failure .
> {code}
> 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$
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to