GitHub user maropu opened a pull request: https://github.com/apache/spark/pull/18938
[SPARK-21363][SQL] Prevent name duplication in (global/local) temporary views ## What changes were proposed in this pull request? This pr prevented name duplication in (global/local) temporary views. Currently, the master only prevents the duplication in permanent views, for example: ``` // Permanent view case scala> sql("CREATE VIEW t AS SELECT * FROM VALUES (1, 2), (2, 3) t(a, a)") org.apache.spark.sql.AnalysisException: Found duplicate column(s) in the view definition: `a`; scala> sql("CREATE VIEW t AS SELECT * FROM VALUES (1, 2), (2, 3) t(a, b)") scala> sql("SELECT * FROM t").show +---+---+ | a| b| +---+---+ | 1| 2| | 2| 3| +---+---+ scala> sql("ALTER VIEW t AS SELECT * FROM VALUES (4, 5), (5, 6) t(b, b)") org.apache.spark.sql.AnalysisException: Found duplicate column(s) in the view definition: `b`; // Local temporary view case scala> sql("CREATE TEMPORARY VIEW t AS SELECT * FROM VALUES (1, 2), (2, 3) t(a, a)") scala> sql("SELECT * FROM t").show +---+---+ | a| a| +---+---+ | 1| 2| | 2| 3| +---+---+ scala> sql("ALTER VIEW t AS SELECT * FROM VALUES (4, 5), (5, 6) t(b, b)") scala> sql("SELECT * FROM t").show +---+---+ | b| b| +---+---+ | 4| 5| | 5| 6| +---+---+ // Global temporary view case scala> sql("CREATE GLOBAL TEMPORARY VIEW t AS SELECT * FROM VALUES (1, 2), (2, 3) t(a, a)") scala> sql("SELECT * FROM global_temp.t").show +---+---+ | a| a| +---+---+ | 1| 2| | 2| 3| +---+---+ scala> sql("ALTER VIEW t AS SELECT * FROM VALUES (4, 5), (5, 6) t(b, b)") scala> sql("SELECT * FROM t").show +---+---+ | b| b| +---+---+ | 4| 5| | 5| 6| +---+---+ ``` This is a follow-up of SPARK-21363 though, this pr changed the existing behaviour. ## How was this patch tested? Modified the existing tests in `DDLSuite`. You can merge this pull request into a Git repository by running: $ git pull https://github.com/maropu/spark SPARK-21363 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/spark/pull/18938.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #18938 ---- commit cf68f6960180817530ef3755edfb0b426cb6cb77 Author: Takeshi Yamamuro <yamam...@apache.org> Date: 2017-08-14T09:21:28Z Prevent name duplication in (global/local) temporary views ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org