MapReduce服务 MRS-LOAD:示例

时间:2023-11-01 16:25:24

示例

创建文件“f1.txt”,填入3行数字,并通过HDFS上传到“/opt/load_test/”目录下。

--读取f1.txt的数据填充表f1CREATE TABLE tb_load_f1(id int) with (format='TEXTFILE'); LOAD DATA INPATH '/opt/load_test/f1.txt' into table tb_load_f1; select * from tb_load_f1; id ----  1   2   3 (3 rows) --读取/opt/load_test/目录下的文件,填充表f2CREATE TABLE tb_load_f2(id int) with (format='TEXTFILE'); LOAD DATA INPATH '/opt/load_test/' into table tb_load_f2; select * from tb_load_f2; id ----  1   2   3 (3 rows) --读取f3.txt文件内容填充表f3(多字段,数据分割符为'-'),并通过HDFS上传到/opt/load_test/ 目录下,f3.txt文件内容如下: 1-n1 2-n2-- 创建目标表tb_load_f3CREATE TABLE tb_load_f3(id int,name varchar) with(format='TEXTFILE',textfile_field_separator='-'); Load data inpath '/opt/load_test/f3.txt' into table tb_load_f3; Select * from tb_load_f3;id | name ----|------  1 | n1     2 | n2   (2 rows)
support.huaweicloud.com/cmpntguide-lts-mrs/mrs_01_249059.html