MapReduce服务 MRS-Hive分区表支持OBS和HDFS存储源:操作示例
操作示例
- 以Hive客户端安装用户登录安装客户端的节点。
- 执行以下命令,切换到客户端安装目录。
例如安装目录为“/opt/client”,则执行以下命令:
cd /opt/client
- 执行以下命令配置环境变量。
- 集群认证模式是否为安全模式。
- 是,执行以下命令进行用户认证:
- 否,执行5。
- 执行以下命令登录Hive客户端。
- 执行如下命令创建Hive分区表“table_1”,指定分区“pt='2021-12-12'”的路径为“hdfs//xxx”,指定分区“pt='2021-12-18'”的路径为“obs://xxx”:
create table table_1(id string) partitioned by(pt string) [stored as [orc|textfile|parquet|...]];
alter table table_1 add partition(pt='2021-12-12') location 'hdfs://xxx';
alter table table_1 add partition(pt='2021-12-18') location 'obs://xxx';
- 给分区表“table_1”中插入数据后,对应的分区数据存储在对应的存储源上,可以使用desc查看分区的location,执行以下命令查看路径下的数据:
desc formatted table_1 partition(pt='2021-12-18');