Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/22990#discussion_r232148583
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -2856,6 +2856,59 @@ class SQLQuerySuite extends QueryTest with
SharedSQLContext {
checkAnswer(sql("select 26393499451 / (1e6 * 1000)"),
Row(BigDecimal("26.3934994510000")))
}
}
+
+ test("self join with aliases on partitioned tables #1") {
+ withTempView("tmpView1", "tmpView2") {
+ withTable("tab1", "tab2") {
+ sql(
+ """
+ |CREATE TABLE `tab1` (`col1` INT, `TDATE` DATE)
+ |USING CSV
+ |PARTITIONED BY (TDATE)
+ """.stripMargin)
+ spark.table("tab1").where("TDATE >=
'2017-08-15'").createOrReplaceTempView("tmpView1")
+ sql("CREATE TABLE `tab2` (`TDATE` DATE) USING parquet")
+ sql(
+ """
+ |CREATE OR REPLACE TEMPORARY VIEW tmpView2 AS
+ |SELECT N.tdate, col1 AS aliasCol1
+ |FROM tmpView1 N
+ |JOIN tab2 Z
+ |ON N.tdate = Z.tdate
+ """.stripMargin)
+ withSQLConf(SQLConf.AUTO_BROADCASTJOIN_THRESHOLD.key -> "0") {
+ sql("SELECT * FROM tmpView2 x JOIN tmpView2 y ON x.tdate =
y.tdate").collect()
+ }
+ }
+ }
+ }
+
+ test("self join with aliases on partitioned tables #2") {
+ withTempView("tmp") {
+ withTable("tab1", "tab2") {
+ sql(
+ """
+ |CREATE TABLE `tab1` (`EX` STRING, `TDATE` DATE)
+ |USING parquet
+ |PARTITIONED BY (tdate)
+ """.stripMargin)
+ sql("CREATE TABLE `tab2` (`TDATE` DATE) USING parquet")
+ sql(
+ """
+ |CREATE OR REPLACE TEMPORARY VIEW TMP as
+ |SELECT N.tdate, EX AS new_ex
+ |FROM tab1 N
+ |JOIN tab2 Z
+ |ON N.tdate = Z.tdate
--- End diff --
nit: `ON N.tdate = Z.tdate`
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]