Commit Graph

400 Commits

Author SHA1 Message Date
Henry Robinson
080299730c IMPALA-1298: Add var_{pop,samp} as aliases for variance_{pop,samp}
Change-Id: I5880ad7ebf0775704ee7fa08685928224e316458
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4656
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins
2014-10-06 15:12:25 -07:00
Nong Li
a1b2de9c95 Update distinctpc/pcsa to return bigint.
Change-Id: Iac3414aa0151f52ba9ec028da152b09fc09af264
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4637
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-10-06 15:12:12 -07:00
Matthew Jacobs
8b1b8f5780 IMPALA-1302: Incorrect result of FIRST_VALUE query
FIRST_VALUE with row offsets preceding did not produce the correct
results. This fix changes the rewrite for FIRST_VALUE and adds
additional handling for NULLs in the backend.

Change-Id: I03d54c05f63f46e9adb467008fa876ab33812c7b
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4648
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
2014-10-06 15:12:03 -07:00
Matthew Jacobs
86b9f8282f Move aggregation tests on decimal tables to decimal.test
Fixes test failures in exhaustive mode when aggregation tests
are run on table formats that do not support decimal.

Change-Id: Ic5dfb398575770cf318ffcc0ce3a20737bb2f5cd
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4636
Reviewed-by: Lenni Kuff <lskuff@cloudera.com>
Tested-by: jenkins
2014-10-06 15:11:58 -07:00
Matthew Jacobs
8f0c206bdd IMPALA-1087: Fix error handling loading libraries in LibCache
If an error occurred loading a library in LibCache (e.g. by using
CREATE FUNCTION) an error is returned but a cache entry may still
exist which may result in strange errors later when the cache
entry is accessed by subsequent queries.

This changes LibCache::GetCacheEntry to ensure cache entries do
not exist if errors occur. Because GetCacheEntry needs to take
the global lock and then the cache entry lock, but needs to
unlock the global lock before performing slow HDFS operations,
we set the error status on the cache entry so that all locks
can be released when an error occurs. Other threads that attempt
to access the cache entry check the status and return if it is
not OK. The first thread (the thread that got the error) can
then remove the cache entry whenever it is able to again acquire
the global lock_.

Change-Id: I00fd0e2a4611b06fa72ffe0aaaa7d077b7a0c36e
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4642
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
2014-10-06 15:11:43 -07:00
Matthew Jacobs
928907905b Fix appx_median to return correct result type
Change-Id: Ifc54e1069e2f7a46242229d710943e921633a920
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4625
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
2014-10-06 15:11:27 -07:00
Victor Bittorf
658f05f63c IMPALA-1316: crash on VARCHAR join
Fixed codegen issue casing some VARCHAR joins to crash.

Change-Id: Ib2674199a3b2c3c5a5fd63cfae0b64e3b1ca158b
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4616
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
2014-10-06 15:11:10 -07:00
Ippokratis Pandis
5c4486a2b2 Proper handling of NULL tuples by buffered-tuple-stream.
Adding a bitstring at the head of each block in the TupleStream that indicates which
tuples of the appended rows in the block are NULLs. When reading the stream, through
GetNext() or GetTupleRow() calls, the NULL tuples are stitched back to their correct
position.

This fixes crashes in PHJ of bushy plans with NULLs on the build side(s) as well as
similar crashes in PAGG and the analytic node.
For example, it fixes IMPALA-1204, IMPALA-1223, and IMPALA-1249.
Also, adds regression tests for IMPALA-1175, IMPALA-1204, IMPALA-1223, IMPALA-1249
and IMPALA-1306.

