| 119 | "FilterProject"), |
| 120 | hasFilter_(filter != nullptr), |
| 121 | driverCtx_(driverCtx), |
| 122 | project_(project), |
| 123 | filter_(filter), |
| 124 | acceptCompositeInput_( |
| 125 | driverCtx->queryConfig().isHashAggregationCompositeOutputEnabled()), |
| 126 | skipForCompositeInput_(type == ProjectType::kSkipCompositeRowVector) { |
| 127 | if (filter_ != nullptr && project_ != nullptr) { |
| 128 | folly::Synchronized<OperatorStats>& opStats = Operator::stats(); |
| 129 | opStats.withWLock([&](auto& stats) { |
| 130 | stats.setStatSplitter( |
| 131 | [filterId = filter_->id()](const auto& combinedStats) { |
| 132 | return splitStats(combinedStats, filterId); |
| 133 | }); |
| 134 | }); |
| 135 | } |
| 136 | } |
| 137 | |
| 138 | void FilterProject::initialize() { |
| 139 | Operator::initialize(); |
| 140 | std::vector<core::TypedExprPtr> allExprs; |
| 141 | if (hasFilter_) { |
| 142 | BOLT_CHECK_NOT_NULL(filter_); |
| 143 | allExprs.push_back(filter_->filter()); |
| 144 | } |
| 145 | if (project_) { |
| 146 | const auto& inputType = project_->sources()[0]->outputType(); |
| 147 | for (column_index_t i = 0; i < project_->projections().size(); i++) { |
| 148 | auto& projection = project_->projections()[i]; |
| 149 | bool identityProjection = checkAddIdentityProjection( |
| 150 | projection, inputType, i, identityProjections_); |
| 151 | if (!identityProjection) { |
| 152 | allExprs.push_back(projection); |
| 153 | resultProjections_.emplace_back(allExprs.size() - 1, i); |
| 154 | } |
| 155 | } |
| 156 | } else { |
| 157 | for (column_index_t i = 0; i < outputType_->size(); ++i) { |
| 158 | identityProjections_.emplace_back(i, i); |
| 159 | } |
| 160 | isIdentityProjection_ = true; |
| 161 | } |
| 162 | { |
| 163 | std::unordered_map<column_index_t, size_t> inputChannelCounts; |
| 164 | for (const auto& projection : identityProjections_) { |
| 165 | ++inputChannelCounts[projection.inputChannel]; |
| 166 | } |
| 167 | for (const auto& [inputChannel, count] : inputChannelCounts) { |
| 168 | if (count > 1) { |
nothing calls this directly
no test coverage detected