show tables;
show databases;
Configuration: In the new hive-site.xml hive.conf directory, enter the following:
<?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>
To build the table
create table records(year string,temperature int,quality int)
row format delimited fields terminated by '\t';
Download Data
load data local inpath '/Users/zhengwei/workspace/bigDataAllIn/src/main/resources/weather/sample.txt'
overwrite into table records;
Which sample.txt:
1950 0 1
1950 22 1
1950 -11 1
1949 111 1
1949 78 1
Inquire:
select year,max(temperature) from records
where temperature !=9999 and quality in(0,1,4,5,9)
group by year;
result:
1949 111
1950 22