hadoop - 加速配置单元连接字符串值

标签 hadoop hive hiveql

我正在 hive 中尝试在下面的代码中尝试在字段“word”上联接两个表。这是永远的,我想知道如何才能加快速度。在一个表中,“单词”字段包含大小写字母的混合,在另一表中,则全部为大写。

Code:

set hive.exec.compress.output=false;
set hive.mapred.mode=nonstrict;


DROP TABLE IF EXISTS newTable;
CREATE TABLE newTable AS
SELECT
      bh.inkey,
      bh.prid,
      bh.hname,
      bh.ptype,
      bh.band,
      bh.sles,
      bh.num_ducts,
      urg.R_NM

from table1 AS bh
INNER JOIN table2 AS urg
    ON LOWER(bh.word)=LOWER(urg.word);

最佳答案

我将基于table1用大写单词创建一个临时表。然后将这个表连接到table2而不使用任何字符串函数,因为table2.word都是大写的。除了table1和table2较大以外,较低的字符串函数还会导致查询速度变慢。

DROP TABLE IF EXISTS tmpTable;
CREATE TABLE tmpTable AS
SELECT bh.word,
      bh.inkey,
      bh.prid,
      bh.hname,
      bh.ptype,
      bh.band,
      bh.sles,
      bh.num_ducts
from table1 AS bh;

DROP TABLE IF EXISTS newTable;
CREATE TABLE newTable AS
SELECT
      tmp.inkey,
      tmp.prid,
      tmp.hname,
      tmp.ptype,
      tmp.band,
      tmp.sles,
      tmp.num_ducts,
      urg.R_NM
from tmpTable AS tmp
INNER JOIN table2 AS urg
    ON tmp.word=urg.word;

关于hadoop - 加速配置单元连接字符串值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49324123/

相关文章:

java - 使用 JDBC 从 Java 连接到 Hive

regex - Hive:反斜杠的正则表达式

sql - 重复删除 Hive 表的有效方法?

hadoop - maven-shade-plugin 与 maven-assembly-plugin

Hadoop Map Reduce,如何将第一个reducer输出和第一个map输入结合起来,作为第二个mapper的输入?

hadoop - 如何从 Oozie 触发的流式 MapReduce 作业中输出 Hadoop EL 计数器?

mysql - Sqoop 使用 "sqoop create-hive-table"创建表模式

regex - 配置单元查询 regexp_extract

sql - Hive 中的错误 : Underlying error: org. apache.hadoop.hive.ql.exec.UDFArgumentTypeException:需要一个或多个参数

hadoop - Hive 存档分区(动态)失败 : Execution Error, 从 org.apache.hadoop.hive.ql.exec.DDLTask 返回代码 1