ca1217667c
### What changes were proposed in this pull request? unionByName does not supports struct having same col names but different sequence ``` val df1 = Seq((1, Struct1(1, 2))).toDF("a", "b") val df2 = Seq((1, Struct2(1, 2))).toDF("a", "b") val unionDF = df1.unionByName(df2) ``` it gives the exception `org.apache.spark.sql.AnalysisException: Union can only be performed on tables with the compatible column types. struct<c2:int,c1:int> <> struct<c1:int,c2:int> at the second column of the second table; 'Union false, false :- LocalRelation [_1#38, _2#39] +- LocalRelation _1#45, _2#46` In this case the col names are same so this unionByName should have the support to check within in the Struct if col names are same it should not throw this exception and works. after fix we are getting the result ``` val unionDF = df1.unionByName(df2) scala> unionDF.show +---+------+ | a| b| +---+------+ | 1|{1, 2}| | 1|{2, 1}| +---+------+ ``` ### Why are the changes needed? As per unionByName functionality based on name, does the union. In the case of struct this scenario was missing where all the columns names are same but sequence is different, so added this functionality. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Added the unit test and also done the testing through spark shell Closes #32972 from SaurabhChawla100/SPARK-35756. Authored-by: SaurabhChawla <s.saurabhtim@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> |
||
---|---|---|
.. | ||
catalyst | ||
core | ||
hive | ||
hive-thriftserver | ||
create-docs.sh | ||
gen-sql-api-docs.py | ||
gen-sql-config-docs.py | ||
gen-sql-functions-docs.py | ||
mkdocs.yml | ||
README.md |
Spark SQL
This module provides support for executing relational queries expressed in either SQL or the DataFrame/Dataset API.
Spark SQL is broken up into four subprojects:
- Catalyst (sql/catalyst) - An implementation-agnostic framework for manipulating trees of relational operators and expressions.
- Execution (sql/core) - A query planner / execution engine for translating Catalyst's logical query plans into Spark RDDs. This component also includes a new public interface, SQLContext, that allows users to execute SQL or LINQ statements against existing RDDs and Parquet files.
- Hive Support (sql/hive) - Includes extensions that allow users to write queries using a subset of HiveQL and access data from a Hive Metastore using Hive SerDes. There are also wrappers that allow users to run queries that include Hive UDFs, UDAFs, and UDTFs.
- HiveServer and CLI support (sql/hive-thriftserver) - Includes support for the SQL CLI (bin/spark-sql) and a HiveServer2 (for JDBC/ODBC) compatible server.
Running ./sql/create-docs.sh
generates SQL documentation for built-in functions under sql/site
, and SQL configuration documentation that gets included as part of configuration.md
in the main docs
directory.