Return-Path: Delivered-To: apmail-hadoop-core-commits-archive@www.apache.org Received: (qmail 32580 invoked from network); 3 Jul 2008 00:37:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Jul 2008 00:37:21 -0000 Received: (qmail 22371 invoked by uid 500); 3 Jul 2008 00:37:22 -0000 Delivered-To: apmail-hadoop-core-commits-archive@hadoop.apache.org Received: (qmail 22225 invoked by uid 500); 3 Jul 2008 00:37:21 -0000 Mailing-List: contact core-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: core-dev@hadoop.apache.org Delivered-To: mailing list core-commits@hadoop.apache.org Received: (qmail 22216 invoked by uid 99); 3 Jul 2008 00:37:21 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 02 Jul 2008 17:37:21 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.130] (HELO eos.apache.org) (140.211.11.130) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Jul 2008 00:36:39 +0000 Received: from eos.apache.org (localhost [127.0.0.1]) by eos.apache.org (Postfix) with ESMTP id E24C8118D8 for ; Thu, 3 Jul 2008 00:36:59 +0000 (GMT) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Apache Wiki To: core-commits@hadoop.apache.org Date: Thu, 03 Jul 2008 00:36:59 -0000 Message-ID: <20080703003659.289.64965@eos.apache.org> Subject: [Hadoop Wiki] Update of "HRDF/HQL" by udanax X-Virus-Checked: Checked by ClamAV on apache.org Dear Wiki user, You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change notification. The following page has been changed by udanax: http://wiki.apache.org/hadoop/HRDF/HQL The comment on the change is: Move to incubator ------------------------------------------------------------------------------ + deleted - = HQL = - == Table of Contents == - {{{ }}}1. [#QueryGrammars Query Grammars] [[BR]] - {{{ }}}1.1 [#DAL Database administration language] [[BR]] - {{{ }}}1.2 [#DDL Data definition language] [[BR]] - {{{ }}}1.3 [#DML Data manipulation language] [[BR]] - {{{ }}}2. [#Example Example Of HQL Uses] [[BR]] - {{{ }}}2.1 [#Create Create the table in a Hbase] [[BR]] - {{{ }}}2.2 [#Select Select data from a table] [[BR]] - {{{ }}}2.3 [#Insert Insert data into a table] [[BR]] - {{{ }}}2.4 [#Delete Delete data in a table] [[BR]] - {{{ }}}2.5 [#Jar How to use external jars in Hbase Shell] [[BR]] - - [[Anchor(QueryGrammars)]] - == Query Grammars == - '''Note''' that attribute values are quoted with either single or double quotes. - [[Anchor(DAL)]] - === Database administration language === - ||'''Syntax''' ||'''Explanation''' || - ||Help ||<99%>'''Help''' provides information about the use of shell script.[[BR]][[BR]]~-''HELP [function_name];''-~ || - ||Show ||<99%>'''Show''' lists tables.[[BR]][[BR]]~-''SHOW tables;''-~ || - ||Describe ||'''Describe''' provides information about the columnfamilies in a table.[[BR]][[BR]]~-''DESC table_name;''-~ || - ||FS ||<99%>'''Filesystem''' commands.[[BR]][[BR]]~-''FS [-option] arguments...;''-~ || - ||JAR ||<99%>'''JAR''' syntax to run hadoop jar commands.[[BR]][[BR]]~-''JAR jarFile [mainClass] args...;''-~|| - ||Clear ||<99%>'''Clear''' the screen.[[BR]][[BR]]~-''CLEAR;''-~ || - ||Exit ||<99%>'''Exit''' from the current shell script.[[BR]][[BR]]~-''EXIT;''-~ || - - [[Anchor(DDL)]] - === Data definition language === - Data definition langague to define data tables - - ||'''Syntax''' ||'''Explanation''' || - ||Create ||<99%>'''Create''' a new table.[[BR]][[BR]]~-''CREATE TABLE table_name ([[BR]]{{{ }}}column_family_definition[[BR]]{{{ }}}[, column_family_spec][[BR]]{{{ }}}...[[BR]])[[BR]][[BR]]''-~'''colum_family_definition:'''~-''[[BR]]column_family_name[[BR]]{{{ }}}[MAX_VERSIONS=n][[BR]]{{{ }}}[MAX_LENGTH=n][[BR]]{{{ }}}[COMPRESSION=NONE|BLOCK|RECORD][[BR]]{{{ }}}[IN_MEMORY][[BR]]{{{ }}}[BLOOMFILTER=NONE|BLOOMFILTER|COUNTING_BLOOMFILTER|RETOUCHED_BLOOMFILTER VECTOR_SIZE=n NUM_HASH=n]''-~ || - ||Alter ||<99%>'''Alter''' syntax changes the structure of the specified table.[[BR]][[BR]]~-''ALTER TABLE table_name[[BR]]{{{ }}}alter_definition [, alter_definition] ...[[BR]][[BR]]''-~'''alter_definition:'''~-''[[BR]]{{{ }}}ADD column_family_definition[[BR]]{{{ }}}| ADD (column_family_definition, ...)[[BR]]{{{ }}}| DROP column_family_name[[BR]]{{{ }}}| CHANGE column_family_name column_family_definition''-~|| - ||Drop ||'''Drop''' columnfamilies in a table or tables.[[BR]][[BR]]~-''DROP [ALL|TABLE table_name1[, table_name2, ...]];''-~ || - ||Truncate ||'''Truncate''' cleans all data from a table. [[BR]][[BR]]~-''TRUNCATE TABLE table_name;''-~ || - ||Enable/Disable ||'''Enable/Disable''' table lock. [[BR]][[BR]]~-''[ENABLE|DISABLE] [ALL|table_name];''-~ || - - [[Anchor(DML)]] - === Data manipulation language === - Data manipulation language to manually manipulate data on more detailed parts - - ||'''Syntax''' ||'''Explanation''' || - ||Insert ||<99%>'''Insert''' one row into the table with a value for specified column in the table.[[BR]][[BR]]~-''INSERT INTO table_name (colmn_name, ...)[[BR]]{{{ }}}VALUES ('value', ...)[[BR]]{{{ }}}WHERE row = 'row-key'[[BR]]{{{ }}}[TIMESTAMP 'timestamp'];''-~ || - ||Delete ||'''Delete''' specified rows in table. [[BR]][[BR]]~-''DELETE { column_name, [, column_name] ... | COLUMNFAMILIES(column_family[, column_family] ... | *} [[BR]]{{{ }}}FROM table_name[[BR]]{{{ }}}[WHERE row = 'row-key'];''-~ || - ||Select ||<99%>'''Select''' syntax retrieves rows from a table.[[BR]]Several aggregate operators: COUNT()[[BR]][[BR]]~-''SELECT { column_name [, column_name] ... | expr[alias] | * }[[BR]]{{{ }}}FROM table_name[[BR]]{{{ }}}[WHERE row = 'row-key' | STARTING FROM 'row-key' [UNTIL 'stop-key']][[BR]]{{{ }}}[NUM_VERSIONS = version_count][[BR]]{{{ }}}[TIMESTAMP 'timestamp'][[BR]]{{{ }}}[LIMIT = row_count][[BR]]{{{ }}}[INTO FILE 'file_name'][[BR]][[BR]]''-~'''column_name:'''~-''[[BR]]{{{ }}}column_family_name[[BR]]{{{ }}}| column_family_name:column_label_name''-~ || - [[Anchor(Example)]] - == Example Of HQL Uses == - [[Anchor(Create)]] - === Create the table in a Hbase === - - {{{ - hql > help create; - CREATE Create tables - - Syntax: - CREATE TABLE table_name ( - column_family_definition [, column_family_definition] ... - ); - column_family_definition: - column_family_name - [MAX_VERSIONS=n] - [MAX_LENGTH=n] - [COMPRESSION=NONE|RECORD|BLOCK] - [IN_MEMORY] - [BLOOMFILTER=NONE|BLOOMFILTER|COUNTING_BLOOMFILTER|RETOUCHED_BLOOMFILTER VECTOR_SIZE=n NUM_HASH=n] - }}} - - '''CREATE TABLE''' enables you to create a new table with various options for each column family. - - * ~-'''MAX_VERSIONS''' makes a table keep only the recent n versions in a cell. Its default value is 3, i.e., only the most recent 3 versions of values are stored in a cell.-~ - * ~-'''MAX_LENGTH''' specifies the maximum size of a column value. By default, the maximum size is unlimited. It is limited only by Integer.MAX_VALUE.-~ - * ~-'''COMPRESSION''' specifies which compression technique to use for the column family. By default, Hbase does not compress any data.-~ - * ~-'''IN_MEMORY''' specifies whether to keep the values in the column family in-memory, or not. By default, values are not kept in-memory.-~ - * ~-'''BLOOMFILTER''' specifies which bloom filter to use for the column family. By default, none of the bloom filters is used. You can specify the options in two ways: with '''VECTOR_SIZE''' and '''NUM_HASH''', or with '''NUM_ENTRIES'''. '''VECTOR_SIZE''' specifies the number of elements in the vector, and '''NUM_HASH''' specifies the number of hash functions to use; With '''NUM_ENTRIES''', you specify only the approximated number of entries in the column, and '''VECTOR_SIZE''' and '''NUM_HASH''' are automatically determined.-~ - - {{{ - hql > CREATE TABLE movieLog_table ( - --> year, length, inColor, studioName, vote, producer, actor); - - hql > CREATE TABLE webtable ( - --> contents in_memory max_versions=10 compression=block, - --> anchor max_length=256 bloomfilter=counting_bloomfilter - --> vector_size=1000000 num_hash=4); - }}} - - [[Anchor(Select)]] - === Select data from a table === - {{{ - hql > help select; - SELECT Select values from tables - - Syntax: - SELECT { column_name, [, column_name] ... | expr[alias] | *} FROM table_name - [WHERE row='row_key' | STARTING FROM 'row-key' [UNTIL 'stop-key']] - [NUM_VERSIONS = version_count] - [TIMESTAMP 'timestamp'] - [LIMIT = row_count] - [INTO FILE 'file_name']; - }}} - - '''SELECT''' retrieves a subset of data from the specified table. - - * ~-'''STARTING FROM''' returns all the rows starting from 'row-key'.-~ - * ~-'''NUM_VERSIONS''' retrieves only the recent n versions of values in a cell.-~ - * ~-'''TIMESTAMP''' returns only the values with the specified timestamp.-~ - * ~-'''LIMIT''' limits the number of rows to be returned.-~ - - {{{ - hql > SELECT studioName: FROM movieLog_table WHERE row = 'Star Wars'; - - +----------------------------+ - | title studioName | - | ========================== | - | Star Wars Fox | - +----------------------------+ - - Successfully print out the selected data.(0.05 sec) - - hql > SELECT count(studioName:Fox) FROM movieLog_table; - }}} - - [[Anchor(Insert)]] - === Insert data into a table === - {{{ - hql > help insert; - INSERT Insert values into tables - - Syntax: - INSERT INTO table_name - (colmn_name, ...) VALUES ('value', ...) - WHERE row='row_key' [TIMESTAMP 'timestamp']; - - column_name: - column_family_name - | column_family_name:column_label_name - }}} - - '''INSERT''' inserts a set of values into a table. - - * ~-If the specified column already exists, the new value is stored as a new version.-~ - * ~-If '''TIMESTAMP''' is not specified for the value, the current time is used as its timestamp.-~ - - {{{ - hql > INSERT INTO movieLog_table (year:, length:, inColor:, studioName:, 'vote:user name', producer:, 'actor:hero') - --> VALUES ('1977', '124', 'true', 'Fox', '5', 'George Lucas', 'Mark Hamill') - --> WHERE row='Star Wars'; - }}} - - [[Anchor(Delete)]] - === Delete data in a table === - {{{ - hql > help delete; - DELETE Delete table data - - Syntax: - DELETE { column_name, [, column_name] ... | COLUMNFAMILIES(column_family[, column_family] ... | *} - FROM table_name - [WHERE row = 'row-key']; - }}} - - * Asterisk (*) will be delete the all in table. - * COLUMNFAMILIES(column_family list) will be delete the all columns in columnfamily. - * Specified column_name will be delete the specified column data. - - {{{ - hql > DELETE actor:hero FROM movieLog_table; - hql > DELETE actor:hero FROM movieLog_table WHERE row='Star Wars'; - hql > DELETE * FROM movieLog_table; - }}} - - [[Anchor(Jar)]] - === How to use external jars in Hbase Shell === - - {{{ - hql > HELP JAR; - JAR jarFile [mainClass] args...; - ... - - hql > JAR ./build/hadoop-examples.jar pi 10 10; - }}} -