You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by Apache Wiki <wi...@apache.org> on 2010/09/11 01:36:57 UTC

[Hadoop Wiki] Update of "Hive/LanguageManual/UDF" by AdamKramer

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Hadoop Wiki" for change notification.

The "Hive/LanguageManual/UDF" page has been changed by AdamKramer.
http://wiki.apache.org/hadoop/Hive/LanguageManual/UDF?action=diff&rev1=52&rev2=53

--------------------------------------------------

  ||<10%>'''Operator''' ||<10%>'''Operand types''' ||'''Description''' ||
  ||A = B ||All primitive types ||TRUE if expression A is equal to expression B otherwise FALSE ||
  ||A == B ||None! ||Fails because of invalid syntax. SQL uses =, not == ||
- ||A <> B ||All primitive types ||TRUE if expression A is NOT equal to expression B otherwise FALSE ||
+ ||A <> B ||All primitive types ||NULL if A or B is NULL, TRUE if expression A is NOT equal to expression B otherwise FALSE ||
- ||A < B ||All primitive types ||TRUE if expression A is less than expression B otherwise FALSE ||
+ ||A < B ||All primitive types ||NULL if A or B is NULL, TRUE if expression A is less than expression B otherwise FALSE ||
- ||A <= B ||All primitive types ||TRUE if expression A is less than or equal to expression B otherwise FALSE ||
+ ||A <= B ||All primitive types ||NULL if A or B is NULL, TRUE if expression A is less than or equal to expression B otherwise FALSE ||
- ||A > B ||All primitive types ||TRUE if expression A is greater than expression B otherwise FALSE ||
+ ||A > B ||All primitive types ||NULL if A or B is NULL, TRUE if expression A is greater than expression B otherwise FALSE ||
- ||A >= B ||All primitive types ||TRUE if expression A is greater than or equal to expression B otherwise FALSE ||
+ ||A >= B ||All primitive types ||NULL if A or B is NULL, TRUE if expression A is greater than or equal to expression B otherwise FALSE ||
  ||A IS NULL ||all types ||TRUE if expression A evaluates to NULL otherwise FALSE ||
  ||A IS NOT NULL ||All types ||TRUE if expression A evaluates to NULL otherwise FALSE ||
- ||A LIKE B ||strings ||TRUE if string A matches the SQL simple regular expression B, otherwise FALSE. The comparison is done character by character. The _ character in B matches any character in A(similar to . in posix regular expressions) while the % character in B matches an arbitrary number of characters in A(similar to .* in posix regular expressions) e.g. 'foobar' like 'foo' evaluates to FALSE where as 'foobar' like 'foo_ _ _' evaluates to TRUE and so does 'foobar' like 'foo%' ||
+ ||A LIKE B ||strings ||NULL if A or B is NULL, TRUE if string A matches the SQL simple regular expression B, otherwise FALSE. The comparison is done character by character. The _ character in B matches any character in A(similar to . in posix regular expressions) while the % character in B matches an arbitrary number of characters in A(similar to .* in posix regular expressions) e.g. 'foobar' like 'foo' evaluates to FALSE where as 'foobar' like 'foo_ _ _' evaluates to TRUE and so does 'foobar' like 'foo%' ||
- ||A RLIKE B ||strings ||TRUE if string A matches the Java regular expression B(See Java regular expressions syntax), otherwise FALSE e.g. 'foobar' rlike 'foo' evaluates to FALSE where as 'foobar' rlike '^f.*r$' evaluates to TRUE ||
+ ||A RLIKE B ||strings ||NULL if A or B is NULL, TRUE if string A matches the Java regular expression B(See Java regular expressions syntax), otherwise FALSE e.g. 'foobar' rlike 'foo' evaluates to FALSE where as 'foobar' rlike '^f.*r$' evaluates to TRUE ||
  ||A REGEXP B ||strings ||Same as RLIKE ||
  
  
  
  
  === Arithmetic Operators ===
- The following operators support various common arithmetic operations on the operands. All return number types.
+ The following operators support various common arithmetic operations on the operands. All return number types; if any of the operands are NULL, then the result is also NULL.
  ||<10%>'''Operator''' ||<10%>'''Operand types''' ||'''Description''' ||
  ||A + B ||All number types ||Gives the result of adding A and B. The type of the result is the same as the common parent(in the type hierarchy) of the types of the operands. e.g. since every integer is a float, therefore float is a containing type of integer so the + operator on a float and an int will result in a float. ||
  ||A - B ||All number types ||Gives the result of subtracting B from A. The type of the result is the same as the common parent(in the type hierarchy) of the types of the operands. ||
@@ -48, +48 @@

  
  
  === Logical Operators ===
- The following operators provide support for creating logical expressions. All of them return boolean TRUE, FALSE, or NULL depending upon the boolean values of the operands. 
+ The following operators provide support for creating logical expressions. All of them return boolean TRUE, FALSE, or NULL depending upon the boolean values of the operands. NULL behaves as an "unknown" flag, so if the result depends on the state of an unknown, the result itself is unknown.
  
  ||<10%>'''Operator''' ||<10%>'''Operand types''' ||'''Description''' ||
- ||A AND B ||boolean ||TRUE if both A and B are TRUE, otherwise FALSE ||
+ ||A AND B ||boolean ||TRUE if both A and B are TRUE, otherwise FALSE. NULL if A or B is NULL ||
  ||A && B ||boolean ||Same as A AND B ||
- ||A OR B ||boolean ||TRUE if either A or B or both are TRUE, otherwise FALSE ||
+ ||A OR B ||boolean ||TRUE if either A or B or both are TRUE; FALSE OR NULL is NULL; otherwise FALSE ||
  ||A | | B ||boolean ||Same as A OR B ||
  ||NOT A ||boolean ||TRUE if A is FALSE or NULL if A is NULL. Otherwise FALSE. ||
  ||! A ||boolean ||Same as NOT A ||
@@ -73, +73 @@

  
  == Built-in Functions ==
  === Mathematical Functions ===
- The following built-in mathematical functions are supported in hive:
+ The following built-in mathematical functions are supported in hive; most return NULL when the argument(s) are NULL:
  ||<10%>'''Return Type''' ||<15%>'''Name(Signature)''' ||'''Description''' ||
  ||BIGINT ||round(double a) ||Returns the rounded BIGINT value of the double ||
  ||BIGINT ||floor(double a) ||Returns the maximum BIGINT value that is equal or less than the double ||