[Spark][Hive]外部文件导入到Hive的例子

Posted 健哥的数据花园

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[Spark][Hive]外部文件导入到Hive的例子相关的知识,希望对你有一定的参考价值。

外部文件导入到Hive的例子:

[[email protected] ~]$ cd ~
[[email protected] ~]$ pwd
/home/training
[[email protected] ~]$

[[email protected] ~]$ vim customers.txt
[[email protected] ~]$
[[email protected] ~]$ cat customers.txt
001 Ali us
002 Bsb ca
003 Carls mx


[[email protected] ~]$ cd ~
[[email protected] ~]$ pwd
/home/training

[[email protected] ~]$ hive
2017-10-01 06:02:24,782 WARN [main] mapreduce.TableMapReduceUtil:
The hbase-prefix-tree module jar containing PrefixTreeCodec is not present. Continuing without it.

Logging initialized using configuration in file:/etc/hive/conf.dist/hive-log4j.properties
WARNING: Hive CLI is deprecated and migration to Beeline is recommended.

hive>
> show tables ‘*c*‘;
OK
Time taken: 3.268 seconds

<<<<<<<<<<< 目前无表

hive>
> CREATE TABLE IF NOT EXISTS customers(
> cust_id string,
> name string,
> country string
> )
> ROW FORMAT DELIMITED FIELDS TERMINATED BY ‘\t‘;
OK
Time taken: 7.931 seconds
hive>

hive> load data local inpath ‘/home/training/customers.txt‘ into table customers;
Loading data to table default.customers
Table default.customers stats: [numFiles=1, totalSize=36]
OK
Time taken: 3.676 seconds


hive> show tables like ‘customers‘;
OK
customers
Time taken: 0.24 seconds, Fetched: 1 row(s)
hive>

hive> show tables ‘*c*‘;
OK
customers
Time taken: 0.167 seconds, Fetched: 1 row(s)
hive>

以上是关于[Spark][Hive]外部文件导入到Hive的例子的主要内容,如果未能解决你的问题,请参考以下文章

原创问题定位分享(16)spark写数据到hive外部表报错ClassCastException: org.apache.hadoop.hive.hbase.HiveHBaseTableOutpu(代

外部覆盖后 Spark 和 Hive 表架构不同步

Spark 不使用 Hive 分区外部表中的分区信息

[大数据]Hive:Spark,我发现你有小秘密啊~

建立Hive和Hbase的映射关系,通过Spark将Hive表中数据导入ClickHouse

hive常用功能:Hive数据导入导出方式