- 浏览: 834013 次
- 性别:
- 来自: 郑州
文章列表
Creating an Index -- 创建一个索引
CREATE TABLE employees (
name STRING,
salary FLOAT,
subordinates ARRAY<STRING>,
deductions MAP<STRING, FLOAT>,
address STRUCT<street:STRING, city:STRING, state:STRING, zip:INT>
)
PARTITIONED BY (country STRING, state STR ...
- 2013-01-22 21:10
- 浏览 382
- 评论(0)
Views to Reduce Query Complexity -- 视图减少复杂查询
FROM (
SELECT * FROM people JOIN cart
ON (cart.people_id=people.id) WHERE firstname='john'
) a SELECT a.lastname WHERE a.id=3;
CREATE VIEW shorter_join AS
SELECT * FROM people JOIN cart
ON (cart.people_id=people.id) WHERE firstname='john';
SELECT ...
- 2013-01-22 20:56
- 浏览 524
- 评论(0)
SELECT … FROM Clauses
hive> SELECT name, salary FROM employees;
表别名
hive> SELECT name, salary FROM employees;
hive> SELECT e.name, e.salary FROM employees e;
Specify Columns with Regular Expressions
hive> SELECT symbol, `price.*` FROM stocks;
AAPL 195.69 197.88 ...
- 2013-01-21 22:00
- 浏览 646
- 评论(0)
Loading Data into Managed Tables -- 加载数据到表
LOAD DATA LOCAL INPATH '${env:HOME}/california-employees'
OVERWRITE INTO TABLE employees
PARTITION (country = 'US', state = 'CA');
LOAD DATA LOCAL ... copies the local data to the final location in the
distributed filesystem, while LOAD DATA ... (i.e., w ...
- 2013-01-20 22:35
- 浏览 482
- 评论(0)
Databases in Hive -- 在HIVE 中使用数据库
Hive offers no support for row-level inserts, updates, and deletes.
Hive doesn’t support transactions. Hive adds ex-tensions to provide
better performance in the context of Hadoop and to integrate withcustom extensions and even external programs.
Hive 不支持行级插入 ...
- 2013-01-20 19:40
- 浏览 513
- 评论(0)
Primitive Data Types --Hive 支持数据类型
Hive supports several sizes of integer and floating-point types, a Boolean type, and
character strings of arbitrary length. Hive v0.8.0 added types for timestamps and binary
fields.
What if you run a query that wants to interpret a string column as a n ...
- 2013-01-19 21:37
- 浏览 560
- 评论(0)
Variables and Properties -- 设置 hive 变量
$ hive --define foo=bar
hive> set foo;
foo=bar;
hive> set hivevar:foo;
hivevar:foo=bar;
hive> set hivevar:foo=bar2;
hive> set foo;
foo=bar2
hive> create table toss1(i int, ${hivevar:foo} string);
hive> describe toss1;
i int
bar2 ...
- 2013-01-19 20:34
- 浏览 437
- 评论(0)
hive默认查询不会显示列名, 当一个表字段比较多的时候,往往看不出值与列之间的对应关系,对日常查错及定位问题带来不便,应同事要求,看了HIVE CLI源码,做了下些许调整, 加入列头打印及行转列显示功能
未开启行转列功能之前:
hive>
>
> select * from example_table where dt='2012-03-31-02' limit 2;
OK
1333133185 0cf49387a23d9cec25da3d76d6988546 3CD5E9A1721861AE6688260ED26206C2 guanwang 1.1 3d3b0a5ec ...
- 2013-01-17 22:45
- 浏览 1147
- 评论(0)
Hive 的官方文档中对查询语言有了很详细的描述,请参考:http://wiki.apache.org/hadoop/Hive/LanguageManual ,本文的内容大部分翻译自该页面,期间加入了一些在使用过程中需要注意到的事项。
Create Table
CREATE [EXTERNAL] TABLE [IF NOT EXISTS] t ...
- 2013-01-17 22:43
- 浏览 358
- 评论(0)
DDL Operations
创建表
hive> CREATE TABLE pokes (foo INT, bar STRING);
创建表并创建索引字段ds
hive> CREATE TABLE invites (foo INT, bar STRING) PARTITIONED BY (ds STRING);
显示所有表
hive> SHOW TABLES;
按正条件(正则表达式)显示表,
hive> SHOW TABLES '.*s';
表添加一列
hive> ALTER TABLE pokes ADD COLUMNS ( ...
- 2013-01-17 22:39
- 浏览 446
- 评论(0)
一、创建表
在官方的wiki里,example是这样的:
Sql代码
CREATE[EXTERNAL]TABLE[IFNOTEXISTS]table_name
[(col_namedata_type[COMMENTcol_comment],...)]
[COMMENTtable_comment]
[PARTITIONEDBY(col_namedata_type
[COMMENTcol_comment],...)]
[CLUSTEREDBY(col_name,col_name,... ...
- 2013-01-17 22:31
- 浏览 697
- 评论(0)
linux给用户添加sudo权限:
有时候,linux下面运行sudo命令,会提示类似:
xxxis not in the sudoers file. This incident will be reported.
这里,xxx是用户名称,然后导致无法执行sudo命令,这时候,如下解决:
进入超级用户模式。也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用)
添加文件的写权限。也就是输入命令"chmod u+w /etc/sudoers"。
编辑/etc/sudoers ...
- 2013-01-15 23:31
- 浏览 381
- 评论(0)
在本机上装的CentOS 5.5 虚拟机,
软件准备:jdk 1.6 U26
hadoop:hadoop-0.20.203.tar.gz
ssh检查配置
Linux代码
[root@localhost~]#ssh-keygen-trsa
Generatingpublic/privatersakeypair.
Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):
Createddirectory'/root/.ssh'.
Enterpassphrase(emptyfornopassphrase):
Enters ...
- 2013-01-15 22:31
- 浏览 836
- 评论(0)
Centos 6 配置 vsftp 同时使用本地用户和虚拟用户
一、安装vsftp
1.安装Vsftpd服务相关部件
yum install vsftpd*
2.确认安装PAM服务相关部件
yum install pam*
3.安装DB4部件包
安装一个db4的包,用来支持文件数据库。
yum install db4*
二、配置vsftp
1.修改/etc/vsftpd/vsftpd.conf
vi /etc/vsftpd/vsftpd.conf
# Allow anonymous FTP? (Beware - allowed by default if you comm ...
- 2013-01-15 13:29
- 浏览 237
- 评论(0)
用 PuTTYgen 来生成密钥,以后可以不用密码登录服务器了
PuTTYgen 是密钥生成器,用来生成一对公钥和私钥供 PuTTY、PSCP、Plink、Pagent 来使用。直接运行 PuTTYgen 可以看到如下的界面。
点击 Generate 按钮就开始生成一个公钥和私 ...
- 2013-01-14 21:57
- 浏览 391
- 评论(0)