|
16 | 16 |
|
17 | 17 | #include <optional>
|
18 | 18 | #include "velox/functions/prestosql/tests/utils/FunctionBaseTest.h"
|
| 19 | +#include "velox/functions/prestosql/types/JsonType.h" |
19 | 20 |
|
20 | 21 | using namespace facebook::velox;
|
21 | 22 | using namespace facebook::velox::test;
|
@@ -145,3 +146,40 @@ TEST_F(ArrayHasDuplicatesTest, nullFreeStrings) {
|
145 | 146 | auto expected = makeFlatVector<bool>({false, true, false, true});
|
146 | 147 | testExpr(expected, "array_has_duplicates(C0)", {array});
|
147 | 148 | }
|
| 149 | + |
| 150 | +TEST_F(ArrayHasDuplicatesTest, json) { |
| 151 | + auto arrayVector = makeNullableArrayVector<StringView>( |
| 152 | + {{R"({"key":"value"})", R"({"key":"value"})"}}, ARRAY(JSON())); |
| 153 | + testExpr( |
| 154 | + makeFlatVector<bool>(true), "array_has_duplicates(C0)", {arrayVector}); |
| 155 | + |
| 156 | + auto test = makeNullableArrayVector<StringView>( |
| 157 | + {{R"({"key":"value"})", R"({"key":"another_value"})"}, |
| 158 | + {R"({"key":"value"})"}, |
| 159 | + {R"({"key":"same_value"})", |
| 160 | + R"({"key":"another_value"})", |
| 161 | + R"({"key":"same_value"})"}, |
| 162 | + {std::nullopt, std::nullopt}, |
| 163 | + {R"({"key":"value"})", |
| 164 | + R"({"key":"another_value"})", |
| 165 | + R"({"another_key":"value"})"}, |
| 166 | + {R"({"key": "value\with\backslash"})", |
| 167 | + R"({"key": "value\with\backslash"})"}, |
| 168 | + {R"({"key": "value\nwith\nnewline"})", |
| 169 | + R"({"key": "value\nwith\nnewline"})"}, |
| 170 | + {R"({"key": "value with \u00A9 and \u20AC"})", |
| 171 | + R"({"key": "value with \u00A9 and \u20AC"})"}, |
| 172 | + {R"({"key": "!@#$%^&*()_+-={}:<>?,./~`"})", |
| 173 | + R"({"key": "!@#$%^&*()_+-={}:<>?,./~`"})"}, |
| 174 | + {R"({"key":"value"})", |
| 175 | + std::nullopt, |
| 176 | + R"({"key":"another_value"})", |
| 177 | + R"({"another_key":"value"})", |
| 178 | + std::nullopt}}, |
| 179 | + ARRAY(JSON())); |
| 180 | + testExpr( |
| 181 | + makeFlatVector<bool>( |
| 182 | + {false, false, true, true, false, true, true, true, true, true}), |
| 183 | + "array_has_duplicates(C0)", |
| 184 | + {test}); |
| 185 | +} |
0 commit comments