Change-Id: I30ad0dbd4dfeabcda8fae444d1c6ec9291f38398
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4596
Reviewed-by: Ippokratis Pandis <ipandis@cloudera.com>
Tested-by: jenkins
2014-10-06 15:10:58 -07:00
Dimitris Tsirogiannis
5db0f877cb Fix subqueries test for HBase
Change-Id: I8d3c10d29a198135e87ab848ba206c2662166760
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4597
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: jenkins
2014-10-06 15:09:37 -07:00
Dimitris Tsirogiannis
b201c7a7d1 IMPALA-1299: Analytic should be allows in correlated EXISTS subquery
With this commit we enable correlated and uncorrelated EXISTS
subqueries with grouping and/or aggregation including analytic
functions. Furthermore, we enable correlated EXISTS subqueries
with a LIMIT clause.

Change-Id: I36c33f80b152b7f175bf803cbe920ce1983d7162
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4583
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: jenkins
2014-10-06 15:09:25 -07:00
Nong Li
4d2da72698 IMPAL-1312: Fix num_pinned tracking in BufferedTupleStream.
Change-Id: I04264ef25ba8d43826e65f98d34135e7b3593f8b
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4582
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
2014-10-06 15:09:20 -07:00
ishaan
010cc22a2f [CDH5] Fix test spilling.
tpch in cdh5 does not have double columns. Also, remove round calls to test that we get
consistent results.

Change-Id: Ia45ef08644ed78b05a08c47422733ab38a26b508
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4595
Reviewed-by: Ishaan Joshi <ishaan@cloudera.com>
Tested-by: Ishaan Joshi <ishaan@cloudera.com>
2014-09-26 22:57:02 -07:00
ishaan
a7c87bb250 [CDH5] Fix tpcds analytical functions test.
There was a new test file in cdh4 which had the wrong datatypes for tpcds.

Change-Id: Ide1300d0a539d1f40a4c0763b44d06fd81c96204
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4590
Reviewed-by: Ishaan Joshi <ishaan@cloudera.com>
Tested-by: Ishaan Joshi <ishaan@cloudera.com>
2014-09-26 16:56:40 -07:00
Victor Bittorf
dbaf718221 IMPALA-1185: Make Avro and Seq writers unsupported
Avro and Sequence writers are only available if query option
ALLOW_UNSUPPORTED_FORMATS is set to true, prints an error otherwise.

Change-Id: I597039f7c68f708fda10f848531eb557d6910f92
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4539
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-09-26 12:28:03 -07:00
Nong Li
d5c948c351 Increase the mem limit for one of the spilling queries.
Change-Id: I9b52582b2ded82821ecc446762f07d7702dedabf
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4555
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
2014-09-26 12:27:29 -07:00
casey
9a72c28832 Add DECODE builtin
This adds DECODE functionality into the existing CaseExpr class. There
will be no separate backend impementation for DECODE, it will be sent to
the backend as a CASE expr so the existing codegen function can be used.

Because Oracle does cast checking during execution and Impala cast
checking during analysis, some uses of DECODE that are valid in Oracle
are invalid in Impala.

Ex:

  SELECT DECODE(foo, bar, int_col, baz, string_col_containing_only_ints)
  FROM ...

  would be run on Oracle. If string_col_containing_only_ints actually
  contained non-INTs, an error would be thrown during execution and no
  results would be returned. In Impala an error is thrown during analysis.
  If a CAST was added to the STRING column, a cast failure would result in
  NULL.

Change-Id: Ia08cc2389abb6f843bba117e7091c659ad25ff41
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4334
Tested-by: jenkins
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Casey Ching <casey@cloudera.com>
2014-09-26 12:26:46 -07:00
Nong Li
f03b05ed50 Fix hash table buckets to allocate memory from the BlockMgr.
This was always a TODO. We want memory to come from the block mgr and trigger spilling.

Change-Id: I07f1f79fbbb33068fb2df64510a80a9b008ef73d
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4466
Tested-by: jenkins
Reviewed-by: Nong Li <nong@cloudera.com>
2014-09-26 12:26:09 -07:00
Victor Bittorf
af4b2086dc Char PARQUET, AVRO, and TEXT tests
Adds fixes and tests for Hive CHAR & VARCHAR compatibility.
Also fixes a bug in tuple materialization for VARCHAR and non in-lined CHAR.

