From e18493382baa37b12fdde265345855ae39032fae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20=C8=98uhan?= Date: Tue, 19 Jan 2016 14:44:32 -0800 Subject: [PATCH] Handle group by all null columns The metadata holds the init values in the case a column is all nulls, we need to account for it. Fixes #145. --- QueryEngine/ExpressionRange.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/QueryEngine/ExpressionRange.cpp b/QueryEngine/ExpressionRange.cpp index 09c02c8b7d..e1516aea55 100644 --- a/QueryEngine/ExpressionRange.cpp +++ b/QueryEngine/ExpressionRange.cpp @@ -280,7 +280,12 @@ ExpressionRange getExpressionRange(const Analyzer::ColumnVar* col_expr, } const auto min_val = extract_min_stat(min_it->second.chunkStats, col_ti); const auto max_val = extract_max_stat(max_it->second.chunkStats, col_ti); - CHECK_GE(max_val, min_val); + if (max_val < min_val) { + CHECK_LT(max_val, 0); + CHECK_GT(min_val, 0); + CHECK_EQ(-(min_val + 1), max_val); + return ExpressionRange::makeIntRange(0, -1, 0, has_nulls); + } return ExpressionRange::makeIntRange(min_val, max_val, 0, has_nulls); } default: