33#include " ast/AndExpr.hpp"
44#include " ast/Expression.hpp"
55#include " ast/FilterExpr.hpp"
6+ #include " ast/FilterOperation.hpp"
67#include " ast/Integral.hpp"
78#include " ast/Literal.hpp"
89#include " ast/OrExpr.hpp"
910
1011using clp_s::search::ast::AndExpr;
1112using clp_s::search::ast::Expression;
1213using clp_s::search::ast::FilterExpr;
14+ using clp_s::search::ast::FilterOperation;
1315using clp_s::search::ast::Integral;
1416using clp_s::search::ast::Integral64;
1517using clp_s::search::ast::literal_type_bitmask_t ;
@@ -63,16 +65,19 @@ EvaluatedValue EvaluateTimestampIndex::run(std::shared_ptr<Expression> const& ex
6365 range_it != m_timestamp_dict->tokenized_column_to_range_end ();
6466 range_it++)
6567 {
68+ // Don't attempt to evaluate the timestamp index against columns with wildcard tokens.
69+ if (column->is_unresolved_descriptor ()) {
70+ continue ;
71+ }
72+
6673 std::vector<std::string> const & tokens = range_it->first ;
6774 auto const & descriptors = column->get_descriptor_list ();
68- // TODO: handle wildcard matching; the initial check on timestamp index happens
69- // before schema matching, so
7075 if (tokens.size () != descriptors.size ()) {
7176 continue ;
7277 }
7378
7479 bool matched = true ;
75- for (size_t i = 0 ; i < descriptors.size (); ++i) {
80+ for (size_t i{ 0ULL } ; i < descriptors.size (); ++i) {
7681 if (tokens[i] != descriptors[i].get_token ()) {
7782 matched = false ;
7883 break ;
@@ -82,20 +87,21 @@ EvaluatedValue EvaluateTimestampIndex::run(std::shared_ptr<Expression> const& ex
8287 continue ;
8388 }
8489
85- EvaluatedValue ret;
86- // this is safe after type narrowing because all DateType literals are either
87- // Integral or a derived class of Integral
88- Integral64 literal = std::static_pointer_cast<Integral>(filter->get_operand ())->get ();
89- if (std::holds_alternative<int64_t >(literal)) {
90- ret = range_it->second ->evaluate_filter (
91- filter->get_operation (),
92- std::get<int64_t >(literal)
93- );
90+ auto const literal{filter->get_operand ()};
91+ if (nullptr == literal) {
92+ return EvaluatedValue::Unknown;
93+ }
94+
95+ EvaluatedValue ret{EvaluatedValue::Unknown};
96+ auto const filter_op{filter->get_operation ()};
97+ int64_t int_literal{};
98+ double float_literal{};
99+ if (literal->as_int (int_literal, filter_op)) {
100+ ret = range_it->second ->evaluate_filter (filter_op, int_literal);
101+ } else if (literal->as_float (float_literal, filter_op)) {
102+ ret = range_it->second ->evaluate_filter (filter_op, float_literal);
94103 } else {
95- ret = range_it->second ->evaluate_filter (
96- filter->get_operation (),
97- std::get<double >(literal)
98- );
104+ return EvaluatedValue::Unknown;
99105 }
100106
101107 if (ret == EvaluatedValue::True) {
0 commit comments