Change-Id: I400b089cb8ddba2e264ef9f2e37956b2ceaaf9fb
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4054
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
2014-09-26 12:24:07 -07:00
Matthew Jacobs
b99fe95b7c IMPALA-1293: Fix DCHECK failure with window ROWS BETWEEN UNBOUNDED PRECEDING
Change-Id: I4e92e9593402f4341826c6940e23e493c7d23641
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4487
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
2014-09-26 12:03:40 -07:00
Matthew Jacobs
f75fc4337a IMPALA-1296: Fix DCHECK failure for unnecessary buffered tuple in AnalyticNode
The AnalyticEvalNode had a DCHECK that expected the buffered tuple to
only be set when it was needed (i.e. when there are partition exprs or
order by exprs). However, the FE creates a buffered tuple for an entire
sort group when any AnalyticEvalNodes in the sort group need it and that
tuple is set for all nodes. This reverses the logic so that we DCHECK
the buffered tuple is set when it is needed.

Change-Id: If54b303bc439f235da06a542b46a35c61da9e1bd
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4489
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
2014-09-26 12:03:06 -07:00
Matthew Jacobs
e3c8d2fe7e Analytic fn query test for IMPALA-1280 needs VERIFY_IS_EQUAL_SORTED
Change-Id: Iefb232a501a97a0f0351fd0794c7a3bfc279f98c
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4513
Reviewed-by: Ippokratis Pandis <ipandis@cloudera.com>
Tested-by: jenkins
2014-09-26 12:03:00 -07:00
Victor Bittorf
afbc2c28a3 Char Partition Fix
Fixed bug CHAR and VARCHAR partition columns. Also, disables CHAR and VARCHAR for UDAs
and UDFs.

Change-Id: I67ccd746cb4c063f8a7a984df9564fa9122fdf43
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4493
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-09-26 12:02:54 -07:00
Dimitris Tsirogiannis
5046a47dc3 IMPALA-1297: Results of NOT IN may not be correct if subquery results in
NULL

This commit fixes a bug in the implementation of the null-aware anti
join that resulted in wrong results being returned from NOT IN correlated
subqueries in the presence of nulls.

Change-Id: I6f2eb326ec7e40d80ec8da94ba33946b9ac9b115
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4506
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: jenkins
2014-09-26 12:02:47 -07:00
Taras Bobrovytsky
9e67b4a401 Analytic functions tests
Added several tests for analytical functions

Tests for the following have not been added because it's not implemented yet:
- Lag, Lead functions
- Window clauses

Change-Id: I34546c967a6d29c97327f4cba405006a50867dcb
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4307
Reviewed-by: Taras Bobrovytsky <tbobrovytsky@cloudera.com>
Tested-by: jenkins
2014-09-26 11:26:05 -07:00
Marcel Kornacker
3edeef53d8 Fix for bug in AnalyticExpr.resetAnalysisState()
Fixes:
IMPALA-1256: Nested analytic: AnalysisException: select list expression not produced by aggregation output
IMPALA-1280: Crash running analytic with LEFT SEMI JOIN

Change-Id: I98b8f90de0079afad5b2d547abc27bcee57651f3
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4500
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
2014-09-25 19:37:02 -07:00
Skye Wanderman-Milne
f2b01997df Allow UDA intermediates to use CHAR. Update stddev/var to use it.
Change-Id: I791c6389978f4994cba33f01273e94343a163916
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4368
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
2014-09-25 19:37:02 -07:00
Skye Wanderman-Milne
7f87e7e5b5 IMPALA-1111: Fix alignment in ReservoirSample aggregate functions
Change-Id: Iac7aa96eb19079715a7e8152a5edfeafa0d50bc7
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4478
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
2014-09-25 19:37:02 -07:00
Dimitris Tsirogiannis
f21aed16fd Bug fixes in null-aware anti-join
This commit fixes issue IMPALA-1215 where NOT IN subqueries return wrong
results in the presence of null values.

