Archive for the ‘hive & pig’ Category

Free BPA Service 简单说明

Sunday, April 11th, 2010

http://conby.com/page/create-c3-task-business-process-automation 简单说明

Task name: 必填,任务的名称,可用中文

Description: 描述任务,可用中文

Maillog:  如果填入为电子邮件,当task条件满足时,将会发送task的日志报告到填入的电子邮件

Conditions Type: 规定task的conditions(条件)之间的关系,OR为任意一个condition条件满足时触发action(动作). AND为所有condition条件同时满足时触发action(动作)

Condition Name: 必填,condition(条件)的名称,如果希望把本condition(条件)的结果作为变量在action(动作)中使用,请使用规范的变量字符(常规字符和数字,可含空格,空格在变量名中将自动转换为下划线)

Condition Type:

  • crontab 为标准的Linux/Unix的crontab格式,条件满足时触发action(动作)
  • post 为一个用户自定义的网址,系统将自动将payload使用HTTP协议的POST方法将数据发送过去,此时可以在eval中验证post回来的结果
  • api 为C3系统的API调用,可接受payload
  • due 为简单的时间到期检查,格式如 2010-01-01 10:30, 时间到达后,将自动触发 action(动作)
  • hook 为系统钩或回调, 可以直接获取到 其他task某个action(动作)的运行结果,并在eval中验证post回来的结果

Spec 为根据不同的condition(条件) Type,填入相应的格式或者名称

Payload 为不同的condition(条件) Type下的参数,只对 api, post, hook有效.  due和 crontab不需要填payload。 payload的格式为name=value&name2=value2, 其中value要求已经被urlencode, 系统的[result]将自动进行urlencode

eval 为Python规范的eval表达式,例如:

  • ‘aa’==’aa’
  • ‘[result]==’aa’, 其中[result]为系统token,表示前面的post,api或者hook的运行结果
  • 1, 如果想不验证运行结果,直接让条件满足触发后面的动作,可以简单填入1

Action Name: 动作的名称, 如果需要在其他任务的hook中被使用,请使用规范的规范的变量字符(常规字符和数字,可含空格)

Action Type:

  • api 为C3系统的API调用,可接受payload
  • post 为一个用户自定义的网址,系统将自动将payload使用HTTP协议的POST方法将数据发送过去
  • queue,基本与api相同,但此动作将会列入云计算平台的队列中异步执行,不会马上返回执行结果,如果希望获得此action的结果,请使用hook condition 方法
  • map-reduce, 基本与queue相同,此action动作专门为map-reduce类型的大规模云计算设计,action(动作)将会列入云计算平台的队列中异步执行,不会马上返回执行结果,如果希望获得此action的结果,请使用hook condition 方法。如queue不同的是:
  1. Spec中需要填入完整的map-reduce api对。例如  c3_demo_mapper-c3_demo_reducer,用”-”分割,前面的代表map-reduce计算模型中的map方法,后面的代表map-reduce计算模型中的reduce方法
  2. Payload中需要指定map数据集,例如 map=1%2C2%2C3,%2C为“,”的urlencode后的表达方式。此例子表示map数据集有3项,分别为1,2,3。 常用的使用方式应该为map=[conditionname],直接使用condition(条件)的返回结果。系统将自动对[conditionname]进行urlencode。
  3. map-redude计算模式一般在2~3分钟内启动计算,经过多轮的map,recuce运算后,计算结果可以使用hook condition 方法获取(需另外创建一个task来hook这个action的运算结果). maillog只会发送同步action(动作)的结果,不会发送异步和任何queue类型的action(动作)的结果

如果需要终止task,或者修改task,请使用 C3 SDK开发包,或者直接登录 BPA系统进行修改.  C3 SDK开发包下载地址:

http://conby.com/products_ch.html

all news and information will be posted on twitter

Thursday, February 25th, 2010

all news and information will be posted on twitter, this blog has been moved to twitter.

a hive error solution

Monday, November 2nd, 2009

FAILED: Error in metadata: javax.jdo.JDOFatalInternalException: Unexpected
exception caught.
NestedThrowables:
java.lang.reflect.InvocationTargetException
FAILED: Execution Error, return code 1 from
org.apache.hadoop.hive.ql..exec.DDLTask

found it’s related to two core-3.1.1.jar
files with the same classes defined in the CLASS_PATH.
Solved by disabling one of the jars:
mv $HADOOP_HOME/build/ivy/lib/Hadoop/common/core-3.1.1.jar
$HADOOP_HOME/build/ivy/lib/Hadoop/common/core-3.1.1.jar.orig

hadoop 0.20.1
hive 0.4
jdk 1.6

HiveSQL Select Syntax

Sunday, October 25th, 2009

Select Syntax

SELECT [ALL | DISTINCT] select_expr, select_expr, ...
FROM table_reference
[WHERE where_condition]
[GROUP BY col_list]
[   CLUSTER BY col_list
  | [DISTRIBUTE BY col_list] [SORT BY col_list]
]
[LIMIT number]
  • A SELECT statement can be part of a union query or a subquery of another query.
  • table_reference indicates the input to the query. It can be a regular table, a join construct or a subquery.
  • Simple query. For example, the following query retrieves all columns and all rows from table t1.
SELECT * FROM t1
  • Where clause – The where condition is a boolean expression. For example, the following query returns only those sales records which have an amount greater than 10 from the US region. Hive does not support IN, EXISTS or subqueries in the WHERE clause.
SELECT * FROM sales WHERE amount > 10 AND region = "US"
  • The ALL and DISTINCT options specify whether duplicate rows should be returned. If none of these options are given, the default is ALL (all matching rows are returned). DISTINCT specifies removal of duplicate rows from the result set.
hive> SELECT col1, col2 FROM t1
    1 3
    1 3
    1 4
    2 5
hive> SELECT DISTINCT col1, col2 FROM t1
    1 3
    1 4
    2 5
hive> SELECT DISTINCT col1 FROM t1
    1
    2
  • Partition based queries. In general, a SELECT query scans the entire table (other than for sampling). If a table created using the PARTITIONED BY clause, a query can do input pruning and scan only a fraction of the table relevant to the query. Hive currently does input pruning only if the partition predicates are specified in the WHERE clause closest to the table_reference in the FROM clause. For example, if table page_views is partitioned on column date, the following query retrieves rows for just one day 2008-03-31.
    SELECT page_views.*
    FROM page_views
    WHERE page_views.date >= '2008-03-01' AND page_views.date <= '2008-03-31'
SELECT col1 FROM t1 GROUP BY col1 HAVING SUM(col2) > 10

can be rewritten as

SELECT col1 FROM (SELECT col1, SUM(col2) AS col2sum FROM t1 GROUP BY col1) t2 WHERE t2.col2sum > 10
  • Limit indicates the number of rows to be returned. The rows returned are chosen at random. The following query returns 5 rows from t1 at random.
SELECT * FROM t1 LIMIT 5
  • Top k queries. The following query returns the top 5 sales records wrt amount.
SET mapred.reduce.tasks = 1
SELECT * FROM sales SORT BY amount DESC LIMIT 5
  • A SELECT statement can take regex-based column specification.
  • We use java regex syntax. Try http://www.fileformat.info/tool/regex.htm for testing purposes.
  • The following query select all columns except ds and hr.
SELECT `(ds|hr)?+.+` FROM sales