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

    https://github.com/apache/spark/pull/11171#discussion_r52714530
  
    --- Diff: 
sql/hive/src/main/scala/org/apache/spark/sql/hive/SQLBuilder.scala ---
    @@ -37,157 +39,137 @@ import 
org.apache.spark.sql.execution.datasources.LogicalRelation
     class SQLBuilder(logicalPlan: LogicalPlan, sqlContext: SQLContext) extends 
Logging {
       def this(df: DataFrame) = this(df.queryExecution.analyzed, df.sqlContext)
     
    -  def toSQL: Option[String] = {
    +  def toSQL: String = {
         val canonicalizedPlan = Canonicalizer.execute(logicalPlan)
    -    val maybeSQL = try {
    -      toSQL(canonicalizedPlan)
    -    } catch { case cause: UnsupportedOperationException =>
    -      logInfo(s"Failed to build SQL query string because: 
${cause.getMessage}")
    -      None
    -    }
    -
    -    if (maybeSQL.isDefined) {
    +    try {
    +      val generatedSQL = toSQL(canonicalizedPlan)
           logDebug(
             s"""Built SQL query string successfully from given logical plan:
    -           |
    -           |# Original logical plan:
    -           |${logicalPlan.treeString}
    -           |# Canonicalized logical plan:
    -           |${canonicalizedPlan.treeString}
    -           |# Built SQL query string:
    -           |${maybeSQL.get}
    +            |
    +            |# Original logical plan:
    +            |${logicalPlan.treeString}
    +            |# Canonicalized logical plan:
    +            |${canonicalizedPlan.treeString}
    +            |# Generated SQL:
    +            |$generatedSQL
              """.stripMargin)
    -    } else {
    +      generatedSQL
    +    } catch { case NonFatal(e) =>
           logDebug(
             s"""Failed to build SQL query string from given logical plan:
    -           |
    +            |
                |# Original logical plan:
    -           |${logicalPlan.treeString}
    -           |# Canonicalized logical plan:
    -           |${canonicalizedPlan.treeString}
    +            |${logicalPlan.treeString}
    +            |# Canonicalized logical plan:
    +            |${canonicalizedPlan.treeString}
    --- End diff --
    
    Nit: Indentation is off.


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