hive(2):单机本地数据配置与第一个例子

本文介绍了如何在单机本地环境中配置Hive,包括创建hive-site.xml配置文件,并通过建立表、加载数据以及执行查询操作,展示了Hive的基本使用流程。在示例中,数据源为sample.txt文件,查询结果未给出。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

show tables;
show databases;

配置:在hive.conf目录下新建hive-site.xml,输入如下内容:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
  <name>javax.jdo.option.ConnectionURL</name>
  <value>jdbc:derby:;databaseName=metastore_db;create=true</value>
</property>
<property>
  <name>javax.jdo.option.ConnectionDriverName</name>
  <value>org.apache.derby.jdbc.EmbeddedDriver</value>
</property>
<property>
  <name>hive.metastore.local</name>
  <value>true</value>
</property>
<property>
  <name>hive.metastore.warehouse.dir</name>
  <value>/Users/zhengwei/hive/warehouse</value>
</property>
</configuration>

建表

create table records(year string,temperature int,quality int) 
row format delimited fields terminated by '\t';

加载数据

load data local inpath '/Users/zhengwei/workspace/bigDataAllIn/src/main/resources/weather/sample.txt'
overwrite into table records;

其中sample.txt:

1950	0	1
1950	22	1
1950	-11	1
1949	111	1
1949	78	1

查询:

select year,max(temperature) from records
where temperature !=9999 and quality in(0,1,4,5,9)
group by year;

结果:

1949	111
1950	22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值