Commit Graph

91 Commits

Author SHA1 Message Date
Zoltan Ivanfi
64ffbc4b51 IMPALA-3973: add position and occurrence to instr()
Change-Id: Ie9648de458d243306fa14adc5e7f7002bf6f67fd
Reviewed-on: http://gerrit.cloudera.org:8080/4094
Tested-by: Internal Jenkins
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
2016-09-13 20:28:27 +00:00
Zoltan Ivanfi
c23dc3a53a IMPALA-1659: Netezza compatibility functions: metadata
Added the SQL functions current_catalog(), current_user() and session_user() as
aliases to existing ones and a new SQL function current_sid().

Change-Id: I9b5d1009bbf42acc175a942d2df484e1c64822ca
Reviewed-on: http://gerrit.cloudera.org:8080/4063
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Reviewed-by: Marcel Kornacker <marcel@cloudera.com>
Tested-by: Internal Jenkins
2016-08-26 16:29:24 +00:00
Dan Hecht
ffa7829b70 IMPALA-3918: Remove Cloudera copyrights and add ASF license header
For files that have a Cloudera copyright (and no other copyright
notice), make changes to follow the ASF source file header policy here:

http://www.apache.org/legal/src-headers.html#headers

Specifically:
1) Remove the Cloudera copyright.
2) Modify NOTICE.txt according to
   http://www.apache.org/legal/src-headers.html#notice
   to follow that format and add a line for Cloudera.
3) Replace or add the existing ASF license text with the one given
   on the website.

Much of this change was automatically generated via:

git grep -li 'Copyright.*Cloudera' > modified_files.txt
cat modified_files.txt | xargs perl -n -i -e 'print unless m#Copyright.*Cloudera#i;'
cat modified_files_txt | xargs fix_apache_license.py [1]

Some manual fixups were performed following those steps, especially when
license text was completely missing from the file.

[1] https://gist.github.com/anonymous/ff71292094362fc5c594 with minor
    modification to ORIG_LICENSE to match Impala's license text.

Change-Id: I2e0bd8420945b953e1b806041bea4d72a3943d86
Reviewed-on: http://gerrit.cloudera.org:8080/3779
Reviewed-by: Dan Hecht <dhecht@cloudera.com>
Tested-by: Internal Jenkins
2016-08-09 08:19:41 +00:00
Hayabusa-intel
4e7172f6f5 IMPALA-2459: Implement next_day date/time UDF
Returns the date of the weekday that follows a particular date.
The weekday argument is a string literal indicating the day of the week.
Also this argument is case-insensitive. Available values are:
"Sunday"/"SUN", "Monday"/"MON", "Tuesday"/"TUE",
"Wednesday"/"WED", "Thursday"/"THU", "Friday"/"FRI", "Saturday"/"SAT".
For example, the first Saturday after Wednesday, 25 December 2013
is on 28 December 2013.
select next_day('2013-12-25','Saturday') returns '2013-12-28 00:00:00'
select next_day(to_timestamp('08-1987-21', 'MM-yyyy-dd'), 'FRIDAY')
returns '1987-08-28 00:00:00'

Change-Id: I2721d236c096639a9e7d2df8a45ca888c6b3e83e
Reviewed-on: http://gerrit.cloudera.org:8080/1943
Reviewed-by: Lars Volker <lv@cloudera.com>
Tested-by: Lars Volker <lv@cloudera.com>
2016-06-09 04:30:48 -07:00
Jim Apple
1c16dd0cf8 IMPALA-2107: Add Base64 encoder/decoder
Change-Id: I911451c5d68e8ae9d352abfcf4d5ff36484f0bf3
Reviewed-on: http://gerrit.cloudera.org:8080/2633
Reviewed-by: Dan Hecht <dhecht@cloudera.com>
Tested-by: Internal Jenkins
2016-05-12 14:17:32 -07:00
Thomas Tauber-Marshall
1c98ec7f81 IMPALA-1772: Add additional date/time functions.
Implemented the 'millisecond' built-in function, which takes
a timestamp and returns an integer representing its
millisecond portion.

Other functions pending.

Change-Id: I3bafc6aaf80d1d8d2a634d120d9dbdb954d3f0c4
Reviewed-on: http://gerrit.cloudera.org:8080/2148
Reviewed-by: Marcel Kornacker <marcel@cloudera.com>
Tested-by: Internal Jenkins
2016-03-08 03:12:51 +00:00
Hayabusa-intel
df599b79d9 IMPALA-1477: implement UUID function
Utilize Boost UUID libraries to generate UUID values.
Usage: select uuid();

