To access MRS Hive data from storage-compute decoupled data warehouse, including when Hive is connected to HDFS or OBS, create an external schema. This function is supported only by 9.1.0 and later versions.
Data Source |
Table Type |
Operation |
TEXT |
CSV |
PARQUET |
ORC |
|---|---|---|---|---|---|---|
HDFS |
Non-partitioned table |
SELECT |
√ |
√ |
√ |
√ |
INSERT/INSERT OVERWRITE |
x |
x |
√ |
√ |
||
Partitioned table |
SELECT |
√ |
√ |
√ |
√ |
|
INSERT/INSERT OVERWRITE |
x |
x |
√ |
√ |
||
OBS |
Non-partitioned table |
SELECT |
√ |
√ |
√ |
√ |
INSERT/INSERT OVERWRITE |
x |
x |
√ |
√ |
||
Partitioned table |
SELECT |
x |
x |
√ |
√ |
|
INSERT/INSERT OVERWRITE |
x |
x |
√ |
√ |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 100,XHDK-A-1293-#fJ3,2017-09-01,A,2017 Autumn New Shirt Women,red,M,328,2017-09-04,715,good 205,KDKE-B-9947-#kL5,2017-09-01,A,2017 Autumn New Knitwear Women,pink,L,584,2017-09-05,406,very good! 300,JODL-X-1937-#pV7,2017-09-01,A,2017 autumn new T-shirt men,red,XL,1245,2017-09-03,502,Bad. 310,QQPX-R-3956-#aD8,2017-09-02,B,2017 autumn new jacket women,red,L,411,2017-09-05,436,It's really super nice 150,ABEF-C-1820-#mC6,2017-09-03,B,2017 Autumn New Jeans Women,blue,M,1223,2017-09-06,1200,The seller's packaging is exquisite 200,BCQP-E-2365-#qE4,2017-09-04,B,2017 autumn new casual pants men,black,L,997,2017-09-10,301,The clothes are of good quality. 250,EABE-D-1476-#oB1,2017-09-10,A,2017 autumn new dress women,black,S,841,2017-09-15,299,Follow the store for a long time. 108,CDXK-F-1527-#pL2,2017-09-11,A,2017 autumn new dress women,red,M,85,2017-09-14,22,It's really amazing to buy 450,MMCE-H-4728-#nP9,2017-09-11,A,2017 autumn new jacket women,white,M,114,2017-09-14,22,Open the package and the clothes have no odor 260,OCDA-G-2817-#bD3,2017-09-12,B,2017 autumn new woolen coat women,red,L,2004,2017-09-15,826,Very favorite clothes 980,ZKDS-J-5490-#cW4,2017-09-13,B,2017 Autumn New Women's Cotton Clothing,red,M,112,2017-09-16,219,The clothes are small 98,FKQB-I-2564-#dA5,2017-09-15,B,2017 autumn new shoes men,green,M,4345,2017-09-18,5473,The clothes are thick and it's better this winter. 150,DMQY-K-6579-#eS6,2017-09-21,A,2017 autumn new underwear men,yellow,37,2840,2017-09-25,5831,This price is very cost effective 200,GKLW-l-2897-#wQ7,2017-09-22,A,2017 Autumn New Jeans Men,blue,39,5879,2017-09-25,7200,The clothes are very comfortable to wear 300,HWEC-L-2531-#xP8,2017-09-23,A,2017 autumn new shoes women,brown,M,403,2017-09-26,607,good 100,IQPD-M-3214-#yQ1,2017-09-24,B,2017 Autumn New Wide Leg Pants Women,black,M,3045,2017-09-27,5021,very good. 350,LPEC-N-4572-#zX2,2017-09-25,B,2017 Autumn New Underwear Women,red,M,239,2017-09-28,407,The seller's service is very good 110,NQAB-O-3768-#sM3,2017-09-26,B,2017 autumn new underwear women,red,S,6089,2017-09-29,7021,The color is very good 210,HWNB-P-7879-#tN4,2017-09-27,B,2017 autumn new underwear women,red,L,3201,2017-09-30,4059,I like it very much and the quality is good. 230,JKHU-Q-8865-#uO5,2017-09-29,C,2017 Autumn New Clothes with Chiffon Shirt,black,M,2056,2017-10-02,3842,very good |
Parameter |
Value |
|---|---|
Region |
Based on site requirements |
Data Redundancy Policy |
Single-AZ storage |
Bucket Name |
mrs-datasource |
Default Storage Class |
Standard |
Bucket Policy |
Private |
Default Encryption |
Disable |
Direct Reading |
Disable |
Enterprise Project |
default |
Tags |
N/A |
Perform this step when Hive interconnects with OBS. Skip this step when Hive interconnects with HDFS.

