Broker导出案例
测试表创建
-- doris源表创建 CREATE TABLE export_test01 ( `id` varchar(1000) NULL COMMENT "来源库表键", `test01` BIGINT SUM DEFAULT "0" COMMENT "测试" ) ENGINE=OLAP AGGREGATE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default: 1", "in_memory" = "false", "storage_format" = "V2" ); -- hive目标表创建 CREATE EXTERNAL TABLE zbh_test.export_test01 ( `id` varchar(1000) comment 'id', `test01` bigint comment 'tf') comment '表备注' row format delimited fields terminated by ',' stored as textfile;
数据初始化
-- doris insert into export_test01 values (1,1),(2,3),(1,2),(3,2) select * from export_test01;
导出任务创建
EXPORT TABLE zbh_test.export_test01 TO "hdfs://doris:9000/user/hive/warehouse/zbh_test.db/export_test01" PROPERTIES ( "column_separator"=",", "load_mem_limit"="2147483648", "timeout" = "3600" ) WITH BROKER "broker_name" ( "username" = "hadoop", "password" = "" );
结果验证
SHOW EXPORT
OutFile案例
测试表创建
-- doris源表创建 CREATE TABLE export_test02 ( `id` varchar(1000) NULL COMMENT "来源库表键", `test01` BIGINT SUM DEFAULT "0" COMMENT "测试" ) ENGINE=OLAP AGGREGATE KEY(`id`) DISTRIBUTED BY HASH(`id`) BUCKETS 1 PROPERTIES ( "replication_allocation" = "tag.location.default: 1", "in_memory" = "false", "storage_format" = "V2" ); -- hive目标表创建 CREATE EXTERNAL TABLE zbh_test.export_test02 ( `id` varchar(1000) comment 'id', `test01` bigint comment 'tf') comment '表备注' row format delimited fields terminated by ',' stored as textfile;
数据初始化
-- doris insert into export_test02 values (2,1),(2,3),(3,2),(3,2) select * from export_test02
导出任务创建
SELECT * FROM export_test02 INTO OUTFILE "hdfs://doris:9000/user/hive/warehouse/zbh_test.db/export_test02/result_" FORMAT AS CSV PROPERTIES ( "broker.name" = "broker_name", "column_separator" = ",", "line_delimiter" = "\n", "broker.username"="hadoop", "broker.password"="" );
结果验证
select into outfile 为同步命令,导出后会直接显示结果
broker常用的broker load、export和select into outfile快速体验至此结束,体验过程中若遇到问题欢迎留言交流