| 481 | }; |
| 482 | |
| 483 | TEST_P(ParameterizedExprTest, moreEncodings) { |
| 484 | const vector_size_t size = 1'000; |
| 485 | std::vector<std::string> fruits = {"apple", "pear", "grapes", "pineapple"}; |
| 486 | VectorPtr a = makeFlatVector<int64_t>(size, [](auto row) { return row; }); |
| 487 | VectorPtr b = vectorMaker_.flatVector(fruits); |
| 488 | |
| 489 | // Wrap b in a dictionary. |
| 490 | auto indices = |
| 491 | makeIndices(size, [&fruits](auto row) { return row % fruits.size(); }); |
| 492 | b = wrapInDictionary(indices, size, b); |
| 493 | |
| 494 | // Wrap both a and b in another dictionary. |
| 495 | auto evenIndices = makeIndices(size / 2, [](auto row) { return row * 2; }); |
| 496 | |
| 497 | a = wrapInDictionary(evenIndices, size / 2, a); |
| 498 | b = wrapInDictionary(evenIndices, size / 2, b); |
| 499 | |
| 500 | auto result = |
| 501 | evaluate("if(c1 = 'grapes', c0 + 10, c0)", makeRowVector({a, b})); |
| 502 | ASSERT_EQ(VectorEncoding::Simple::DICTIONARY, result->encoding()); |
| 503 | ASSERT_EQ(size / 2, result->size()); |
| 504 | |
| 505 | auto expected = makeFlatVector<int64_t>(size / 2, [&fruits](auto row) { |
| 506 | return (fruits[row * 2 % 4] == "grapes") ? row * 2 + 10 : row * 2; |
| 507 | }); |
| 508 | assertEqualVectors(expected, result); |
| 509 | } |
| 510 | |
| 511 | TEST_P(ParameterizedExprTest, reorder) { |
| 512 | constexpr int32_t kTestSize = 20'000; |
nothing calls this directly
no test coverage detected