| 35 | namespace bytedance::bolt::exec { |
| 36 | |
| 37 | TableWriter::TableWriter( |
| 38 | int32_t operatorId, |
| 39 | DriverCtx* driverCtx, |
| 40 | const std::shared_ptr<const core::TableWriteNode>& tableWriteNode) |
| 41 | : Operator( |
| 42 | driverCtx, |
| 43 | tableWriteNode->outputType(), |
| 44 | operatorId, |
| 45 | tableWriteNode->id(), |
| 46 | "TableWrite", |
| 47 | tableWriteNode->canSpill(driverCtx->queryConfig()) |
| 48 | ? driverCtx->makeSpillConfig(operatorId) |
| 49 | : std::nullopt), |
| 50 | driverCtx_(driverCtx), |
| 51 | connectorPool_(driverCtx_->task->addConnectorPoolLocked( |
| 52 | planNodeId(), |
| 53 | driverCtx_->pipelineId, |
| 54 | driverCtx_->driverId, |
| 55 | operatorType(), |
| 56 | tableWriteNode->insertTableHandle()->connectorId())), |
| 57 | insertTableHandle_( |
| 58 | tableWriteNode->insertTableHandle()->connectorInsertTableHandle()), |
| 59 | commitStrategy_(tableWriteNode->commitStrategy()) { |
| 60 | setConnectorMemoryReclaimer(); |
| 61 | if (tableWriteNode->outputType()->size() == 1) { |
| 62 | BOLT_USER_CHECK_NULL(tableWriteNode->aggregationNode()); |
| 63 | } else { |
| 64 | BOLT_USER_CHECK(tableWriteNode->outputType()->equivalent( |
| 65 | *(TableWriteTraits::outputType(tableWriteNode->aggregationNode())))); |
| 66 | } |
| 67 | |
| 68 | if (tableWriteNode->aggregationNode() != nullptr) { |
| 69 | aggregation_ = std::make_unique<HashAggregation>( |
| 70 | operatorId, driverCtx, tableWriteNode->aggregationNode()); |
| 71 | } |
| 72 | const auto& connectorId = tableWriteNode->insertTableHandle()->connectorId(); |
| 73 | connector_ = connector::getConnector(connectorId); |
| 74 | connectorQueryCtx_ = operatorCtx_->createConnectorQueryCtx( |
| 75 | connectorId, |
| 76 | planNodeId(), |
| 77 | connectorPool_, |
| 78 | spillConfig_.has_value() ? &(spillConfig_.value()) : nullptr); |
| 79 | |
| 80 | auto names = tableWriteNode->columnNames(); |
| 81 | auto types = tableWriteNode->columns()->children(); |
| 82 | |
| 83 | const auto& inputType = tableWriteNode->sources()[0]->outputType(); |
| 84 | |
| 85 | inputMapping_.reserve(types.size()); |
| 86 | for (const auto& name : tableWriteNode->columns()->names()) { |
| 87 | inputMapping_.emplace_back(inputType->getChildIdx(name)); |
| 88 | } |
| 89 | |
| 90 | mappedType_ = ROW(std::move(names), std::move(types)); |
| 91 | } |
| 92 | |
| 93 | void TableWriter::initialize() { |
| 94 | Operator::initialize(); |
nothing calls this directly
no test coverage detected