我使用星火2.1在Azure (HDInsight)与木星笔记本。
我不能在一个笔记本单元里创建多个表。
以下查询工作良好:
%%sql
create table if not exists temp1(Col varchar(32))
返回:没有结果。
以下查询在单个单元格中不起作用:
%%sql
create table if not exists temp2(Col varchar(32))
create table if not exists temp3(Col varchar(32))
遇到一个错误: org.apache.spark.sql.catalyst.parser.ParseException:不匹配的输入“create”期望(第3行,pos 0) == SQL == 如果不存在创建表,则为temp2((32)),如果不存在,则创建temp3((32))^ 在org.apache.spark.sql.catalyst.parser.ParseException.withCommand(ParseDriver.scala:197) at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parse(ParseDriver.scala:99) at org.apache.spark.sql.execution.SparkSqlParser.parse(SparkSqlParser.scala:45) at org.apache.spark.sql.catalyst.parser.AbstractSqlParser.parsePlan(ParseDriver.scala:53) at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:592) 47
如何在一个单元格中创建多个表?
发布于 2017-05-12 01:06:34
看来,带sql
解释器的木星中的单个单元格对应于Spark执行的单个SQL查询。
一个可能的解决办法是使用spark
解释器(或scala
)并在spark.sql
中执行SQL语句,如下所示:
%%spark
spark.sql("create table if not exists temp2(Col varchar(32))")
spark.sql("create table if not exists temp3(Col varchar(32))")
这应该是可行的。
https://stackoverflow.com/questions/43933046
复制相似问题