spark写orc格式文件
在hive中建表格式存储格式为orc
创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:网站设计、做网站、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的舞钢网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!
create table user(id int,name string) stored as orc;
spark写文件
val jsons = "hdfs://localhost:9000/test/artist_orc.json" val people = sc.textFile(jsons) val schemaString = "id name" val schema = StructType(schemaString.split(" ").map(fieldName => {if(fieldName == "name") StructField(fieldName, StringType, true) else StructField(fieldName, IntegerType, true)})) val rowRDD = people.map(line=>{ JSONObject.fromObject(line) }).map(p => Row(new Integer(p.get("id").toString), p.get("name"))) val hiveContext = new org.apache.spark.sql.hive.HiveContext(sc) val peopleSchemaRDD = hiveContext.createDataFrame(rowRDD, schema) peopleSchemaRDD.write.format("orc").save("hdfs://localhost:9000/user/xb/warehouse/artist_orc/adf")
文章题目:spark写orc格式文件
本文URL:http://hbruida.cn/article/pdcspo.html