将 Spark 数据帧写入 Impala 表时出现语法错误
我想将 Spark 数据帧写入 Impala 表,但列类型上出现语法错误。
这是 Pyspark 中的代码示例:
df = spark.createDataFrame(
[
(1, 'row1'),
(2, 'row2'),
],
['col1', 'col2']
)
df.write.format('jdbc').option('url','jdbc:impala://172.25.0.1:21050/default').option('driver','com.cloudera.impala.jdbc41.Driver').option('dbtable','test').save()
这是出现的错误:
Caused by: com.cloudera.impala.support.exceptions.GeneralException: [Cloudera][ImpalaJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:ParseException: Syntax error in line 1:
CREATE TABLE test ("col1" BIGINT , "col2" TEXT )
^
Encountered: STRING LITERAL
Expected: DEFAULT, IDENTIFIER
CAUSED BY: Exception: Syntax error
), Query: CREATE TABLE test ("col1" BIGINT , "col2" TEXT ).
... 50 more
我尝试了多种替代方法来创建 Spark 数据帧和使用 JDBC 的写入模式,但我总是收到此错误。我该如何解决这个问题?
I want to write a Spark dataframe to an Impala table, but syntax errors occur on the types of the columns.
This is an example of the code in Pyspark:
df = spark.createDataFrame(
[
(1, 'row1'),
(2, 'row2'),
],
['col1', 'col2']
)
df.write.format('jdbc').option('url','jdbc:impala://172.25.0.1:21050/default').option('driver','com.cloudera.impala.jdbc41.Driver').option('dbtable','test').save()
And this is the error that appears:
Caused by: com.cloudera.impala.support.exceptions.GeneralException: [Cloudera][ImpalaJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:ParseException: Syntax error in line 1:
CREATE TABLE test ("col1" BIGINT , "col2" TEXT )
^
Encountered: STRING LITERAL
Expected: DEFAULT, IDENTIFIER
CAUSED BY: Exception: Syntax error
), Query: CREATE TABLE test ("col1" BIGINT , "col2" TEXT ).
... 50 more
I have tried numerous alternatives for creating the Spark dataframe and for writing mode using JDBC but I always get this error. How could I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论