使用Spark SQL的Cassandra简单插入语句因org.apache.spark.sql.catalyst.parser.ParseException失败 [英] Cassandra Simple Insert Statement using Spark SQL Fails with org.apache.spark.sql.catalyst.parser.ParseException

查看:1543
本文介绍了使用Spark SQL的Cassandra简单插入语句因org.apache.spark.sql.catalyst.parser.ParseException失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用Spark SQL将数据插入Cassandra表中,如下所示:

I'm trying to insert data into Cassandra table with Spark SQL as follows:

String query = "CREATE TEMPORARY TABLE my_table USING org.apache.spark.sql.cassandra OPTIONS (table \"my_table\",keyspace \"my_keyspace\", pushdown \"true\")";
                spark.sparkSession.sql(query);
                spark.sparkSession
                                .sql("INSERT INTO my_keyspace.my_table (column0, column1) VALUES ('value0', 'value1');

但是,它失败,但出现以下异常: E

however, it fails with the following exception: E

xception in thread "main" org.apache.spark.sql.catalyst.parser.ParseException:
mismatched input 'column0' expecting {'(', 'SELECT', 'FROM', 'VALUES', 'TABLE', 'INSERT', 'MAP', 'REDUCE'}(line 1, pos 33)

我尝试了不使用列名的方法,并且可以正常工作. 我的意思是要为某些列而不是所有列插入数据.

I tried it without the column names and it worked. My point here is to insert data for some columns, not all of them.

推荐答案

Spark SQL与CQL使用的语法不同,它们是不同的语言.查看HiveQL参考以获取更多信息.

Spark SQL does not use the same syntax as CQL they are different languages. Check HiveQL references for more information.

一个警告,通过SparkSql单行插入将非常慢.它是为大型多记录(百万)插入而制作的.

One warning, doing single row inserts through SparkSql will be very slow. It is made for large multi record (millions) inserts.

这篇关于使用Spark SQL的Cassandra简单插入语句因org.apache.spark.sql.catalyst.parser.ParseException失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