cd /opt/client
sh refreshConfig.sh /opt/client Full_path_of_client_configuration_file_package
In this tutorial, run the following command:
sh refreshConfig.sh /opt/client /tmp/MRS-client/MRS_Services_Client.tar
su - omm
cd /opt/client
source bigdata_env
If find: 'opt/client/Hudi': Permission denied is displayed, ignore it. This does not affect subsequent operations.
kinit MRS cluster user
1 | CREATE DATABASE demo; |
1 | USE demo; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | DROP TABLE product_info; CREATE TABLE product_info ( product_price int , product_id char(30) , product_time date , product_level char(10) , product_name varchar(200) , product_type1 varchar(20) , product_type2 char(10) , product_monthly_sales_cnt int , product_comment_time date , product_comment_num int , product_comment_content varchar(200) ) row format delimited fields terminated by ',' stored as TEXTFILE; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | DROP TABLE product_info_orc; CREATE TABLE product_info_orc ( product_price int , product_id char(30) , product_time date , product_level char(10) , product_name varchar(200) , product_type1 varchar(20) , product_type2 char(10) , product_monthly_sales_cnt int , product_comment_time date , product_comment_num int , product_comment_content varchar(200) ) row format delimited fields terminated by ',' stored as orc; |
1 | insert into product_info_orc select * from product_info; |
1 | select * from product_info_orc; |

Perform this step only when Hive interconnects with OBS. Skip this step when Hive interconnects with HDFS.
Hard-coded or plaintext AK and SK are risky. For security purposes, encrypt your AK and SK and store them in the configuration file or environment variables.
1 2 3 4 5 6 7 8 9 | CREATE SERVER obs_server FOREIGN DATA WRAPPER DFS_FDW OPTIONS ( address 'obs.example.com:5443', //Address for accessing OBS encrypt 'on', access_key '{AK value}', secret_access_key '{SK value}', type 'obs' ); |
1 | SELECT * FROM pg_foreign_server WHERE srvname='obs_server'; |
The server is successfully created if information similar to the following is displayed:
1 2 3 4 | srvname | srvowner | srvfdw | srvtype | srvversion | srvacl | srvoptions --------------------------------------------------+----------+--------+---------+------------+--------+--------------------------------------------------------------------------------------------------------------------- obs_server | 16476 | 14337 | | | | {address=obs.example.com:5443,type=obs,encrypt=on,access_key=***,secret_access_key=***} (1 row) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | //When interconnecting Hive with OBS: Set SERVER to the name of the external server created in , DATABASE to the database created on Hive, METAADDRESS to the IP address and port number of the Hive metastore service recorded in , and CONFIGURATION to the default configuration path of the MRS data source. DROP SCHEMA IF EXISTS ex1; CREATE EXTERNAL SCHEMA ex1 WITH SOURCE hive DATABASE 'demo' SERVER obs_server METAADDRESS '***.***.***.***:***' CONFIGURATION '/MRS/gaussdb/mrs_server' //When interconnecting Hive with HDFS: Set SERVER to mrs_server (name of the data source created in ), METAADDRESS to the IP address and port number of the Hive metastore service recorded in , and CONFIGURATION to the default configuration path of the MRS data source. DROP SCHEMA IF EXISTS ex1; CREATE EXTERNAL SCHEMA ex1 WITH SOURCE hive DATABASE 'demo' SERVER mrs_server METAADDRESS '***.***.***.***:***' CONFIGURATION '/MRS/gaussdb/mrs_server' |
1 2 3 4 5 6 | SELECT * FROM pg_namespace WHERE nspname='ex1'; SELECT * FROM pg_external_namespace WHERE nspid = (SELECT oid FROM pg_namespace WHERE nspname = 'ex1'); nspid | srvname | source | address | database | confpath | ensoptions | catalog --------------------------------------------------+----------+--------+---------+------------+--------+--------------------------------------------------------------------------------------------------------------------- 16393 | obs_server | hive | ***.***.***.***:*** | demo | *** | | (1 row) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | DROP TABLE IF EXISTS product_info; CREATE TABLE product_info ( product_price integer , product_id char(30) , product_time date , product_level char(10) , product_name varchar(200) , product_type1 varchar(20) , product_type2 char(10) , product_monthly_sales_cnt integer , product_comment_time date , product_comment_num integer , product_comment_content varchar(200) ) ; |
1 | INSERT INTO product_info SELECT * FROM ex1.product_info_orc; |
1 | SELECT * FROM product_info; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | DROP TABLE IF EXISTS product_info_export; CREATE TABLE product_info_export ( product_price integer , product_id char(30) , product_time date , product_level char(10) , product_name varchar(200) , product_type1 varchar(20) , product_type2 char(10) , product_monthly_sales_cnt integer , product_comment_time date , product_comment_num integer , product_comment_content varchar(200) ) ; INSERT INTO product_info_export SELECT * FROM product_info; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | DROP TABLE product_info_orc_export; CREATE TABLE product_info_orc_export ( product_price int , product_id char(30) , product_time date , product_level char(10) , product_name varchar(200) , product_type1 varchar(20) , product_type2 char(10) , product_monthly_sales_cnt int , product_comment_time date , product_comment_num int , product_comment_content varchar(200) ) row format delimited fields terminated by ',' stored as orc; |
1 | INSERT INTO ex1.product_info_orc_export SELECT * FROM product_info_export; |
1 | SELECT * FROM product_info_orc_export; |