为什么Zeppelin因“输入不匹配”而失败;'期待 “在%spark.sql段落?

问题描述 投票:2回答:1

我已经从csv构建了一个镶木地板文件。

在Zeppelin中,我创建了一个sql语句,如:

%spark.sql
DROP TABLE IF EXISTS df;
CREATE TABLE df (
    date_time STRING
  , site_name STRING
  , posa_continent STRING
  , user_location_country STRING
  , user_location_region STRING
  , user_location_city STRING
  , orig_destination_distance DOUBLE
  , user_id STRING
  , is_mobile STRING
  , is_package STRING
  , channel STRING
  , srch_ci STRING
  , srch_co STRING
  , srch_adults_cnt INT 
  , srch_children_cnt INT
  , srch_rm_cnt INT
  , srch_destination_id STRING
  , srch_destination_type_id STRING
  , is_booking STRING
  , cnt INT
  , hotel_continentm STRING
  , hotel_country STRING
  , hotel_market STRING
  , hotel_cluster STRING)
USING parquet
OPTIONS (path "s3://hansprojekt/training_17000000pq")

结果我收到一个错误:

mismatched input ';' expecting <EOF>(line 1, pos 23)
== SQL ==
DROP TABLE IF EXISTS df;
-----------------------^^^
CREATE TABLE df (
    date_time STRING
  , site_name STRING
  , posa_continent STRING
  , user_location_country STRING
  , user_location_region STRING
  , user_location_city STRING
  , orig_destination_distance DOUBLE
  , user_id STRING
  , is_mobile STRING
  , is_package STRING
  , channel STRING
  , srch_ci STRING
  , srch_co STRING
  , srch_adults_cnt INT 
  , srch_children_cnt INT
  , srch_rm_cnt INT
  , srch_destination_id STRING
  , srch_destination_type_id STRING
  , is_booking STRING
  , cnt INT
  , hotel_continent STRING
  , hotel_country STRING
  , hotel_market STRING
  , hotel_cluster STRING)
USING parquet
OPTIONS (path "s3://hansprojekt/training_17000000pq")
set zeppelin.spark.sql.stacktrace = true to see full stacktrace

我不明白这个问题。 csv用','分隔。

有人可以帮帮我吗?

apache-spark apache-spark-sql parquet apache-zeppelin
1个回答
1
投票

在Zeppelin的paragraph中的%spark.sql(又名代码部分)使用一个SQL语句。

所以,这一行在一个段落中:

DROP TABLE IF EXISTS df;

和另一个%spark.sql段中的那个。

CREATE TABLE df (
    date_time STRING
  , site_name STRING
  , posa_continent STRING
  , user_location_country STRING
  , user_location_region STRING
  , user_location_city STRING
  , orig_destination_distance DOUBLE
  , user_id STRING
  , is_mobile STRING
  , is_package STRING
  , channel STRING
  , srch_ci STRING
  , srch_co STRING
  , srch_adults_cnt INT 
  , srch_children_cnt INT
  , srch_rm_cnt INT
  , srch_destination_id STRING
  , srch_destination_type_id STRING
  , is_booking STRING
  , cnt INT
  , hotel_continentm STRING
  , hotel_country STRING
  , hotel_market STRING
  , hotel_cluster STRING)
USING parquet
OPTIONS (path "s3://hansprojekt/training_17000000pq")

qazxsw poi qazxsw poi(来自qazxsw poi)。

如果我没有弄错,当要求结果时,%spark.sql只执行provides a SQL environment using Spark SQL

SparkSQLInterpreter

这指向SparkSQLInterpreter作为“执行环境”。

sql(sqlText:String):DataFrame使用Spark执行SQL查询,将结果作为DataFrame返回。

SQLContext.sql期望一个SQL语句。

© www.soinside.com 2019 - 2024. All rights reserved.