Change-Id: I932f78952d65f4073d8177c6e80693586e6285cb
Reviewed-on: http://gerrit.cloudera.org:8080/647
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Internal Jenkins
2016-02-03 10:10:28 +00:00
Michael Ho
f3e7274342 IMPALA-2711: Fix memory leak in Rand().
MathFunctions::RandPrepare() allocates a 4-bytes seed and
stores it in the FunctionContext's thread local state.
However, it was never freed. This change fixes the problem
by adding a close function for Rand() so it has a chance to
free the seed. A new test is also added to verify the fix.

Change-Id: Ibcc2e1ca0d052b86defe80aad471f9fdaac5a453
Reviewed-on: http://gerrit.cloudera.org:8080/1855
Reviewed-by: Michael Ho <kwho@cloudera.com>
Tested-by: Internal Jenkins
2016-01-26 11:53:38 +00:00
Jim Apple
1a3d7ffd4f IMPALA-2147: Support IS [NOT] DISTINCT FROM and "<=>" predicates
Enforces that the planner treats IS NOT DISTINCT FROM as eligible for
hash joins, but does not find the minimum spanning tree of
equivalences for use in optimizing query plans; this is left as future
work.

Change-Id: I62c5300b1fbd764796116f95efe36573eed4c8d0
Reviewed-on: http://gerrit.cloudera.org:8080/710
Reviewed-by: Jim Apple <jbapple@cloudera.com>
Tested-by: Internal Jenkins
2016-01-14 05:45:22 +00:00
Michael Ho
34a94c2503 IMPALA-2404: Implements built-in function regexp_match_count
This patch implements a new built-in function
regexp_match_count. This function returns the number of
matching occurrences in input.

The regexp_match_count() function has the following syntax:

int = regexp_match_count(string input, string pattern)
int = regexp_match_count(string input, string pattern,
    int start_pos, string flags)

The input value specifies the string on which the regular
expression is processed.

The pattern value specifies the regular expression.

The start_pos value specifies the character position
at which to start the search for a match. It is set
to 1 by default if it's not specified.

The flags value (if specified) dictates the behavior of
the regular expression matcher:

m: Specifies that the input data might contain more than
one line so that the '^' and the '$' matches should take
that into account.

i: Specifies that the regex matcher is case insensitive.

c: Specifies that the regex matcher is case sensitive.

n: Specifies that the '.' character matches newlines.

By default, the flag value is set to 'c'. Note that the
flags are consistent with other existing built-in functions
(e.g. regexp_like) so certain flags in IBM netezza such as
's' are not supported to avoid confusion.

Change-Id: Ib33ece0448f78e6a60bf215640f11b5049e47bb5
Reviewed-on: http://gerrit.cloudera.org:8080/1248
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Internal Jenkins
2015-10-27 10:11:13 +00:00
aacalfa
5e733e8d62 IMPALA-2190: Complete conversion functions between timestamp, unixtime, and string dates
Change-Id: I48a446f19c7634477f175d0defa8779dd70a392f
Reviewed-on: http://gerrit.cloudera.org:8080/654
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Internal Jenkins
2015-09-07 07:07:20 +00:00
Tim Armstrong
d7e52e336a IMPALA-1660: addendum: add more aliases
Add in missing dfloor alias. This should have been added as part of
IMPALA-1660 as an alias for floor(double) but was overlooked.

Also add in aliases for decimal versions of functions where they exist.

Change-Id: Icb790745714882248d365274e95d45eaaf0ba133
Reviewed-on: http://gerrit.cloudera.org:8080/697
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: Internal Jenkins
2015-09-01 10:46:16 +00:00
Feni Chawla
2db0371a26 IMPALA-2033: Netezza compatibility date/time related functions.
Added INT_MONTHS_BETWEEN, TIMEOFDAY, TIMESTAMP_CMP, MONTHS_BETWEEN functions

Change-Id: I44834c84e21856568613938418947c532e7fbd2e
Reviewed-on: http://gerrit.cloudera.org:8080/642
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Internal Jenkins
2015-08-27 04:17:05 +00:00
Sailesh Mukil
1c46cab5c6 IMPALA-2084: SPLIT_PART and REGEXP_LIKE functions for Tableau pushdown
Added the SPLIT_PART and the REGEXP_LIKE builtin functions and tests for both.
The REGEXP_LIKE has an optional third parameter which if used, uses a different
'prepare' function (RegexpLikePrepare in like-predicate.cc) so that the appropriate
options can be set in the RE2 library.