Change-Id: I97e41c8df8ba864d0189595d670b3f0349fcad36
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4467
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
2014-09-23 07:33:23 -07:00
Dan Hecht
47a11578d4 IMPALA-1272: fix crash when compression codec is invalid for parquet
Defer resizing the columns_ vector until we are sure we will initialize it.
Downstream code doesn't expect any NULLs.

Change-Id: I250cceee5181428fcd3cd1a8b021edb7187ae888
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4465
Reviewed-by: Daniel Hecht <dhecht@cloudera.com>
Tested-by: jenkins
2014-09-23 07:33:13 -07:00
Matthew Jacobs
28fc8ddf60 IMPALA-1292: Incorrect result in analytic SUM when ORDER BY column is null
The 'less than' predicate created by AnalyticPlanner used to check if the
previous row was less than the current row is not exactly what we want
to determine when rows in RANGE windows (the default window in this case)
share the same result values. Rows get the same results when the order by
exprs evaluate equally or both null, so it's easiest (and more efficient)
to use a predicate that simply checks equality or both null. We already
create such predicates for checking for partition boundaries, so this is
a trivial change.

When we support arbitrary RANGE window offsets we will likely want to
add similar predicates that compare two tuples plus/minus the offset,
but those will be simpler because there can be only one order by expr
when specifying RANGE offsets with PRECEDING/FOLLOWING.

Change-Id: I52ff6203686832852430e498eca6ad2cc2daee98
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4474
Tested-by: jenkins
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: Matthew Jacobs <mj@cloudera.com>
2014-09-23 07:32:43 -07:00
Matthew Jacobs
08a5204594 Analytic Fns: BE support for range unbounded on both sides and range offsets fail analysis
1) Adds BE support for RANGE windows between UNBOUNDED PRECEDING to
   UNBOUNDED FOLLOWING.
2) RANGE windows with offset boundaries fail analysis because they're
   not supported by the BE yet.

Change-Id: I734575eb87c909d09d24c4df028023f3b50d3cb5
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4442
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: Matthew Jacobs <mj@cloudera.com>
2014-09-23 07:32:21 -07:00
Victor Bittorf
9939c9d009 Bugfix and tests for CHAR(N) and VARCHAR(N)
Fixed a bug when setting the length in reading/write text files for CHAR(N).
Also added chars_tiny table for testing CHAR(N) and VARCHAR(N).

Change-Id: If5d5db30afa4b00cf03c68c6a845f182970329f4
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4415
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
2014-09-23 07:30:07 -07:00
Matthew Jacobs
8a75e759cb Move analytic fns test case for decimal to decimal.test
Change-Id: Ic6e02484f47f9a9c47924850c8cf12daf8574c8c
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4449
Reviewed-by: Ippokratis Pandis <ipandis@cloudera.com>
Tested-by: jenkins
2014-09-23 07:26:32 -07:00
Matthew Jacobs
da5198e615 Add spilling test for an analytic fn
Change-Id: Ia93c71c9c2a01f7f04a81593d51f5ca565286b7d
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4447
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-09-23 07:26:09 -07:00
Alex Behm
8345494fb1 IMPALA-1249: Anti joins have a uni-directional value transfer.
Like left/right outer joins, anti joins have a uni-directional value transfer.
Predicates could be pushed into anti joined plan subtrees if the condition
was inverted, but this patch does not implement this optimization.

No special consideration must be made to prevent predicate assignment
into anti-joined branches because anti-joined tuples are invisible outside
of the On-clause, and therefore, all unassigned conjuncts referencing the
invisible tuple must come from the original join's On-clause. The assignment
of such predicates is already handled correctly.

