Created
March 22, 2017 06:00
-
-
Save dgadiraju/3091418a2883b014c1ff64c1bf48b11d to your computer and use it in GitHub Desktop.
Make sure you save oozie-fork-join-workflow.xml as workflow.xml in a directory (let's say daily_revenue)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use dgadiraju_oozie; | |
drop table orders; | |
drop table order_items; | |
create external table orders ( | |
order_id int, | |
order_date string, | |
order_customer_id int, | |
order_status string | |
) row format delimited fields terminated by ',' | |
location '/user/dgadiraju/daily_revenue/orders'; | |
create external table order_items ( | |
order_item_id int, | |
order_item_order_id int, | |
order_item_product_id int, | |
order_item_quantity int, | |
order_item_subtotal float, | |
order_item_price float | |
) row format delimited fields terminated by ',' | |
location '/user/dgadiraju/daily_revenue/order_items'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This can be used for Hive2 and many other workflows | |
#jdbcURL is to connect to hive database using hive server | |
nameNode=hdfs://nn01.itversity.com:8020 | |
jobTracker=rm01.itversity.com:8050 | |
queueName=default | |
jdbcURL=jdbc:hive2://nn01.itversity.com:10000/dgadiraju | |
oozie.use.system.libpath=true | |
oozie.wf.application.path=${nameNode}/user/${user.name}/daily_revenue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!-- | |
Licensed to the Apache Software Foundation (ASF) under one | |
or more contributor license agreements. See the NOTICE file | |
distributed with this work for additional information | |
regarding copyright ownership. The ASF licenses this file | |
to you under the Apache License, Version 2.0 (the | |
"License"); you may not use this file except in compliance | |
with the License. You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, | |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
See the License for the specific language governing permissions and | |
limitations under the License. | |
--> | |
<workflow-app xmlns="uri:oozie:workflow:0.2" name="sqoop-wf"> | |
<start to="sqoop-parallel"/> | |
<fork name="sqoop-parallel"> | |
<path start="sqoop-orders"/> | |
<path start="sqoop-orderitems"/> | |
</fork> | |
<action name="sqoop-orders"> | |
<sqoop xmlns="uri:oozie:sqoop-action:0.2"> | |
<job-tracker>${jobTracker}</job-tracker> | |
<name-node>${nameNode}</name-node> | |
<configuration> | |
<property> | |
<name>mapred.job.queue.name</name> | |
<value>${queueName}</value> | |
</property> | |
</configuration> | |
<command>import --connect jdbc:mysql://nn01.itversity.com:3306/retail_db --username retail_dba --password itversity --table order_items --target-dir /user/dgadiraju/daily_revenue/order_items -m 1</command> | |
</sqoop> | |
<ok to="ordersjoin"/> | |
<error to="fail"/> | |
</action> | |
<action name="sqoop-orderitems"> | |
<sqoop xmlns="uri:oozie:sqoop-action:0.2"> | |
<job-tracker>${jobTracker}</job-tracker> | |
<name-node>${nameNode}</name-node> | |
<configuration> | |
<property> | |
<name>mapred.job.queue.name</name> | |
<value>${queueName}</value> | |
</property> | |
</configuration> | |
<command>import --connect jdbc:mysql://nn01.itversity.com:3306/retail_db --username retail_dba --password itversity --table orders --target-dir /user/dgadiraju/daily_revenue/orders -m 1</command> | |
</sqoop> | |
<ok to="ordersjoin"/> | |
<error to="fail"/> | |
</action> | |
<join name="ordersjoin" to="hive2-create-tables"/> | |
<action name="hive2-create-tables"> | |
<hive2 xmlns="uri:oozie:hive2-action:0.1"> | |
<job-tracker>${jobTracker}</job-tracker> | |
<name-node>${nameNode}</name-node> | |
<configuration> | |
<property> | |
<name>mapred.job.queue.name</name> | |
<value>${queueName}</value> | |
</property> | |
</configuration> | |
<jdbc-url>${jdbcURL}</jdbc-url> | |
<script>hive_create_tables.hql</script> | |
</hive2> | |
<ok to="end"/> | |
<error to="fail"/> | |
</action> | |
<kill name="fail"> | |
<message>Sqoop failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message> | |
</kill> | |
<end name="end"/> | |
</workflow-app> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment