MAPREDUCE服务 MRS-使用Spark客户端创建CarbonData表:在Spark-shell上使用CarbonData

时间:2024-06-29 16:25:13

在Spark-shell上使用CarbonData

用户若需要在Spark-shell上使用CarbonData,需通过如下方式创建CarbonData Table,加载数据到CarbonData Table和在CarbonData中查询数据的操作。

spark.sql("CREATE TABLE x2(imei string, deviceInformationId int, mac string, productdate timestamp, updatetime timestamp, gamePointId double, contractNumber double) STORED AS carbondata")
spark.sql("LOAD DATA inpath 'hdfs://hacluster/data/x1_without_header.csv' into table x2 options('DELIMITER'=',', 'QUOTECHAR'='\"','FILEHEADER'='imei, deviceinformationid,mac, productdate,updatetime, gamepointid,contractnumber')")
spark.sql("SELECT * FROM x2").show()
support.huaweicloud.com/cmpntguide-mrs/mrs_01_1406.html