Change-Id: Ic2b94f6eb57e000ea51e253035e713288b205298
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4425
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
2014-09-23 07:25:51 -07:00
Nong Li
8a661d0787 [CDH5] cherry pick conflicts.
Change-Id: Ic11237b7ead4a810b523d6b6095781efbc5bb66b
2014-09-20 19:41:42 -07:00
Dimitris Tsirogiannis
3b5f1d3ab5 Rewrite NOT IN subqueries with a null-aware anti-join.
This commit fixes the issue (IMPALA-1215) where NOT IN subqueries return
wrong results in the presence of NULL values. The null-matching equality
operator is introduced in the front-end and the NOT IN subqueries are
rewritten using the null-aware anti-join operator.

Change-Id: I5a323357025d77c2143db86e1057999ec8a371c0
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4391
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: jenkins
2014-09-20 16:13:49 -07:00
Matthew Jacobs
8de30cbdb6 Simplify FIRST_VALUE analytic function implementation
Change-Id: I290adcaf50e9f5d5831eab4d67513d251e5fbe3e
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4418
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
2014-09-20 16:13:14 -07:00
Matthew Jacobs
9ffb9069b6 Fix multiple bugs in analytic fns BE and improved/consolidated tests
1) Fix ROWS following start bound where window is never fully in partition
2) Fix sum() NULL handling over sliding windows and add/consolidate tests.
   sum() should return NULL when all non-NULL values are removed. Because
   sum only stores the current sum as the intermediate value, we can't know
   if the sum is actually 0 or if there are no non-NULL values in the window.
   (avg() doesn't have this problem because it explicitly keeps the count
   of the number of elements in the average as part of the intermediate state.)
   Instead of changing sum() to have more intermediate state (which would
   affect aggregations), we can just keep track of the number of calls to
   Update() and Remove() in the FunctionContextImpl and check in SumRemove()
   whether or not there are any non-null elements being summed. Added
   tests (verified with Oracle).
3) Fixed a bug where the state tracking the last result tuple could be
   wrong and resulting in a crash.
4) IMPALA-1269: Windows between a start offset to CURRENT ROW might could
   produce wrong results between partitions.
5) IMPALA-1273: Incorrect results with very large window and small table

Tests are included for all issues.

Change-Id: I0f396c24078a1494fb977e8775f1ca8c530932eb
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4397
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
2014-09-20 16:12:44 -07:00
Nong Li
6b73eec02d PHJ: Fix block management when spilling.
The previous code did not handle well the case where the spilling happens when
building the hash table (i.e. partitioning the build rows fit). This caused the
probe partition to be starved causing queries that should be able to run to fail
with a not enough buffers error.

Change-Id: I3a9a84e8800a72ed3ce6f5ab7ff03bc2d6eb7ad8
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4403
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
2014-09-20 16:12:21 -07:00
Victor Bittorf
6289121261 CHAR(N) Followup Patch
This patch addresses:
  1. Char doesn't use codegen
  2. Not in-lining large CHAR(N) for N > 128
  3. Parquet reader/writer for CHAR(N) and VARCHAR(N)

Change-Id: I83a29a8bd312841a3e29bfe2243884074570f247
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4280
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
2014-09-20 16:12:03 -07:00
Skye Wanderman-Milne
2a449651da Use CRC hash for 0th partition level.
Change-Id: Ie845e0edb684f13421eea41327b1571b368db21a
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4370
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-09-20 16:11:40 -07:00
Alex Behm
0fb380961c IMPALA-1187: Add appx_count_distinct query option to rewrite COUNT(DISTINCT) to NDV().
This patch also fixes IMPALA-1164: NDV() now returns a BIGINT (and not STRING).

