[英]If Spark SQL support HQL like 'insert overwrite directory'?
I would like to ask if Spark SQL support HQL like 'insert overwrite directory'. 我想问一下Spark SQL是否支持HQL,例如“插入覆盖目录”。 Or is there another way to save the Result set(from a spark sql jdbc server) to HDFS directly?
还是有另一种方法(从spark sql jdbc服务器)将结果集直接保存到HDFS?
There is one jira for this issue which is not yet resolved the jira link for that is https://issues.apache.org/jira/browse/SPARK-4131 . 此问题有一个jira尚未解决,因此该jira链接为https://issues.apache.org/jira/browse/SPARK-4131 。 But you can do something like this:
但是您可以执行以下操作:
JavaSchemaRDD employeeSchemaRDD = context.sql("SELECT * FROM employee");
JavaRDD<String> strRDD=employeeSchemaRDD.map(new Function<Row, String>() {
public String call(Row row) throws Exception {
// TODO Auto-generated method stub
return row.get(1).toString();
}
});
strRDD.saveAsTextFile("outputdir");
Replace outputdir with HDFS url where you want to write the output. 用要写入输出的HDFS url替换outputdir。 Hope this answer you question.
希望这个回答你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.