Added a patch for the RE2 library so that the 'dot matches all' option is exposed
via the RE2 class.

Fixed a bug in the case when the function to be evaluated for the WHERE clause
operates on constants, proper cleanup isn't guaranteed on certain edge cases.

Change-Id: Ia2a8de9eeb2854100a2d949f612cfaba317c5a7b
Reviewed-on: http://gerrit.cloudera.org:8080/501
Reviewed-by: Sailesh Mukil <sailesh@cloudera.com>
Tested-by: Internal Jenkins
2015-08-18 09:07:34 +00:00
Casey Ching
cf60967b7e IMPALA-1675: Avoid overflow when adding large intervals to TIMESTAMPs
It turns out there is a variety of cases where boost incorrectly adds
intervals if the interval is at (or beyond) an edge case value. This
change defines a max interval and returns NULL if the user supplies
an interval beyond the max.

Change-Id: I4fb6869be22ab06089b66eeffaea04b0c0880080
Reviewed-on: http://gerrit.cloudera.org:8080/492
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Internal Jenkins
2015-08-16 12:09:24 +00:00
Feni Chawla
9428448146 IMPALA 2034: Netezza compatibility char functions for ASCII and UTF-8 strings: CHR and BTRIM
Change-Id: I76bf9ba76172b9f1a192ee0936d73718808c0fbd
Reviewed-on: http://gerrit.cloudera.org:8080/529
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Internal Jenkins
2015-08-06 02:24:24 +00:00
Casey Ching
074e5b4349 Remove hashbang from non-script python files
Many python files had a hashbang and the executable bit set though
they were not intended to be run a standalone script. That makes
determining which python files are actually scripts very difficult.
A future patch will update the hashbang in real python scripts so they
use $IMPALA_HOME/bin/impala-python.

Change-Id: I04eafdc73201feefe65b85817a00474e182ec2ba
Reviewed-on: http://gerrit.cloudera.org:8080/599
Reviewed-by: Casey Ching <casey@cloudera.com>
Reviewed-by: Taras Bobrovytsky <tbobrovytsky@cloudera.com>
Tested-by: Internal Jenkins
2015-08-04 05:26:07 +00:00
Tim Armstrong
e151ebaa71 IMPALA-1001: Bit and byte manipulation functions
Bit and byte functions for compatibility with Teradata: bitand, bitor, bitxor, bitnot,
countset, getbit, setbit, shiftleft, shiftright, rotateleft, rotateright.
Interfaces and behavior follow Teradata documentation.

All bit* functions are compatible with DB2.  bitand only is compatible with Oracle.

Change-Id: Idba3fb7beb029de493b602e6279aa68e32688df3
2015-07-28 08:11:01 -07:00
Tim Armstrong
822cb8f5e2 IMPALA-1660: Netezza compatibility - factorial
Implements suffix n! operator for factorial and factorial function.

Slightly refactor operators in fe to share code between unary operators.

Based partially on work by Arthur Peng <arthur.peng@intel.com>.

Change-Id: I71b6c824c59fc5305f16b8c4457805126a1da93b
Reviewed-on: http://gerrit.cloudera.org:8080/531
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Internal Jenkins
2015-07-27 19:03:48 +00:00
Tim Armstrong
e5cc539d3f IMPALA-1660: Netezza math function aliases
Add aliases for existing functions for Netezza compatibility:
dceil->ceil, dtrunc->truncate, dexp->exp, dlog1->ln, log10->dlog10, dpow->pow,
fpow->pow, dsqrt->sqrt, random->rand.

Change-Id: I97da27b676d4e07e55735540f494bdb873f7ed61
Reviewed-on: http://gerrit.cloudera.org:8080/559
Reviewed-by: Tim Armstrong <tarmstrong@cloudera.com>
Tested-by: Internal Jenkins
2015-07-23 21:56:33 +00:00
Casey Ching
a6d534682b IMPALA-2086, IMPALA-2090: Avoid boost year/month interval logic
Boost handles a couple of edge cases differently than other databases
such as Postgres and MySQL when adding year/month intervals to
timestamps. This change makes Impala consistent for the other databases.
The performance difference was not noticeable (<5% if any).

