Github user dilipbiswal commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11596#discussion_r55475930
  
    --- Diff: 
sql/hive/src/test/scala/org/apache/spark/sql/hive/LogicalPlanToSQLSuite.scala 
---
    @@ -445,4 +461,98 @@ class LogicalPlanToSQLSuite extends SQLBuilderTest 
with SQLTestUtils {
           "f1", "b[0].f1", "f1", "c[foo]", "d[0]"
         )
       }
    +
    +  test("SQL generator for explode in projection list") {
    +    // Basic Explode
    +    checkHiveQl("SELECT explode(array(1,2,3)) FROM src")
    +
    +    // Explode with Alias
    +    checkHiveQl("SELECT explode(array(1,2,3)) as value FROM src")
    +
    +    // Explode without FROM
    +    checkHiveQl("select explode(array(1,2,3)) AS gencol")
    +
    +    // non-generated columns in projection list
    +    checkHiveQl("SELECT key as c1, explode(array(1,2,3)) as c2, value as 
c3 FROM t1")
    +  }
    +
    +  test("SQL generation for json_tuple as generator") {
    +    checkHiveQl("SELECT key, json_tuple(jstring, 'f1', 'f2', 'f3', 'f4', 
'f5') FROM parquet_t3")
    +  }
    +
    +  test("SQL generation for lateral views") {
    +    // Filter and OUTER clause
    +    checkHiveQl(
    +      """
    +        |SELECT key, value
    +        |FROM t1
    +        |LATERAL VIEW OUTER explode(value) gentab as gencol
    +        |WHERE key = 1
    +      """.stripMargin
    +    )
    +
    +    // single lateral view
    +    checkHiveQl(
    +      """
    +        |SELECT *
    +        |FROM t1
    +        |LATERAL VIEW explode(array(1,2,3)) gentab AS gencol
    +        |SORT BY key ASC, gencol ASC LIMIT 1
    +      """.stripMargin
    +    )
    +
    +    // multiple lateral views
    +    checkHiveQl(
    +      """
    +        |SELECT gentab2.*
    +        |FROM t1
    +        |LATERAL VIEW explode(array(array(1,2,3))) gentab1 AS gencol1
    +        |LATERAL VIEW explode(gentab1.gencol1) gentab2 AS gencol2 LIMIT 3
    +      """.stripMargin
    +    )
    +
    +    // No generated column aliases
    +    checkHiveQl(
    +      """SELECT gentab.*
    +        |FROM t1
    +        |LATERAL VIEW explode(map('key1', 100, 'key2', 200)) gentab limit 2
    +      """.stripMargin
    +    )
    +  }
    +
    +  test("SQL generation for lateral views in subquery") {
    +    // Subquries in FROM clause using Generate
    +    checkHiveQl(
    +      """
    +        |SELECT subq.gencol
    +        |FROM
    +        |(SELECT * from t1 LATERAL VIEW explode(value) gentab AS gencol) 
subq
    +      """.stripMargin)
    +
    +    checkHiveQl(
    +      """
    +        |SELECT subq.key
    +        |FROM
    +        |(SELECT key, value from t1 LATERAL VIEW explode(value) gentab AS 
gencol) subq
    +      """.stripMargin
    +    )
    +  }
    +
    +  test("SQL generation for UDTF") {
    --- End diff --
    
    OK. 


---
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

Reply via email to