日本熟妇hd丰满老熟妇,中文字幕一区二区三区在线不卡 ,亚洲成片在线观看,免费女同在线一区二区

Hive訪問(wèn)TableStore數(shù)據(jù)

本文通過(guò)示例為您介紹EMR Hive作業(yè)如何處理TableStore中的數(shù)據(jù)。

前提條件

使用限制

  • 本文操作僅適用于DataLake集群。

  • DataLake集群和TableStore實(shí)例須在相同地域下,通過(guò)EMR VPC內(nèi)網(wǎng)可以訪問(wèn)TableStore。

操作步驟

  1. 在EMR Master節(jié)點(diǎn)上創(chuàng)建一個(gè)目錄,同時(shí)將Hive訪問(wèn)TableStore所需的JAR包復(fù)制到該目錄。

    mkdir -p /path/to/tablestore/jars
    cp emr-tablestore-2.2.0.jar tablestore-5.13.11-jar-with-dependencies.jar \
      /path/to/tablestore/jars
  2. 在EMR控制臺(tái),修改Hive服務(wù)配置,保存并開(kāi)啟自動(dòng)配置更新

    修改配置項(xiàng)詳情請(qǐng)參見(jiàn)修改配置項(xiàng)

    配置文件

    配置項(xiàng)

    修改內(nèi)容

    hive-env.sh

    hive_aux_jars_path

    配置項(xiàng)末尾添加,/path/to/tablestore/jars。

    hive-site.xml

    hive.aux.jars.path

    配置項(xiàng)末尾添加,/path/to/tablestore/jars。

  3. 在TableStore控制臺(tái)創(chuàng)建數(shù)據(jù)表,詳情請(qǐng)參見(jiàn)通過(guò)控制臺(tái)使用寬表模型

    本文示例中創(chuàng)建的數(shù)據(jù)表名稱為pet,表主鍵為name。

  4. 執(zhí)行以下命令,進(jìn)入Hive命令行。

    hive
    說(shuō)明

    如果使用Beeline,則需要重啟HiveServer2服務(wù)。

  5. 在Hive中創(chuàng)建并查詢表數(shù)據(jù)。

    1. 執(zhí)行以下命令,創(chuàng)建Hive表。

      CREATE EXTERNAL TABLE pet
        (name STRING, owner STRING, species STRING, sex STRING, birth STRING, death STRING)
        STORED BY 'com.aliyun.openservices.tablestore.hive.TableStoreStorageHandler'
        WITH SERDEPROPERTIES(
          "tablestore.columns.mapping"="name,owner,species,sex,birth,death")
        TBLPROPERTIES (
          "tablestore.endpoint"="https://<instance_name>.<region>.vpc.tablestore.aliyuncs.com",
          "tablestore.access_key_id"="<yourAccesskeyId>",
          "tablestore.access_key_secret"="<yourAccesskeyKey>",
          "tablestore.table.name"="pet");
    2. 執(zhí)行以下命令,向表中插入數(shù)據(jù)。

      INSERT INTO pet VALUES("Fluffy", "Harold", "cat", "f", "1993-02-04", null);
      INSERT INTO pet VALUES("Claws", "Gwen", "cat", "m", "1994-03-17", null);
      INSERT INTO pet VALUES("Buffy", "Harold", "dog", "f", "1989-05-13", null);
      INSERT INTO pet VALUES("Fang", "Benny", "dog", "m", "1990-08-27", null);
      INSERT INTO pet VALUES("Bowser", "Diane", "dog", "m", "1979-08-31", "1995-07-29");
      INSERT INTO pet VALUES("Chirpy", "Gwen", "bird", "f", "1998-09-11", null);
      INSERT INTO pet VALUES("Whistler", "Gwen", "bird", null, "1997-12-09", null);
      INSERT INTO pet VALUES("Slim", "Benny", "snake", "m", "1996-04-29", null);
      INSERT INTO pet VALUES("Puffball", "Diane", "hamster", "f", "1999-03-30", null);
    3. 執(zhí)行以下命令,查詢數(shù)據(jù)。

      SELECT * FROM pet;

      返回信息如下所示。

      OK
      Bowser	Diane	dog	m	1979-08-31	1995-07-29
      Buffy	Harold	dog	f	1989-05-13	NULL
      Chirpy	Gwen	bird	f	1998-09-11	NULL
      Claws	Gwen	cat	m	1994-03-17	NULL
      Fang	Benny	dog	m	1990-08-27	NULL
      Fluffy	Harold	cat	f	1993-02-04	NULL
      Puffball	Diane	hamster	f	1999-03-30	NULL
      Slim	Benny	snake	m	1996-04-29	NULL
      Whistler	Gwen	bird	NULL	1997-12-09	NULL
      Time taken: 1.731 seconds, Fetched: 9 row(s)