Suman Ghosh
Suman Ghosh

Reputation: 33

What is the difference between = and == in hive

I accidentally used == instead of = in one of my HQL query, but shockingly it didn't throw any error but was working as it should have been working for =. My question here is why do we have == operator in HQL and what is the exact difference between the two.

Upvotes: 2

Views: 3737

Answers (1)

David דודו Markovitz
David דודו Markovitz

Reputation: 44981

The= and == operators have the same functionality.
They are implemented by the exact same class.

system.registerGenericUDF("=", GenericUDFOPEqual.class);
system.registerGenericUDF("==", GenericUDFOPEqual.class);

FunctionRegistry.java


+----------+---------------------+----------------------------------------------------------------+
| Operator |    Operand types    |                          Description                           |
+----------+---------------------+----------------------------------------------------------------+
| A = B    | All primitive types | TRUE if expression A is equal to expression B otherwise FALSE. |
| A == B   | All primitive types | Synonym for the = operator.                                    |
+----------+---------------------+----------------------------------------------------------------+

LanguageManual UDF

Upvotes: 10

Related Questions