Hive创建Hbase外表,及查询结果导出到hdfs操作
1、创建外表
语法
create_table '<my_table>', ':key:string, f:<cq1>:<datatype1>, ...', '[{<PROPERTY> => <value>, ...}]'
':key:string, f:<cq1>:<datatype1>, …' 定义表 <my_table> 的schema,f:<cq1> 为第一列的列名,<datatype1> 为 f:<cq1> 列的数据类型。{<PROPERTY> ⇒ <value>, …} 用于指定一些可选参数,和建HBase表的指令create相比,create_table 的第二个参数用于定义表的schema(而 create 的第二个参数用于指定列族),其他参数(例如SPLITS)和 create 相同,用法也相同。
create_table 'htable', ':key:string, f:c1:int, f:c2:double, f:c3:varchar(10), f:c4:boolean, f:c5:binary, f:c6:tinyint, f:c7:smallint, f:c8:bigint, f:c9:date, f:c10:timestamp, f:c11:float, f:c12:decimal(5,22), f:c13:struct<string, int,varchar(10), decimal(9,33), boolean, float, double, bigint, tinyint, smallint, date, timestamp>'
2、导出到hdfs,可以指定列分隔符:
INSERT OVERWRITE local DIRECTORY'/tmp/out/htable' ROW FORMAT DELIMITED FIELDS TERMINATED BY ',' select * from htable ;
3、hdfs文件下载
hadoop fs -get /tmp/out/htable/* /tmp

浙公网安备 33010602011771号