赞
踩
create external table test_hive_delimiter
(
id int,
name string,
address string
)
row format delimited fields terminated by '\u001B'
stored as textfile location '/fayson/test_hive_delimiter';
[root@ip-172-31-6-148 ~]# sqoop import --connect jdbc:mysql://ip-172-31-6-148.fayson.com:3306/fayson -username root -password 123456 --table test -m 1 --hive-import --fields-terminated-by "\0x001B" --target-dir /fayson/test_hive_delimiter --hive-table test_hive_delimiter
[root@ip-172-31-6-148 ~]# hadoop fs -ls /fayson/test_hive_delimiter
Found 2 items
-rw-r--r-- 3 fayson supergroup 0 2017-09-06 13:46 /fayson/test_hive_delimiter/_SUCCESS
-rwxr-xr-x 3 fayson supergroup 56 2017-09-06 13:46 /fayson/test_hive_delimiter/part-m-00000
[root@ip-172-31-6-148 ~]# hadoop fs -ls /fayson/test_hive_delimiter/part-m-00000
-rwxr-xr-x 3 fayson supergroup 56 2017-09-06 13:46 /fayson/test_hive_delimiter/part-m-00000
[root@ip-172-31-6-148 ~]#
[root@ip-172-31-6-148 ~]# beeline Beeline version 1.1.0-cdh5.12.1 by Apache Hive beeline> !connect jdbc:hive2://localhost:10000/;principal=hive/ip-172-31-6-148.fayson.com@FAYSON.COM ... Transaction isolation: TRANSACTION_REPEATABLE_READ 0: jdbc:hive2://localhost:10000/> select * from test_hive_delimiter; ... INFO : OK +-------------------------+---------------------------+------------------------------+--+ | test_hive_delimiter.id | test_hive_delimiter.name | test_hive_delimiter.address | +-------------------------+---------------------------+------------------------------+--+ | NULL | NULL | NULL | | NULL | NULL | NULL | | NULL | NULL | NULL | +-------------------------+---------------------------+------------------------------+--+ 3 rows selected (0.287 seconds) 0: jdbc:hive2://localhost:10000/>
0: jdbc:hive2://localhost:10000/> show create table test_hive_delimiter; ... INFO : OK +----------------------------------------------------+--+ | createtab_stmt | +----------------------------------------------------+--+ | CREATE EXTERNAL TABLE `test_hive_delimiter`( | | `id` int, | | `name` string, | | `address` string) | | ROW FORMAT SERDE | | 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' | | WITH SERDEPROPERTIES ( | | 'field.delim'='\u0015', | | 'serialization.format'='\u0015') | | STORED AS INPUTFORMAT | | 'org.apache.hadoop.mapred.TextInputFormat' | | OUTPUTFORMAT | | 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' | | LOCATION | | 'hdfs://ip-172-31-6-148.fayson.com:8020/fayson/test_hive_delimiter' | | TBLPROPERTIES ( | | 'COLUMN_STATS_ACCURATE'='false', | | 'numFiles'='0', | | 'numRows'='-1', | | 'rawDataSize'='-1', | | 'totalSize'='0', | | 'transient_lastDdlTime'='1504705887') | +----------------------------------------------------+--+ 22 rows selected (0.084 seconds) 0: jdbc:hive2://localhost:10000/>
create external table test_hive_delimiter
(
id int,
name string,
address string
)
row format delimited fields terminated by '\033'
stored as textfile location '/fayson/test_hive_delimiter';
0: jdbc:hive2://localhost:10000/> show create table test_hive_delimiter; ... INFO : OK +----------------------------------------------------+--+ | createtab_stmt | +----------------------------------------------------+--+ | CREATE EXTERNAL TABLE `test_hive_delimiter`( | | `id` int, | | `name` string, | | `address` string) | | ROW FORMAT SERDE | | 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' | | WITH SERDEPROPERTIES ( | | 'field.delim'='\u001B', | | 'serialization.format'='\u001B') | | STORED AS INPUTFORMAT | | 'org.apache.hadoop.mapred.TextInputFormat' | | OUTPUTFORMAT | | 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' | | LOCATION | | 'hdfs://ip-172-31-6-148.fayson.com:8020/fayson/test_hive_delimiter' | | TBLPROPERTIES ( | | 'COLUMN_STATS_ACCURATE'='false', | | 'numFiles'='0', | | 'numRows'='-1', | | 'rawDataSize'='-1', | | 'totalSize'='0', | | 'transient_lastDdlTime'='1504707693') | +----------------------------------------------------+--+ 22 rows selected (0.079 seconds) 0: jdbc:hive2://localhost:10000/>
0: jdbc:hive2://localhost:10000/> select * from test_hive_delimiter;
...
INFO : OK
+-------------------------+---------------------------+------------------------------+--+
| test_hive_delimiter.id | test_hive_delimiter.name | test_hive_delimiter.address |
+-------------------------+---------------------------+------------------------------+--+
| 1 | fayson | guangdong |
| 2 | zhangsan | shenzheng |
| 3 | lisi | shanghai |
+-------------------------+---------------------------+------------------------------+--+
3 rows selected (0.107 seconds)
0: jdbc:hive2://localhost:10000/>
大数据视频推荐:
CSDN
大数据语音推荐:
企业级大数据技术应用
大数据机器学习案例之推荐系统
自然语言处理
大数据基础
人工智能:深度学习入门到精通
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。