| 284 | // Test that timestamp types work as inputs to in expressions |
| 285 | template <typename Type> |
| 286 | void TestDateOrTimeInExpression( |
| 287 | arrow::MemoryPool* pool, const DataTypePtr& type, |
| 288 | std::function<NodePtr(NodePtr, std::unordered_set<typename Type::c_type>)> |
| 289 | expression_factory) { |
| 290 | using c_type = typename Type::c_type; |
| 291 | |
| 292 | // schema for input fields |
| 293 | auto field0 = field("f0", type); |
| 294 | auto schema = arrow::schema({field0}); |
| 295 | |
| 296 | // Build f0 in (717629471, 717630471) |
| 297 | auto node_f0 = TreeExprBuilder::MakeField(field0); |
| 298 | std::unordered_set<c_type> in_constants({717629471, 717630471}); |
| 299 | auto in_expr = expression_factory(node_f0, in_constants); |
| 300 | auto condition = TreeExprBuilder::MakeCondition(in_expr); |
| 301 | |
| 302 | std::shared_ptr<Filter> filter; |
| 303 | auto status = Filter::Make(schema, condition, TestConfiguration(), &filter); |
| 304 | ASSERT_TRUE(status.ok()) << status.message(); |
| 305 | |
| 306 | // Create a row-batch with some sample data |
| 307 | int num_records = 5; |
| 308 | auto array0 = MakeArrowArray<Type, c_type>( |
| 309 | type, {717629471, 717630471, 717729471, 717629471, 717629571}, |
| 310 | {true, true, true, false, true}); |
| 311 | // expected output (indices for which condition matches) |
| 312 | auto exp = MakeArrowArrayUint16({0, 1}); |
| 313 | |
| 314 | // prepare input record batch |
| 315 | auto in_batch = arrow::RecordBatch::Make(schema, num_records, {array0}); |
| 316 | |
| 317 | std::shared_ptr<SelectionVector> selection_vector; |
| 318 | status = SelectionVector::MakeInt16(num_records, pool, &selection_vector); |
| 319 | ASSERT_TRUE(status.ok()) << status.message(); |
| 320 | |
| 321 | // Evaluate expression |
| 322 | status = filter->Evaluate(*in_batch, selection_vector); |
| 323 | ASSERT_TRUE(status.ok()) << status.message(); |
| 324 | |
| 325 | // Validate results |
| 326 | EXPECT_ARROW_ARRAY_EQUALS(exp, selection_vector->ToArray()); |
| 327 | } |
| 328 | |
| 329 | TEST_F(TestIn, TestInDate32) { |
| 330 | TestDateOrTimeInExpression<arrow::Date32Type>( |