Hive - 可以提取常见选项以在其他脚本中重用吗? [英] Hive - Can one extract common options for reuse in other scripts?

查看:19
本文介绍了Hive - 可以提取常见选项以在其他脚本中重用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个 Hive 脚本,如下所示:

脚本 A:

<块引用>

SET hive.exec.dynamic.partition=true;SET hive.exec.dynamic.partition.mode=非严格;SET hive.exec.parallel=true;... 做一点事 ...

脚本 B:

<块引用>

 SET hive.exec.dynamic.partition=true;SET hive.exec.dynamic.partition.mode=非严格;SET hive.exec.parallel=true;……做点别的……

我们在每个脚本开头设置的选项都是一样的.是否有可能以某种方式将它们提取到一个公共位置(例如,到 commonoptions.sql 中),以便我们的脚本看起来像这样:

脚本 A:

<块引用>

 <运行 commonoptions.sql>... 做一点事 ...

脚本 B:

<块引用>

 <运行 commonoptions.sql>……做点别的……

理想情况下,我也想提取表定义,以便:

脚本 A:

<块引用>

 <运行 commonoptions.sql><运行defineExternalTableXYZ.sql>... 对 Table XYZ 做一些事情 ...

脚本 B:

<块引用>

 <运行 commonoptions.sql><运行defineExternalTableXYZ.sql>... 对 Table XYZ 做一些其他的事情 ...

这样我就可以在一个地方管理 TableXYZ 定义.我没有使用 Hive CLI.我将 Amazon EMR 与 Hive Steps 结合使用.

解决方案

您可以将这些配置参数存储在公共文件中,并使用 source 命令加载到您的每个脚本中:

source/tmp/common_init.hql;

您也可以从数据库为每个工作流生成此文件.

I have two Hive scripts which look like this:

Script A:

SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=non-strict;
SET hive.exec.parallel=true;

... do something ...

Script B:

  SET hive.exec.dynamic.partition=true;
  SET hive.exec.dynamic.partition.mode=non-strict;
  SET hive.exec.parallel=true;

... do something else ...

The options that we set at the beginning of each script are the same. Is it possible somehow to extract them out to a common place (for example, into a commonoptions.sql) so that our scripts look like this:

Script A:

 <run commonoptions.sql>

... do something ...

Script B:

 <run commonoptions.sql>

... do something else ...

Ideally I would like to extract out table defintions as well, so that I have:

Script A:

 <run commonoptions.sql>
 <run defineExternalTableXYZ.sql>
... do something with Table XYZ ...

Script B:

 <run commonoptions.sql>
 <run defineExternalTableXYZ.sql>
... do something else with Table XYZ ...

That way I can manage the TableXYZ definition at a single spot. I am not using the Hive CLI. I am using Amazon EMR with Hive Steps.

解决方案

You can store these configuration parameters in common file and load in each of your scripts using source command:

source /tmp/common_init.hql;

Also you can generate this file for each workflow from the database.

这篇关于Hive - 可以提取常见选项以在其他脚本中重用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