| 1003 | } |
| 1004 | |
| 1005 | std::unordered_set<column_index_t> Driver::canPushdownFilters( |
| 1006 | const Operator* filterSource, |
| 1007 | const std::vector<column_index_t>& channels) const { |
| 1008 | int filterSourceIndex = -1; |
| 1009 | for (auto i = 0; i < operators_.size(); ++i) { |
| 1010 | auto op = operators_[i].get(); |
| 1011 | if (filterSource == op) { |
| 1012 | filterSourceIndex = i; |
| 1013 | break; |
| 1014 | } |
| 1015 | } |
| 1016 | BOLT_CHECK_GE( |
| 1017 | filterSourceIndex, |
| 1018 | 0, |
| 1019 | "Operator not found in its Driver: {}", |
| 1020 | filterSource->toString()); |
| 1021 | |
| 1022 | std::unordered_set<column_index_t> supportedChannels; |
| 1023 | for (auto i = 0; i < channels.size(); ++i) { |
| 1024 | auto channel = channels[i]; |
| 1025 | for (auto j = filterSourceIndex - 1; j >= 0; --j) { |
| 1026 | auto prevOp = operators_[j].get(); |
| 1027 | |
| 1028 | if (j == 0) { |
| 1029 | // Source operator. |
| 1030 | if (prevOp->canAddDynamicFilter()) { |
| 1031 | supportedChannels.emplace(channels[i]); |
| 1032 | } |
| 1033 | break; |
| 1034 | } |
| 1035 | |
| 1036 | const auto& identityProjections = prevOp->identityProjections(); |
| 1037 | auto inputChannel = getIdentityProjection(identityProjections, channel); |
| 1038 | if (!inputChannel.has_value()) { |
| 1039 | // Filter channel is not an identity projection. |
| 1040 | if (prevOp->canAddDynamicFilter()) { |
| 1041 | supportedChannels.emplace(channels[i]); |
| 1042 | } |
| 1043 | break; |
| 1044 | } |
| 1045 | |
| 1046 | // Continue walking upstream. |
| 1047 | channel = inputChannel.value(); |
| 1048 | } |
| 1049 | } |
| 1050 | |
| 1051 | return supportedChannels; |
| 1052 | } |
| 1053 | |
| 1054 | Operator* Driver::findOperator(std::string_view planNodeId) const { |
| 1055 | for (auto& op : operators_) { |
no test coverage detected