You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Haris (JIRA)" <ji...@apache.org> on 2018/01/06 08:13:00 UTC

[jira] [Commented] (SPARK-7551) Don't split by dot if within backticks for DataFrame attribute resolution

    [ https://issues.apache.org/jira/browse/SPARK-7551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16314443#comment-16314443 ] 

Haris commented on SPARK-7551:
------------------------------

I encountered a similar problem in spark 2,2 while using pyspark, I tried to split a column with period (.) and it did not behave well even after providing escape chars:

{code}

>>> spark.sql("select split('a.aaa','.')").show()
+---------------+
|split(a.aaa, .)|
+---------------+
|   [, , , , , ]|
+---------------+

>>> spark.sql("select split('a.aaa','\\.')").show()
+---------------+
|split(a.aaa, .)|
+---------------+
|   [, , , , , ]|
+---------------+

>>> spark.sql("select split('a.aaa','[.]')").show()
+-----------------+
|split(a.aaa, [.])|
+-----------------+
|         [a, aaa]|
+-----------------+
{code}

It uses period only when we provide it like {code} [.] {code}  while it should also be working with escape seq {code}'\\.'{code}

> Don't split by dot if within backticks for DataFrame attribute resolution
> -------------------------------------------------------------------------
>
>                 Key: SPARK-7551
>                 URL: https://issues.apache.org/jira/browse/SPARK-7551
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>            Reporter: Reynold Xin
>            Assignee: Wenchen Fan
>            Priority: Critical
>             Fix For: 1.4.0
>
>
> DataFrame's resolve:
> {code}
>   protected[sql] def resolve(colName: String): NamedExpression = {
>     queryExecution.analyzed.resolve(colName.split("\\."), sqlContext.analyzer.resolver).getOrElse {
>       throw new AnalysisException(
>         s"""Cannot resolve column name "$colName" among (${schema.fieldNames.mkString(", ")})""")
>     }
>   }
> {code}
> We should not split the parts quoted by backticks (`).
> For example, `ab.cd`.`efg` should be split into two parts "ab.cd" and "efg". 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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