Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dimension filtering with BETWEEN in date-type Dims #370

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions mytile/ha_mytile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2029,7 +2029,9 @@ const COND *tile::mytile::cond_push_func_datetime(
// We should add support at some point for handling functions (i.e.
// date_dimension = current_date())
for (uint i = 1; i < func_item->argument_count(); i++) {
if (args[i]->type() != Item::CONST_ITEM) {
if (args[i]->type() != Item::CONST_ITEM &&
func_item->functype() != Item_func::BETWEEN) {
// datetime args in 'BETWEEN' are not constants
DBUG_RETURN(func_item);
}
}
Expand Down Expand Up @@ -2211,21 +2213,24 @@ const COND *tile::mytile::cond_push_func_datetime(

break;
}
case Item_func::BETWEEN: {
case Item_func::BETWEEN:
neg = (dynamic_cast<const Item_func_opt_neg *>(func_item))->negated;
if (neg) // don't support negations!
DBUG_RETURN(func_item);
}
// fall through
case Item_func::LE_FUNC: // Handle all cases where there is 1 or 2 arguments
// we must set on
case Item_func::LT_FUNC:
case Item_func::GE_FUNC:
case Item_func::GT_FUNC: {
bool between = false;
// the range
Item_basic_constant *lower_const = nullptr;
Item_basic_constant *upper_const = nullptr;

Item *lower_item_between = nullptr;
Item *upper_item_between = nullptr;

// Get field type for comparison
Item_result cmp_type = args[1]->cmp_type();

Expand All @@ -2235,8 +2240,9 @@ const COND *tile::mytile::cond_push_func_datetime(

// If we have 3 items then we can set lower and upper
if (func_item->argument_count() == 3) {
lower_const = dynamic_cast<Item_basic_constant *>(args[1]);
upper_const = dynamic_cast<Item_basic_constant *>(args[2]);
between = true;
lower_item_between = args[1];
upper_item_between = args[2];
// If the condition is less than we know its the upper limit we have
} else if (func_item->functype() == Item_func::LT_FUNC ||
func_item->functype() == Item_func::LE_FUNC) {
Expand All @@ -2253,8 +2259,16 @@ const COND *tile::mytile::cond_push_func_datetime(
std::unique_ptr<void, decltype(&std::free)>(nullptr, &std::free),
func_item->functype(), tiledb_datatype_t::TILEDB_ANY, 0, 0});

int ret = set_range_from_item_datetime(ha_thd(), lower_const, upper_const,
cmp_type, range, datatype);
int ret;
if (between) {
ret = set_range_from_item_datetime(ha_thd(), lower_item_between,
upper_item_between, cmp_type, range,
datatype);
} else {

ret = set_range_from_item_datetime(ha_thd(), lower_const, upper_const,
cmp_type, range, datatype);
}

if (ret)
DBUG_RETURN(func_item);
Expand Down
Loading