flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "thinktothings (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-11919) Exception in thread "main" org.apache.flink.table.api.SqlParserException: SQL parse failed. Encountered "FROM user" at line 1, column 17.
Date Fri, 15 Mar 2019 01:25:00 GMT

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

thinktothings commented on FLINK-11919:
---------------------------------------

 some string combinations are already reserved as keywords for future use. If you want to
use one of the following strings as a field name, make sure to surround them with backticks
(e.g. {{`value`}}, {{`count`}}).

-----------------------------------------------------------------------------------------------

 

package com.opensourceteams.module.bigdata.flink.example.sql.dataset.user

import org.apache.flink.api.scala.\{ExecutionEnvironment, _}
import org.apache.flink.table.api.TableEnvironment
import org.apache.flink.table.api.scala._

object Run {



 def main(args: Array[String]): Unit = {


 //得到批环境
 val env = ExecutionEnvironment.getExecutionEnvironment


 val dataSet = env.fromElements(("小明",15,"男"),("小李",25,"女"))

 //得到Table环境
 val tableEnv = TableEnvironment.getTableEnvironment(env)
 //注册table
 tableEnv.registerDataSet("user",dataSet,'name,'age,'sex)



 //系统保留的关键字,是需要加 ` 来使用
 tableEnv.sqlQuery(s"select name,age FROM `user` ")
 .first(100).print()


 }

}

> Exception in thread "main" org.apache.flink.table.api.SqlParserException: SQL parse failed.
Encountered "FROM user" at line 1, column 17.
> -----------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-11919
>                 URL: https://issues.apache.org/jira/browse/FLINK-11919
>             Project: Flink
>          Issue Type: Bug
>          Components: API / Table SQL
>    Affects Versions: 1.7.2
>         Environment: os: mac 0.14.3 
> java: 1.8.0_191
> scala: 2.11.12
> code: https://github.com/opensourceteams/flink-maven-scala/blob/master/src/main/scala/com/opensourceteams/module/bigdata/flink/example/sql/user/Run.scala
>  
>            Reporter: thinktothings
>            Priority: Blocker
>         Attachments: image-2019-03-14-17-41-43-840.png
>
>
> Register table name, can not use user, use other names, such as user1 can be normal
>  
>  
> ===========================================================
> package com.opensourceteams.module.bigdata.flink.example.tableapi.test
> import org.apache.flink.api.scala.ExecutionEnvironment
> import org.apache.flink.table.api.scala._
> import org.apache.flink.api.scala._
> import org.apache.flink.table.api.TableEnvironment
> object Run {
>  def main(args: Array[String]): Unit = {
>  //得到批环境
>  val env = ExecutionEnvironment.getExecutionEnvironment
>  val dataSet = env.fromElements(("小明",15,"男"),("小李",25,"女"))
>  //得到Table环境
>  val tableEnv = TableEnvironment.getTableEnvironment(env)
>  //注册table
>  tableEnv.registerDataSet("user",dataSet,'name,'age,'sex)
>  tableEnv.sqlQuery(s"select name,age FROM user")
>  .first(100).print()
>  }
> }
>  
> ===========================================================
>  
> Exception in thread "main" org.apache.flink.table.api.SqlParserException: SQL parse failed.
Encountered "FROM user" at line 1, column 17.
> Was expecting one of:
>  <EOF> 
>  "ORDER" ...
>  "LIMIT" ...
>  "OFFSET" ...
>  "FETCH" ...
>  "FROM" <IDENTIFIER> ...
>  "FROM" <QUOTED_IDENTIFIER> ...
>  "FROM" <BACK_QUOTED_IDENTIFIER> ...
>  "FROM" <BRACKET_QUOTED_IDENTIFIER> ...
>  "FROM" <UNICODE_QUOTED_IDENTIFIER> ...
>  "FROM" "LATERAL" ...
>  "FROM" "(" ...
>  "FROM" "UNNEST" ...
>  "FROM" "TABLE" ...
>  "," ...
>  "AS" ...
>  <IDENTIFIER> ...
>  <QUOTED_IDENTIFIER> ...
>  <BACK_QUOTED_IDENTIFIER> ...
>  <BRACKET_QUOTED_IDENTIFIER> ...
>  <UNICODE_QUOTED_IDENTIFIER> ...
>  "." ...
>  "NOT" ...
>  "IN" ...
>  "<" ...
>  "<=" ...
>  ">" ...
>  ">=" ...
>  "=" ...
>  "<>" ...
>  "!=" ...
>  "BETWEEN" ...
>  "LIKE" ...
>  "SIMILAR" ...
>  "+" ...
>  "-" ...
>  "*" ...
>  "/" ...
>  "%" ...
>  "||" ...
>  "AND" ...
>  "OR" ...
>  "IS" ...
>  "MEMBER" ...
>  "SUBMULTISET" ...
>  "CONTAINS" ...
>  "OVERLAPS" ...
>  "EQUALS" ...
>  "PRECEDES" ...
>  "SUCCEEDS" ...
>  "MULTISET" ...
>  "[" ...
>  "UNION" ...
>  "INTERSECT" ...
>  "EXCEPT" ...
>  "MINUS" ...
>  "(" ...
>  
>  at org.apache.flink.table.calcite.FlinkPlannerImpl.parse(FlinkPlannerImpl.scala:94)
>  at org.apache.flink.table.api.TableEnvironment.sqlQuery(TableEnvironment.scala:743)
>  at com.opensourceteams.module.bigdata.flink.example.tableapi.test.Run$.main(Run.scala:28)
>  at com.opensourceteams.module.bigdata.flink.example.tableapi.test.Run.main(Run.scala)
>  
>  
> =======================================================
>  
>  
> !image-2019-03-14-17-41-43-840.png!



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

Mime
View raw message