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

Michael Armbrust commented on SPARK-2346:
-----------------------------------------

The goal of the SQL method is to provide something that is close to SQL-92, 
which explicitly disallows identifiers that start with numbers (as this makes 
expressions like 2e2 kind of ambiguous).  I think your query will work if you 
run it using the hive parser, using the hql method, instead.

> Register as table should not accept table names that start with numbers
> -----------------------------------------------------------------------
>
>                 Key: SPARK-2346
>                 URL: https://issues.apache.org/jira/browse/SPARK-2346
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 1.0.0
>            Reporter: Alexander Albul
>            Priority: Minor
>              Labels: starter
>             Fix For: 1.1.0
>
>
> Looks like *org.apache.spark.sql.catalyst.SqlParser* cannot parse table names 
> when they start from numbers.
> Steps to reproduce:
> {code:title=Test.scala|borderStyle=solid}
> case class Data(value: String)
> object Test {
>   def main(args: Array[String]) {
>     val sc = new SparkContext("local", "sql")
>     val sqlSc = new SQLContext(sc)
>     import sqlSc._
>     sc.parallelize(List(Data("one"), 
> Data("two"))).registerAsTable("123_table")
>     sql("SELECT * FROM '123_table'").collect().foreach(println)
>   }
> }
> {code}
> And here is an exception:
> {quote}
> Exception in thread "main" java.lang.RuntimeException: [1.15] failure: ``('' 
> expected but "123_table" found
> SELECT * FROM '123_table'
>               ^
>       at scala.sys.package$.error(package.scala:27)
>       at org.apache.spark.sql.catalyst.SqlParser.apply(SqlParser.scala:47)
>       at org.apache.spark.sql.SQLContext.parseSql(SQLContext.scala:70)
>       at org.apache.spark.sql.SQLContext.sql(SQLContext.scala:150)
>       at io.ubix.spark.Test$.main(Test.scala:24)
>       at io.ubix.spark.Test.main(Test.scala)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:606)
>       at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
> {quote}
> When i am changing from 123_table to table_123 problem disappears.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to