Change-Id: Icb02a06281b53753938cab88e0d28f20709fee06
Reviewed-on: http://gerrit.cloudera.org:8080/489
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Internal Jenkins
2015-07-20 10:16:54 +00:00
Arthur Peng
a275f2a751 IMPALA-1660: Netezza math functions support
1.Add cot function
2.Add double type support in truncate

Change-Id: Id48c58b7778a31edfbda8982f7a8c3d05a1ad14e
2015-07-16 22:29:26 -07:00
Casey Ching
f351119730 Add section in builtin function registry for invisible functions
An upcoming patch will add a function that will not be user visible.
This patch allows a non-visible function to be added in the same way
that visible functions are added (using impala_functions.py).

Change-Id: I70971ced0d595a7aaa975985e589d2676423e221
Reviewed-on: http://gerrit.cloudera.org:8080/528
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Internal Jenkins
2015-07-15 23:43:55 +00:00
Henry Robinson
79913b01e6 IMPALA-2064: Add effective_user() builtin
The user() builtin always returns the connecteduser. However, if the
client wants to see which user its queries are actually delegated to,
there was no easy way to do that.

This patch adds effective_user(), which returns the proxy delegated user
for authorization purposes. If no delegated user is set, the effective
user is the same as that returned from user().

The only way to test this is via a new custom cluster test, which sets
impala.doas.user so that the effective user might be different from the
connected one.

Change-Id: I7048c27c6808a6986dbe1246929816176dca9f76
Reviewed-on: http://gerrit.cloudera.org:8080/458
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Internal Jenkins
2015-06-16 23:42:40 +00:00
Feni Chawla
d4817b697f IMPALA-1771: Add support for hyperbolic trigonometric functions sinh(), cosh(), tanh() and atan2()
Change-Id: Iedd89629b36ec4f5ef270e5eff48371e075ad3ff
Reviewed-on: http://gerrit.cloudera.org:8080/409
Tested-by: Internal Jenkins
Reviewed-by: Henry Robinson <henry@cloudera.com>
2015-05-27 15:54:55 +00:00
zuowang
bcd4c1de21 IMPALA-1662: Netezza compatibility functions: Logic
Logic functions for improved Netezza compatibility:
ISFALSE
ISNOTFALSE
ISNOTTRUE
ISTRUE
NONNULLVALUE
NULLVALUE

Change-Id: I1d5eef793ce99e286c340dc5c63839dc5eb2655d
Reviewed-on: http://gerrit.cloudera.org:8080/21
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Internal Jenkins
2015-03-04 21:09:06 +00:00
casey
dbc504fad1 IMPALA-1579: UNIX_TIMESTAMP() should return BIGINTs instead of INTs
This should fix the last y2k38 problem. Previously calling
unix_timestamp() with a input of '2038-01-19 03:14:08' or later would
return a negative value due to a 32 bit int overflow. This patch
switches from 32 to 64 bit ints.

Change-Id: Ic9180887d6c828f6ecd25435be86fd0bd52d3f0d
Reviewed-on: http://gerrit.cloudera.org:8080/61
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Internal Jenkins
2015-02-16 00:59:34 +00:00
zuowang
60f6373a56 IMPALA-899: Add Mod() UDF
It's an overload function supports parameters of tinyint, int,
smallint, bigint, float, double, and decimal type.

Change-Id: I040753ea06d5402b2f67751f8c4d5d49fa539952
Reviewed-on: http://gerrit.cloudera.org:8080/22
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: Internal Jenkins
2015-02-14 03:07:25 +00:00
Arthur Peng
26386eb41d IMPALA-1597: Add typeOf() builtin
typeOf() returns the type of the given expression.
e.g. typeOf(bigint_col) -> "BIGINT"

Change-Id: I4c12d6fb2759af38a941c92d0f20a6faa000f996
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/5915
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins
2015-02-03 00:41:12 -08:00
Martin Grund
6e0c1c26c9 IMPALA-1424: abs() function retains input type
This patch modifies the abs() built-in function so that it
retains the type of the input argument for the return type
in the same way as Postgres does.

