You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Hyukjin Kwon (JIRA)" <ji...@apache.org> on 2019/05/21 04:14:42 UTC

[jira] [Resolved] (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:all-tabpanel ]

Hyukjin Kwon resolved SPARK-21674.
----------------------------------
    Resolution: Incomplete

> 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: bulk-closed, 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
(v7.6.3#76005)

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