impala-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anonymous Coward (Code Review)" <>
Subject [Impala-ASF-CR] IMPALA-4101: qgen: Hive join predicates should only contains equality functions
Date Thu, 22 Sep 2016 00:05:35 GMT has uploaded a new patch set (#5).

Change subject: IMPALA-4101: qgen: Hive join predicates should only contains equality functions

IMPALA-4101: qgen: Hive join predicates should only contains equality functions


Hive only supports equi-joins in its JOIN clause, while Postgres and Impala support more
complex functions such as <, <=, >, >=, etc. This change modifies the
QueryGenerator._create_relational_join_condition and
QueryGenerator._create_boolean_func_tree methods to only construct equality join
conditions under certain conditions.

The _create_boolean_func_tree method is invoked via
QueryGenerator -> create_query -> _create_from_clause -> _create_join_clause ->
_create_relational_join_condition -> _create_boolean_func_tree. This method is invoked
when constructing the JOIN, WHERE, and HAVING clauses. It creates a tree of functions
that would typically be found in any of these clauses.


The parameter "signatures" is added to the method _create_boolean_func_tree, and it lists
out all the allowed signatures the function is allowed to use. Previously, this list of
signatures was populated by calling _funcs_to_allowed_signatures(FUNCS), and if
"signatures" is not specified, then the code defaults back to the results of that method.
A new method in the DefaultProfile called get_allowed_join_signatures is introduced and
returns a list of function signatures that are allowed within a JOIN clause. The
DefaultProfile allows all given signatures, while the HiveProfile only allows for the
Equals and And functions, as well as any function that operates over only one column.
The reason for these restrictions is that Hive only allows equality joins, does not allow
OR operators in the join clause, and has some restrictions on functions that operate over
multiple different tables. This last restriction is somewhat subtle; if one side of the
equals operator contains a function that operates over two different tables, the other
side of the operator cannot contain either of those tables. While it is possible to have
functions that take in multiple input parameters, the inputs must be taken from specific
tables to prevent Hive from throwing a compile time exception. Adding support for this in
qgen code will require significant effort and modification to some core methods
(_create_relational_join_condition and _populate_func_with_vals), so it's best to disable
these for Hive altogether.

Note that the _create_boolean_func_tree still allows for OR operators due to some logic
around its "and_or_fill_ratio" variable. The plan is to fix this in a future patch that
specifically focuses on removing OR operators from Hive JOIN clauses.

Minor change to discrepancy_searcher so that the logs print out "Hive" instead of
"Impala" when running against Hive.


* Added a new unit test that ensures the HiveProfile only returns equality joins
* Unit tests pass
* Tested against Hive locally
* Tested against Impala via Leopard
* Tested against Impala via the Discrepancy Checker

Change-Id: Ibe8832a03cfa0d7ecc293ec6db6db2bcb34ab459
M tests/comparison/
M tests/comparison/
M tests/comparison/
A tests/comparison/tests/hive/
4 files changed, 117 insertions(+), 12 deletions(-)

  git pull ssh:// refs/changes/19/4419/5
To view, visit
To unsubscribe, visit

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Ibe8832a03cfa0d7ecc293ec6db6db2bcb34ab459
Gerrit-PatchSet: 5
Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-Reviewer: David Knupp <>
Gerrit-Reviewer: Michael Brown <>
Gerrit-Reviewer: Taras Bobrovytsky <>

View raw message