Change-Id: I1750237b85bedbc3ce9d52330ac4d458b0aada3a
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4980
Reviewed-by: Martin Grund <mgrund@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 424b359ab0a4f621f2865844c3293f2c80e0867f)
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4996
2014-10-28 08:07:21 -07:00
casey
543fa73f3a Standardize EXTRACT and add DATE_PART
The standard EXTRACT syntax is EXTRACT(<TIME UNIT> FROM <TIMESTAMP>) but
it was implemented as a regular function EXTRACT(<STRING>, <TIMESTAMP>).
The existing function will continue to be supported. We could deprecate
it but it doesn't seem like much of a burden to keep.

Adding DATE_PART is easy since it is functionally the same as the EXTRACT
function. The only difference is in the call signature. Besides the
difference in name, the arguments are reversed. Otherwise the two
functions are equivalent.

Change-Id: Ia6f9156624ed901723672469f94205c704839248
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4579
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
2014-10-08 16:44:37 -07:00
Victor Bittorf
177337dc33 length(CHAR(*)) function ignores spaces
Fixed length to behave like postgres for CHAR(*).

Change-Id: I817c74a4af73a3c0a9f5ea1d8ee36b520936395f
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4572
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: Victor Bittorf <victor.bittorf@cloudera.com>
2014-10-06 15:10:53 -07:00
Skye Wanderman-Milne
559b83d3d0 Expr refactoring
This patch changes the interface for evaluating expressions, in order
to allow for thread-safe expression evaluations and easier
codegen. Thread safety is achieved via the ExprContext class, a
light-weight container for expression tree evaluation state. Codegen
is easier because more expressions can be cross-compiled to IR.

See expr.h and expr-context.h for an overview of the API
changes. See sort-exec-exprs.cc for a simple example of the new
interface and hdfs-scanner.cc for a more complicated example.

This patch has not been completely code reviewed and may need further
cleanup/stylistic work, as well as additional perf work.

Change-Id: I3e3baf14ebffd2687533d0cc01a6fb8ac4def849
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/3459
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: Skye Wanderman-Milne <skye@cloudera.com>
2014-08-17 12:44:44 -07:00
Skye Wanderman-Milne
f062a22997 Convert string functions to UDF interface
This also switches to using the re2 library for regular expression
functions instead of boost.

Change-Id: I4c3ae72ff2f7cbd5b1a2be719275f1b2e25f8ab2
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/3412
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: Skye Wanderman-Milne <skye@cloudera.com>
2014-08-17 12:44:38 -07:00
Skye Wanderman-Milne
7a0cc27fd1 Convert math functions to the UDF interface.
Also adds FunctionContext::GetNumArgs() method to the public UDF API.

Change-Id: I76e21814e423f075a0a22b4e924c1d3ec26daba7
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/3410
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: Skye Wanderman-Milne <skye@cloudera.com>
2014-08-17 12:44:32 -07:00
Skye Wanderman-Milne
7d29de16bb Rewrite decimal functions/operators as UDFs.
This patch also adds a GetReturnType() method to FunctionContext. This
is staging for the expr refactoring.

Change-Id: I854e79ded409e151663c4ec99c4e08631ad9e03e
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/3234
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: Skye Wanderman-Milne <skye@cloudera.com>
2014-08-17 12:44:18 -07:00
Paden Tomasello
879a40913c Implemented UDFs for timestamp functions.
FromUtc and ToUtc use thirdparty libraries which use inline asm which
isn't currently supported with JIT. The UDFs are included in this
commit, but the function symbols were not changed in
impala_functions.py

Change-Id: I0824a434d4a26a39abf29bc6e47d51b5ad7991d6
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3390
Reviewed-by: Paden Tomasello <paden.tomasello@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 8e149ccd78010b7a22d6fff1b0de5614848b02ac)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3548
2014-07-21 15:27:46 -07:00
Victor Bittorf
778fba232c Adding MADlib vector operations.
These are basic UDFs which the user will need to interact with MADlib.

Change-Id: Iadcec2376e29d2f73f1bb04d5e695c58d9381952
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2368
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 2eac4ec1287e354c26c2b8916515307fe793fb93)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/3160
2014-06-19 14:48:59 -07:00
Skye Wanderman-Milne
a618d34f17 More decimal builtins.
Change-Id: Ie5b89ad7d1fc80fa646f7cf5f520db13b25b9565
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2764
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 6e994ce7712047000d3a12b5eb677b5470687370)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2830
2014-06-06 19:42:45 -07:00
Nong Li
8f4dc0f2f0 IMPALA-974: Switch from FloatLiteral to DecimalLiteral.
Float/Doubles are lossy so using those as the default literal type
is problematic.

