CDH-20905: Disable Sequence Writer Test

Disable the test to unblock builds.

Change-Id: Ie06df7dbca13be7775798cc56ba8325e8877587e
Codegen AVG

This uses the same logic as NDV, i.e. cross-compiling the Update and
Merge functions.

Change-Id: I93b5658402e1bfeed141a53f8e52f82952838e45
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4303
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
Fix spilling with aggregated exprs with string slots.

This patch also does some clean up on agg-fn-evaluator to support this case.

Change-Id: If7e5c8663c7d371b2666acaab2966a2cd7bdccf9
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4256
Tested-by: jenkins
Reviewed-by: Nong Li <nong@cloudera.com>
IMPALA-1230: Uncorrelated non-scalar subquery accepted in binary
predicate

This commit fixes the issue where an uncorrelated non-scalar subquery
with distinct in the select list is accepted in a binary predicate. The
issue is fixed by adding a proper check for a distinct clause in the
select list of a subquery when evaluating the subquery's return type
(scalar or non-scalar).

Change-Id: I7a207c89502a6db589d5288aeaf4e54b43122c41
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4316
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: jenkins
Fix char test to only run on test/none.

Change-Id: I8f5ac5a6e7399ce2fdbe78d07ae24deaa1d7532d
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4326
Tested-by: jenkins
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Speed up PHJ.

This patch does a few things to speed up probe performance by ~50% in a fact to dim
table join on a single int64 key.

- Change IR function to return int instead of status. This doesn't change performance
but makes the IR much easier to read.
- Switch from FNV to murmur2 hash. I had done some experiments before and this function
is much faster than FNV and produces better hashes.
- Remove some unnecessary state in HashTableCtx that was not necessary and generating
load/stores.
- Cache the per partition hash table instead of walking the hash_partitions_ structure.

This takes us from roughly 2x slower from v1.4 to ~35% slower. If I switch the hash
function to CRC (like in v1.4) the perf difference is <5%. In a follow up patch, we'll
probably have to use CRC as the first level to get perf parity in the non-spilling
case.

Change-Id: I7481a35ed767d4817e78d06fe85016408620a85a
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4325
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: jenkins
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
Codegen SUM(decimal)

On a simple local benchmark that sums a decimal column, this improves
query time by ~4x.

Change-Id: I4968a31c66f94ac55b1d3a6e51707f72b81b662a
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4341
Reviewed-by: Skye Wanderman-Milne <skye@cloudera.com>
Tested-by: jenkins
IMPALA-1257: Fix asan issue with string literals.

Change-Id: I31a24a3323081b6486bf7baf450f8fb2fdc56ec5
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4363
Reviewed-by: Ippokratis Pandis <ipandis@cloudera.com>
Tested-by: jenkins
IMPALA-1105 : TRUNC(TIMESTAMP) malformed input from cast

Fixed crash when TRUNC(TIMESTAMP) was passed malformed timestamp values. The fix
is for CAST(STRING to TIMESTAMP), returns NULL when STRING is malformed.

Change-Id: Ie13395d740b2587dfb59c2f677b3ed3d0d4e992f
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/3583
Reviewed-by: Victor Bittorf <victor.bittorf@cloudera.com>
Tested-by: jenkins
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>
Properly initialize variables in DecimalAvgGetValue.

This was causing the ASAN failures.

Change-Id: I31b7ea4059d2ac6be295b2f5c19339b79ed3b30e
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4374
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
IMPALA-1228 Incorrect rewrite of scalar agg subquery

This commit fixes an issue where, for the case of a scalar agg subquery
with count, the zeroifnull fn is applied to the wrong column during
query rewrite.

This commit also fixes IMPALA-1237.

Change-Id: Ic00ae5799d6970171c007e3ed25348d7fc09d825
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4286
Reviewed-by: Dimitris Tsirogiannis <dtsirogiannis@cloudera.com>
Tested-by: jenkins
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>
Fixed bugs in BufferedBlockMgr and PA.

In the case of OOM in the BufferedBlockMgr, it was returning a dangling
block pointer instead of NULL.

In PA, when spilling, there was the possibility of forgetting to finalize
the last tuple we tried to add, leading to leaked memory in the UDA.

Change-Id: Id77037aec6b351c19ec8338198a98f0b74d7addc
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4383
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
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
Add metrics for number of spilled queries and total spilled bytes written.

Change-Id: Icdd06b6c2310d126278ad4c2e9f8280b4835d6f4
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4384
Reviewed-by: Nong Li <nong@cloudera.com>
Tested-by: Nong Li <nong@cloudera.com>
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>
Fix CompoundPredicate::CodegenComputeFn

The codegen'd function was returning false instead of NULL

Change-Id: I481b5b82e3336a71c2a55a7be326af8d39a4d510
Reviewed-on: http://gerrit.sjc.cloudera.com:8080/4394
Tested-by: jenkins
Reviewed-by: Nong Li <nong@cloudera.com>
IMPALA-1243: Incorrect plan in analytic using inline view

Prevent predicate propagation into inline views containing analytic exprs by
a) not explicitly pushing predicates into such inline views
b) blocking the propagation path by not registering auxiliary eq predicates for the inline view

Change-Id: Ie2961d36a532f6b4603a4edbe7dd9cf0a6882d75