|
26 | 26 | namespace gandiva { |
27 | 27 |
|
28 | 28 | using arrow::boolean; |
| 29 | +using arrow::date32; |
29 | 30 | using arrow::date64; |
30 | 31 | using arrow::float32; |
31 | 32 | using arrow::int32; |
32 | 33 | using arrow::int64; |
| 34 | +using arrow::timestamp; |
33 | 35 |
|
34 | 36 | class TestProjector : public ::testing::Test { |
35 | 37 | public: |
@@ -130,6 +132,42 @@ TEST_F(TestProjector, TestIsNull) { |
130 | 132 | EXPECT_ARROW_ARRAY_EQUALS(exp_isnotnull, outputs.at(1)); |
131 | 133 | } |
132 | 134 |
|
| 135 | +TEST_F(TestProjector, TestDate32IsNull) { |
| 136 | + auto d0 = field("d0", date32()); |
| 137 | + auto schema = arrow::schema({d0}); |
| 138 | + |
| 139 | + // output fields |
| 140 | + auto b0 = field("isnull", boolean()); |
| 141 | + |
| 142 | + // isnull and isnotnull |
| 143 | + auto isnull_expr = TreeExprBuilder::MakeExpression("isnull", {d0}, b0); |
| 144 | + |
| 145 | + std::shared_ptr<Projector> projector; |
| 146 | + auto status = Projector::Make(schema, {isnull_expr}, TestConfiguration(), &projector); |
| 147 | + ASSERT_TRUE(status.ok()); |
| 148 | + |
| 149 | + int num_records = 4; |
| 150 | + std::vector<int32_t> d0_data = {0, 100, 0, 1000}; |
| 151 | + auto validity = {false, true, false, true}; |
| 152 | + auto d0_array = |
| 153 | + MakeArrowTypeArray<arrow::Date32Type, int32_t>(date32(), d0_data, validity); |
| 154 | + |
| 155 | + // expected output |
| 156 | + auto exp_isnull = |
| 157 | + MakeArrowArrayBool({true, false, true, false}, {true, true, true, true}); |
| 158 | + |
| 159 | + // prepare input record batch |
| 160 | + auto in_batch = arrow::RecordBatch::Make(schema, num_records, {d0_array}); |
| 161 | + |
| 162 | + // Evaluate expression |
| 163 | + arrow::ArrayVector outputs; |
| 164 | + status = projector->Evaluate(*in_batch, pool_, &outputs); |
| 165 | + EXPECT_TRUE(status.ok()); |
| 166 | + |
| 167 | + // Validate results |
| 168 | + EXPECT_ARROW_ARRAY_EQUALS(exp_isnull, outputs.at(0)); |
| 169 | +} |
| 170 | + |
133 | 171 | TEST_F(TestProjector, TestDateTime) { |
134 | 172 | auto field0 = field("f0", date64()); |
135 | 173 | auto field2 = field("f2", timestamp(arrow::TimeUnit::MILLI)); |
|
0 commit comments