Change-Id: I5a619dd931d576e2e6cd7774139e9bafb9452db9
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2758
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-05-31 22:19:06 -07:00
Nong Li
26ca559f38 Add decimal builtins: abs/round/ceil/floor/truncate.
Change-Id: I4fe0ee69475ff56d3dc0cd69ea21f677714ae8bc
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2748
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-05-30 11:53:06 -07:00
Victor Bittorf
0bb66ef327 Adding aliases ADD_MONTHS and SUB_MONTHS
This is a request for consistency with oracle.

Change-Id: I463a66694a068cd773532d8f6f853a4b089b918a
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2400
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 1f0b643789596f96c54580b8c5262fada4dfc958)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2502
2014-05-09 17:35:29 -07:00
Henry Robinson
38befd2126 IMPALA-724: Support infinite / nan values in text files
This patch allows the text scanner to read 'inf' or 'Infinity' from a
row and correctly translate it into floating-point infinity. It also
adds is_inf() and is_nan() builtins.

Finally, we change the text table writer to write Infinity and NaN for
compatibility with Hive.

In the future, we might consider adding nan / inf literals to our
grammar (postgres has this, see:
http://www.postgresql.org/docs/9.3/static/datatype-numeric.html).

Change-Id: I796f2852b3c6c3b72e9aae9dd5ad228d188a6ea3
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2393
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 58091355142cadd2b74874d9aa7c8ab6bf3efe2f)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2483
2014-05-08 12:28:53 -07:00
Henry Robinson
35d986cc8d Add max / min_*int() builtins
It would have been convenient today to know the largest values that
Impala accepts for its integer types. This patch adds max and min
builtins for our numeric types.

[localhost:21000] > select max_bigint(), max_int(), max_smallint(),
max_tinyint();
Query: select max_bigint(), max_int(), max_smallint(), max_tinyint()
+---------------------+------------+----------------+---------------+
| max_bigint()        | max_int()  | max_smallint() | max_tinyint() |
+---------------------+------------+----------------+---------------+
| 9223372036854775807 | 2147483647 | 32767          | 127           |
+---------------------+------------+----------------+---------------+

Change-Id: I6df6df2728197529c6375dbb1b7d3c9ddb9833d2
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2381
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2398
2014-04-29 16:54:31 -07:00
Victor Bittorf
46151dc7dd Adding EXTRACT builtin.
Change-Id: I6de20f336ecdfa3acd8d3a9166cff4a062baaacc
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2247
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
(cherry picked from commit f233955020ffbd1023f2d6adbbfb22e267986305)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2370
2014-04-25 15:38:51 -07:00
Victor Bittorf
c414c91931 Adding TRUNC builtin.
Includes additions to builtin UDF registration to support prepare/close.

Change-Id: I22668fa7ee033b3fa37050b7bccee935571ac453
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2243
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
2014-04-22 13:17:12 -07:00
Nong Li
87295a4e06 Decimal implementation.
This patch implements decimal support for text based formats.

Change-Id: I8e2c9e512ed149fe965216a72cb21fffd4f18e75
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1669
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
Reviewed-on: http://gerrit.ent.cloudera.com:8080/2238
Tested-by: jenkins
2014-04-14 21:07:32 -07:00
Srinath Shankar
23d394c572 IMPALA-1238: Impala supports length() but not char_length()
Adds aliases char_length and character_length for the length()
 builtin. These are valid for ASCII.

Change-Id: I934d997f2c6d372ed12e7221efc1a574d68e01f3
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1802
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1827
Reviewed-by: Srinath Shankar <sshankar@cloudera.com>
2014-03-08 16:53:49 -08:00
Srinath Shankar
985d90146e IMPALA-856:NULLIFZERO and ZEROIFNULL
Both nullifzero and zeroifnull apply only to numeric types.
nullifzero(arg) - Return NULL if arg == 0, arg otherwise
zeroifnull(arg) - Return 0 if arg is NULL, arg otherwise

Change-Id: I41260de1edca2f9fcf50594fe137ca1f68f76056
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1805
Reviewed-by: Srinath Shankar <sshankar@cloudera.com>
Tested-by: jenkins
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1826
2014-03-08 13:09:33 -08:00
Nong Li
f0a67153d3 Decimal analysis changes.
Change-Id: Ib7d6a6a7650cc9058ff1486fc7546ab66c698d46
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1734
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-03-03 21:15:00 -08:00