You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Chin Han Yu (JIRA)" <ji...@apache.org> on 2017/08/21 03:38:00 UTC

[jira] [Comment Edited] (SPARK-21674) Support double/single-quoted strings for alias names in SQL

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

Chin Han Yu edited comment on SPARK-21674 at 8/21/17 3:37 AM:
--------------------------------------------------------------

Hi, I would like to work on this ticket. 
Since it's common to use double quotes or single quotes to escape reserved word as a column name or alias name to PostgreSQL/MySQL users, this improvement may be helpful. 


was (Author: byakuinss):
Hi, I would like to work on this ticket. 
Since it's common to use double quotes or single quotes to escape reserved word as a column name to PostgreSQL/MySQL users, this improvement may be helpful. 

> Support double/single-quoted strings for alias names in SQL
> -----------------------------------------------------------
>
>                 Key: SPARK-21674
>                 URL: https://issues.apache.org/jira/browse/SPARK-21674
>             Project: Spark
>          Issue Type: Improvement
>          Components: SQL
>    Affects Versions: 2.2.0
>            Reporter: Takeshi Yamamuro
>            Priority: Trivial
>              Labels: starter
>
> In the master, users can't use single/double-quoted strings for alias names in SQL;
> {code}
> scala> sql("""SELECT 1 AS "NAME" """)
> org.apache.spark.sql.catalyst.parser.ParseException:
> extraneous input '"NAME"' expecting {<EOF>, ',', 'FROM', 'WHERE', 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LATERAL', 'WINDOW', 'UNION', 'EXCEPT', 'MINUS', 'INTERSECT', 'SORT', 'CLUSTER', 'DISTRIBUTE'}(line 1, pos 12)
> == SQL ==
> SELECT 1 AS "NAME"
> ------------^^^
>   at org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:217)
>   at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:114)
> ...
> {code}
> PostgreSQL and MySQL support this;
> {code}
> ~:$psql -d postgres
> psql (9.5beta1)
> Type "help" for help.
> postgres=# select 1 AS "NAME";
>  NAME 
> ------
>     1
> (1 row)
> mysql> select 1 AS "NAME";
> +------+
> | NAME |
> +------+
> |    1 |
> +------+
> 1 row in set (0.00 sec)
> {code}
> Hive does not;
> {code}
> hive> select 1 AS "NAME";
> NoViableAltException(352@[87:7: ( ( ( KW_AS )? identifier ) | ( KW_AS LPAREN identifier ( COMMA identifier )* RPAREN ) )?])
> 	at org.antlr.runtime.DFA.noViableAlt(DFA.java:158)
> 	at org.antlr.runtime.DFA.predict(DFA.java:116)
> {code}
> Trivial though, it might some help for PostgreSQL/MySQL users.



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