· 8 years ago · May 05, 2018, 06:14 PM
1set hive.cli.print.header=true; --Mostrar nombre de columnas
2set hive.exec.dynamic.partition=true;
3set hive.exec.dynamic.partition.mode=nonstrict;
4CREATE EXTERNAL TABLE IF NOT EXISTS retail.ventasctic(
5invoiceNo STRING COMMENT 'Numero factura',
6stockCode STRING COMMENT 'Codigo stock',
7description STRING COMMENT 'Descripcion de los items',
8quantity STRING COMMENT 'Cantidad',
9invoiceDate string COMMENT 'Fecha factura',
10unitPrice STRING COMMENT 'Precio unitario',
11customerId STRING COMMENT 'Identificacion cliente'
12)
13PARTITIONED BY (country STRING)
14ROW FORMAT DELIMITED
15FIELDS TERMINATED BY ','
16LINES TERMINATED BY '\n'
17STORED AS TEXTFILE
18LOCATION '/landing/retailparticionada'
19tblproperties("skip.header.line.count" = "1");
20
21set hive.exec.dynamic.partition.mode=nonstrict;
22INSERT INTO TABLE retail.ventasctic partition (country) SELECT A.* FROM retail.ventas AS A;
23
24
25CREATE EXTERNAL TABLE IF NOT EXISTS retail.ventas(
26invoiceNo STRING COMMENT 'Numero factura',
27stockCode STRING COMMENT 'Codigo stock',
28description STRING COMMENT 'Descripcion de los items',
29quantity STRING COMMENT 'Cantidad',
30invoiceDate STRING COMMENT 'Fecha factura',
31unitPrice STRING COMMENT 'Precio unitario',
32customerId STRING COMMENT 'Identificacion cliente',
33country STRING COMMENT 'pais'
34)
35COMMENT 'tabla de ventas diarias'
36ROW FORMAT DELIMITED
37FIELDS TERMINATED BY ','
38LINES TERMINATED BY '\n'
39STORED AS TEXTFILE
40LOCATION '/landing/retail'
41tblproperties("skip.header.line.count" = "1")
42;