[ 
https://issues.apache.org/jira/browse/SPARK-25769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Simeon Simeonov updated SPARK-25769:
------------------------------------
    Description: 
 This issue affects dynamic SQL generation that relies on {{sql()}}.
{code:java}
import org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute

// The correct output is a.b, without backticks, or `a`.`b`.
$"a.b".expr.asInstanceOf[UnresolvedAttribute].sql
// res2: String = `a.b`

// Parsing is correct; the bug is localized to sql() 
$"a.b".expr.asInstanceOf[UnresolvedAttribute].nameParts 
// res1: Seq[String] = ArrayBuffer(a, b)
{code}
The likely culprit is that the {{sql()}} implementation does not check for 
{{nameParts}} being non-empty.
{code:java}
override def sql: String = name match { 
  case ParserUtils.escapedIdentifier(_) | 
ParserUtils.qualifiedEscapedIdentifier(_, _) => name 
  case _ => quoteIdentifier(name) 
}
{code}
 

  was:
 

This issue affects dynamic SQL generation that relies on {{sql()}}.

 
{code:java}
import org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute

// The correct output is a.b, without backticks, or `a`.`b`.
$"a.b".expr.asInstanceOf[UnresolvedAttribute].sql
// res2: String = `a.b`

// Parsing is correct; the bug is localized to sql() 
$"a.b".expr.asInstanceOf[UnresolvedAttribute].nameParts 
// res1: Seq[String] = ArrayBuffer(a, b)
{code}
 

The likely culprit is that the {{sql()}} implementation does not check for 
{{nameParts}} being non-empty.

 

 
{code:java}
override def sql: String = name match { 
  case ParserUtils.escapedIdentifier(_) | 
ParserUtils.qualifiedEscapedIdentifier(_, _) => name 
  case _ => quoteIdentifier(name) 
}
{code}
 


> UnresolvedAttribute.sql() incorrectly escapes nested columns
> ------------------------------------------------------------
>
>                 Key: SPARK-25769
>                 URL: https://issues.apache.org/jira/browse/SPARK-25769
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.3.2
>            Reporter: Simeon Simeonov
>            Priority: Major
>              Labels: sql
>
>  This issue affects dynamic SQL generation that relies on {{sql()}}.
> {code:java}
> import org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute
> // The correct output is a.b, without backticks, or `a`.`b`.
> $"a.b".expr.asInstanceOf[UnresolvedAttribute].sql
> // res2: String = `a.b`
> // Parsing is correct; the bug is localized to sql() 
> $"a.b".expr.asInstanceOf[UnresolvedAttribute].nameParts 
> // res1: Seq[String] = ArrayBuffer(a, b)
> {code}
> The likely culprit is that the {{sql()}} implementation does not check for 
> {{nameParts}} being non-empty.
> {code:java}
> override def sql: String = name match { 
>   case ParserUtils.escapedIdentifier(_) | 
> ParserUtils.qualifiedEscapedIdentifier(_, _) => name 
>   case _ => quoteIdentifier(name) 
> }
> {code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@spark.apache.org
For additional commands, e-mail: issues-h...@spark.apache.org

Reply via email to