
# OBS上的数据准备
#### 操作场景
使用SQL on OBS功能查询OBS数据之前：
1. 已将ORC数据存储在OBS上。 例如，在使用Hive或Spark等组件时创建了ORC表，其表数据已经存储在OBS上的场景。
   假设有2个ORC数据文件"product_info.0"和"product_info.1"，其原始数据如[原始数据]所示，都已经存储在OBS桶"mybucket"的"demo.db/product_info_orc/"目录中。
   
2. 如果数据文件已经在OBS上了，请执行[获取源数据的OBS路径并设置读取权限]中的步骤。
   ![](https://support.huaweicloud.com/migration-dws/public_sys-resources/note_3.0-zh-cn.png)
   本小节以导入ORC格式为例，CARBONDATA、PARQUET和JSON数据的导入方法与ORC格式相似。
   
 
 #### 原始数据
假设您已将2个ORC数据文件存储在OBS上，其原始数据分别如下：
- 数据文件"product_info.0" 示例数据如下所示：
  ```
  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.
  ```
  
- 数据文件"product_info.1" 示例数据如下所示：
  ```
  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.
  ```
  
 
 #### 获取源数据的OBS路径并设置读取权限
1. [登录OBS控制台](https://console.huaweicloud.com/obs)。
   
   单击"服务列表"，选择"对象存储服务"，打开OBS管理控制台页面。
   
   
2. 获取数据源文件的OBS路径。 
   数据源文件在上传到OBS桶之后，会生成全局唯一的访问路径。在创建外表时需要指定数据源文件的OBS路径。
   
   如何查看OBS路径，请参见《对象存储服务控制台指南》的[通过对象URL访问对象](https://support.huaweicloud.com/usermanual-obs/obs_03_0319.html)章节。
   例如，在本例中，查看到数据文件的OBS路径分别为：
   ```
   https://obs.cn-north-1.myhuaweicloud.com/mybucket/demo.db/product_info_orc/product_info.0
   https://obs.cn-north-1.myhuaweicloud.com/mybucket/demo.db/product_info_orc/product_info.1
   ```
   
   
3. 为用户设置OBS桶的读取权限。 
   在使用SQL on OBS功能时，执行该功能的用户需要取得数据源文件所在OBS桶的读取权限。通过配置桶的ACL权限，可以将读取权限授予指定的用户账号。
   
   具体请参见《对象存储服务控制台指南》中的[配置桶ACL](https://support.huaweicloud.com/usermanual-obs/obs_03_0326.html)章节。
   
   
 
