| 389 | |
| 390 | template <typename Op> |
| 391 | std::shared_ptr<ScalarFunction> MakeCompareFunction(std::string name, FunctionDoc doc) { |
| 392 | auto func = std::make_shared<CompareFunction>(name, Arity::Binary(), std::move(doc)); |
| 393 | |
| 394 | DCHECK_OK(func->AddKernel( |
| 395 | {boolean(), boolean()}, boolean(), |
| 396 | applicator::ScalarBinary<BooleanType, BooleanType, BooleanType, Op>::Exec)); |
| 397 | |
| 398 | for (const std::shared_ptr<DataType>& ty : NumericTypes()) { |
| 399 | AddPrimitiveCompare<Op>(ty, func.get()); |
| 400 | } |
| 401 | AddPrimitiveCompare<Op>(date32(), func.get()); |
| 402 | AddPrimitiveCompare<Op>(date64(), func.get()); |
| 403 | |
| 404 | // Add timestamp kernels |
| 405 | for (auto unit : TimeUnit::values()) { |
| 406 | InputType in_type(match::TimestampTypeUnit(unit)); |
| 407 | ScalarKernel kernel = |
| 408 | GetCompareKernel<Op>(in_type, Type::INT64, CompareTimestamps<Op>::Exec); |
| 409 | DCHECK_OK(func->AddKernel(kernel)); |
| 410 | } |
| 411 | |
| 412 | // Duration |
| 413 | for (auto unit : TimeUnit::values()) { |
| 414 | InputType in_type(match::DurationTypeUnit(unit)); |
| 415 | ArrayKernelExec exec = GeneratePhysicalNumeric<CompareKernel>(int64()); |
| 416 | DCHECK_OK(func->AddKernel(GetCompareKernel<Op>(in_type, Type::INT64, exec))); |
| 417 | } |
| 418 | |
| 419 | // Time32 and Time64 |
| 420 | for (auto unit : {TimeUnit::SECOND, TimeUnit::MILLI}) { |
| 421 | InputType in_type(match::Time32TypeUnit(unit)); |
| 422 | ArrayKernelExec exec = GeneratePhysicalNumeric<CompareKernel>(int32()); |
| 423 | DCHECK_OK(func->AddKernel(GetCompareKernel<Op>(in_type, Type::INT32, exec))); |
| 424 | } |
| 425 | for (auto unit : {TimeUnit::MICRO, TimeUnit::NANO}) { |
| 426 | InputType in_type(match::Time64TypeUnit(unit)); |
| 427 | ArrayKernelExec exec = GeneratePhysicalNumeric<CompareKernel>(int64()); |
| 428 | DCHECK_OK(func->AddKernel(GetCompareKernel<Op>(in_type, Type::INT64, exec))); |
| 429 | } |
| 430 | |
| 431 | for (const std::shared_ptr<DataType>& ty : BaseBinaryTypes()) { |
| 432 | auto exec = |
| 433 | GenerateVarBinaryBase<applicator::ScalarBinaryEqualTypes, BooleanType, Op>(*ty); |
| 434 | DCHECK_OK(func->AddKernel({ty, ty}, boolean(), std::move(exec))); |
| 435 | } |
| 436 | for (const auto& ty : BinaryViewTypes()) { |
| 437 | auto exec = |
| 438 | GenerateVarBinaryViewBase<applicator::ScalarBinaryEqualTypes, BooleanType, Op>( |
| 439 | *ty); |
| 440 | DCHECK_OK(func->AddKernel({ty, ty}, boolean(), std::move(exec))); |
| 441 | } |
| 442 | |
| 443 | for (const auto id : {Type::DECIMAL128, Type::DECIMAL256}) { |
| 444 | auto exec = GenerateDecimal<applicator::ScalarBinaryEqualTypes, BooleanType, Op>(id); |
| 445 | DCHECK_OK(func->AddKernel({InputType(id), InputType(id)}, boolean(), std::move(exec), |
| 446 | /*init=*/nullptr, DecimalsHaveSameScale())); |
| 447 | } |
| 448 |
nothing calls this directly
no test coverage detected