| 209 | } // namespace |
| 210 | |
| 211 | void CheckDictionary(const std::string& func_name, const DatumVector& args, |
| 212 | bool result_is_encoded) { |
| 213 | auto actual = CheckDictionaryNonRecursive(func_name, args, result_is_encoded); |
| 214 | |
| 215 | if (actual.is_scalar()) return; |
| 216 | ASSERT_TRUE(actual.is_array()); |
| 217 | ASSERT_GE(actual.length(), 0); |
| 218 | |
| 219 | // Check all scalars |
| 220 | for (int64_t i = 0; i < actual.length(); i++) { |
| 221 | CheckDictionaryNonRecursive(func_name, GetDatums(GetScalars(args, i)), |
| 222 | result_is_encoded); |
| 223 | } |
| 224 | |
| 225 | // Check slices of the input |
| 226 | const auto slice_length = actual.length() / 3; |
| 227 | if (slice_length > 0) { |
| 228 | CheckDictionaryNonRecursive(func_name, SliceArrays(args, 0, slice_length), |
| 229 | result_is_encoded); |
| 230 | CheckDictionaryNonRecursive(func_name, SliceArrays(args, slice_length, slice_length), |
| 231 | result_is_encoded); |
| 232 | CheckDictionaryNonRecursive(func_name, SliceArrays(args, 2 * slice_length), |
| 233 | result_is_encoded); |
| 234 | } |
| 235 | |
| 236 | // Check empty slice |
| 237 | CheckDictionaryNonRecursive(func_name, SliceArrays(args, 0, 0), result_is_encoded); |
| 238 | |
| 239 | // Check chunked arrays |
| 240 | if (slice_length > 0) { |
| 241 | DatumVector chunked_args; |
| 242 | chunked_args.reserve(args.size()); |
| 243 | for (const auto& arg : args) { |
| 244 | if (arg.is_array()) { |
| 245 | auto arr = arg.make_array(); |
| 246 | ArrayVector chunks{arr->Slice(0, slice_length), arr->Slice(slice_length)}; |
| 247 | chunked_args.push_back(std::make_shared<ChunkedArray>(std::move(chunks))); |
| 248 | } else { |
| 249 | chunked_args.push_back(arg); |
| 250 | } |
| 251 | } |
| 252 | CheckDictionaryNonRecursive(func_name, chunked_args, result_is_encoded); |
| 253 | } |
| 254 | } |
| 255 | |
| 256 | void CheckScalarUnary(std::string func_name, Datum input, Datum expected, |
| 257 | const FunctionOptions* options) { |
no test coverage detected