Change-Id: Ia2a3272204938579d61091ee4f7f2d1cbf38ed55
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4338
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
2014-09-20 16:11:34 -07:00
Alex Behm
ae7f59a65a Cost-based inversion of outer, semi and cross joins.
Change-Id: I7ce8847aadb5028ea5655ef2437ad31ab277e6de
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4323
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
2014-09-20 16:11:25 -07:00
Matthew Jacobs
0facf61296 Analytic Functions: BE support for ROWS windows with arbitrary start bounds
Adds support in the BE AnalyticEvalNode for ROWS windows with arbitrary
start bounds. If there is a start bound specified a sliding window must
be maintained. As input rows are processed they are added to the window.
As they expire from the window, they are 'removed' from the current
intermediate state of the evaluators (stored in curr_tuple_) by calling
AggFnEvaluator::Remove(). This is an initial implementation that keeps
the tuples in the window in memory. We can improve this later by using
the BufferedTupleStream with an Iterator interface supporting multiple
readers.

This also fixes IMPALA-1253: LAST_VALUE returns incorrect results

Change-Id: Id5daf6c060ab4079bb8dacf2db8992985894a820
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4335
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: Matthew Jacobs <mj@cloudera.com>
2014-09-20 16:08:12 -07:00
Victor Bittorf
a1892a17d5 IMPALA-1248: Fixed CHAR(N) in VALUES clause.
Queries like;
INSERT INTO table VALUES (CAST("..." AS CHAR(N)))
Used codegen path and failed; changed to use interpreted path.

Change-Id: Id80274580df268b3f828dec19a2e0b0578061ca8
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4362
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
2014-09-20 16:07:16 -07:00
Alex Behm
7355d9c221 IMPALA-1247: In a 2-phase agg the 1st phase should output its intermediate tuple.
Change-Id: I8f7ba0551099b6cf524baf6bd6f848d02896418d
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4378
Tested-by: jenkins
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
2014-09-20 16:07:06 -07:00
ishaan
c4b4e010ff Buffered Tuple Stream fixes.
This patch fixes two issues:
  - Add API to buffered block mgr to allow an atomic Unpin and GetNewBlock. This has
    the semantics of unpinning a block and giving the buffer to the new block. This
    is necessary for the tuple stream to make sure another thread does not grab the
    unpinned block in between.
  - Buffer management reading an unpinned stream. Before moving onto a new block (and
    unpinning the current), we need to make sure all the tuples returned from the
    current block are returned up the operator tree.

Change-Id: I95ee58d1019dd971f6a7dc19ecafdfa54cdbf942
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4333
Tested-by: jenkins
Reviewed-by: Nong Li <nong@cloudera.com>
2014-09-20 16:05:11 -07:00
Skye Wanderman-Milne
f8905ea485 Fix AVG codegen
We weren't returning the right merge function for decimal in
GetAvgFunction(). Someday the functions will be registered in the FE
like for scalar functions.

Change-Id: I1153ef8570b0e78f0925b7d3d58ec3b0fbb2c589
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4336
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
2014-09-20 16:02:47 -07:00
Lenni Kuff
9e43e4b5e8 [CDH5] Add support for SHOW GRANT ROLE <roleName> [ON <privilege spec>]
Adds support for displaying all or a subset of the privileges granted to a role. Users
have privileges to execute this statement if they are already granted the role or if
they are an admin user on the Sentry Policy Service. The output includes:
* The target scope of the privilege
* The privilege level
* The target names in the object hierarchy
* Whether the privilege was granted using WITH GRANT OPTION
* The create time of the privilege

Examples:
-- Show all grants in role1
SHOW GRANT ROLE role1

-- Shows all grants in role1 on the database foo
SHOW GRANT ROLE role1 on DATABASE foo

Output looks like:
+----------+------------+-------+-----+-----------+--------------+-------------------------------+
| scope    | database   | table | uri | privilege | grant_option | create_time                   |
+----------+------------+-------+-----+-----------+--------------+-------------------------------+
| DATABASE | functional |       |     | ALL       | false        | Fri, Sep 19 2014 16:13:40.999 |
+----------+------------+-------+-----+-----------+--------------+-------------------------------+

Change-Id: I8ef1b87a4c22c8fba4228012668033d7f9d06fcb
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4389
Reviewed-by: Lenni Kuff <lskuff@cloudera.com>
Tested-by: jenkins
2014-09-19 21:08:05 -07:00