0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[自分用メモ] Hiveのテーブル作成

0
Last updated at Posted at 2021-08-02

テーブル作成例

create table customer (
  `c_custkey` bigint COMMENT '', 
  `c_name` string COMMENT '', 
  `c_address` string COMMENT '', 
  `c_nationkey` bigint COMMENT '', 
  `c_phone` string COMMENT '', 
  `c_acctbal` double COMMENT '', 
  `c_mktsegment` string COMMENT '', 
  `c_comment` string COMMENT '')
STORED AS PARQUET
LOCATION 'gs://bucket-1/customer';

テーブルの作成 Avro バージョン

CREATE  TABLE `customer`(
  `c_custkey` bigint COMMENT '', 
  `c_name` string COMMENT '', 
  `c_address` string COMMENT '', 
  `c_nationkey` bigint COMMENT '', 
  `c_phone` string COMMENT '', 
  `c_acctbal` double COMMENT '', 
  `c_mktsegment` string COMMENT '', 
  `c_comment` string COMMENT '', 
  `null` binary COMMENT '')
  STORED AS AVRO
  LOCATION 'gs://bucket-2/customer'
  TBLPROPERTIES("avro.compression"="SNAPPY");

他のテーブルからのデータの挿入

insert overwrite table customer select c_custkey, c_name, c_address, c_nationkey, c_phone, c_acctbal, c_mktsegm
ent, c_comment from db1.customer;

テーブルの作成 PRC パーティションあり

CREATE TABLE `lineitems`(
  `l_orderkey` bigint, 
  `l_linenumber` bigint, 
  `l_quantity` double, 
  `l_extendedprice` double, 
  `l_discount` double, 
  `l_tax` double, 
  `l_returnflag` string, 
  `l_linestatus` string, 
  `l_shipdate` date, 
  `l_recieptdate` date, 
  `l_shipinstruct` string, 
  `l_shipmode` string, 
  `o_orderkey` int, 
  `o_custkey` int, 
  `o_orderdate` date, 
  `o_totalprice` double, 
  `o_orderstatus` string, 
  `o_orderpriority` string, 
  `o_shippriority` int, 
  `o_clerk` string, 
  `c_custkey` bigint, 
  `c_nationkey` bigint, 
  `c_acctbal` double, 
  `c_mktsegment` string)
PARTITIONED BY (year int, month int, day int)
STORED AS ORC
LOCATION 'gs://bucket-3/';
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?