赞
踩
For SQL query in Spark.
For read, we can read jdbc by
CREATE TEMPORARY TABLE jdbcTable
USING org.apache.spark.sql.jdbc
OPTIONS dbtable ...;
For write, what is the query to write the data to the remote JDBC table using SQL?
NOTE: I want it to be SQL query.
plz provide the pure "SQL query" that can write to jdbc when using HiveContext.sql(...) of SparkSQL.
解决方案
An INSERT OVERWRITE TABLE will write to your database using the JDBC connection:
DROP TABLE IF EXISTS jdbcTemp;
CREATE TABLE jdbcTemp
USING org.apache.spark.sql.jdbc
OPTIONS (...);
INSERT OVERWRITE TABLE jdbcTemp
SELECT * FROM my_spark_data;
DROP TABLE jdbcTemp;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。