@@ -219,4 +219,40 @@ TEST(AnalyticsTests, AggregateNullHandling) {
219219 EXPECT_TRUE (result_batch->get_column (1 ).is_null (0 ));
220220}
221221
222+ TEST (AnalyticsTests, VectorizedExpressionAdvanced) {
223+ StorageManager storage (" ./test_analytics" );
224+ Schema schema;
225+ schema.add_column (" a" , common::ValueType::TYPE_INT64, true );
226+ schema.add_column (" b" , common::ValueType::TYPE_INT64, true );
227+
228+ auto batch = VectorBatch::create (schema);
229+ // Row 0: (10, 20)
230+ batch->append_tuple (Tuple ({common::Value::make_int64 (10 ), common::Value::make_int64 (20 )}));
231+ // Row 1: (NULL, 30)
232+ batch->append_tuple (Tuple ({common::Value::make_null (), common::Value::make_int64 (30 )}));
233+ // Row 2: (40, NULL)
234+ batch->append_tuple (Tuple ({common::Value::make_int64 (40 ), common::Value::make_null ()}));
235+
236+ // Test: (a IS NULL) OR (a > 20)
237+ auto col_a = std::make_unique<ColumnExpr>(" a" );
238+ auto is_null = std::make_unique<IsNullExpr>(std::move (col_a), false );
239+ auto col_a_2 = std::make_unique<ColumnExpr>(" a" );
240+ auto gt_20 =
241+ std::make_unique<BinaryExpr>(std::move (col_a_2), TokenType::Gt,
242+ std::make_unique<ConstantExpr>(common::Value::make_int64 (20 )));
243+
244+ BinaryExpr or_expr (std::move (is_null), TokenType::Or, std::move (gt_20));
245+
246+ NumericVector<bool > res (common::ValueType::TYPE_BOOL);
247+ or_expr.evaluate_vectorized (*batch, schema, res);
248+
249+ ASSERT_EQ (res.size (), 3U );
250+ // Row 0: (10 IS NULL) OR (10 > 20) -> FALSE OR FALSE -> FALSE
251+ EXPECT_FALSE (res.get (0 ).as_bool ());
252+ // Row 1: (NULL IS NULL) OR (NULL > 20) -> TRUE OR NULL -> TRUE
253+ EXPECT_TRUE (res.get (1 ).as_bool ());
254+ // Row 2: (40 IS NULL) OR (40 > 20) -> FALSE OR TRUE -> TRUE
255+ EXPECT_TRUE (res.get (2 ).as_bool ());
256+ }
257+
222258} // namespace
0 commit comments