Github user dongjoon-hyun commented on a diff in the pull request:
https://github.com/apache/spark/pull/22868#discussion_r229059209
--- Diff: docs/sql-migration-guide-hive-compatibility.md ---
@@ -51,6 +51,22 @@ Spark SQL supports the vast majority of Hive features,
such as:
* Explain
* Partitioned tables including dynamic partition insertion
* View
+ * If column aliases are not specified in view definition queries, both
Spark and Hive will
+ generate alias names, but in different ways. In order for Spark to be
able to read views created
+ by Hive, users should explicitly specify column aliases in view
definition queries. As an
+ example, Spark cannot read `v1` created as below by Hive.
+
+ ```
+ CREATE TABLE t1 (c1 INT, c2 STRING);
+ CREATE VIEW v1 AS SELECT * FROM (SELECT c1 + 1, upper(c2) FROM t1) t2;
+ ```
+
+ Instead, you should create `v1` as below with column aliases
explicitly specified.
+
+ ```
+ CREATE VIEW v1 AS SELECT * FROM (SELECT c1 + 1 AS inc_c1, upper(c2) AS
upper_c2 FROM t1) t2;
--- End diff --
Also, let's update this one together.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]