| 119 | } |
| 120 | |
| 121 | std::unique_ptr<PhysicalOperator> PlanMapper::mapCopyRelFrom( |
| 122 | const LogicalOperator* logicalOperator) { |
| 123 | auto& copyFrom = logicalOperator->constCast<LogicalCopyFrom>(); |
| 124 | const auto copyFromInfo = copyFrom.getInfo(); |
| 125 | auto partitioner = mapOperator(copyFrom.getChild(0).get()); |
| 126 | DASSERT(partitioner->getOperatorType() == PhysicalOperatorType::PARTITIONER); |
| 127 | auto partitionerSharedState = partitioner->ptrCast<Partitioner>()->getSharedState(); |
| 128 | const auto catalog = Catalog::Get(*clientContext); |
| 129 | const auto transaction = transaction::Transaction::Get(*clientContext); |
| 130 | auto extraInfo = copyFromInfo->extraInfo->constCast<ExtraBoundCopyRelInfo>(); |
| 131 | auto fromTableID = |
| 132 | catalog->getTableCatalogEntry(transaction, extraInfo.fromTableName)->getTableID(); |
| 133 | auto toTableID = |
| 134 | catalog->getTableCatalogEntry(transaction, extraInfo.toTableName)->getTableID(); |
| 135 | std::vector<LogicalType> warningColumnTypes; |
| 136 | for (auto& column : copyFromInfo->getWarningColumns()) { |
| 137 | warningColumnTypes.push_back(column->getDataType().copy()); |
| 138 | } |
| 139 | auto fTable = |
| 140 | FactorizedTableUtils::getSingleStringColumnFTable(MemoryManager::Get(*clientContext)); |
| 141 | auto batchInsertSharedState = std::make_shared<BatchInsertSharedState>(fTable); |
| 142 | // If the table entry doesn't exist, assume both directions |
| 143 | std::vector directions = {RelDataDirection::FWD, RelDataDirection::BWD}; |
| 144 | if (catalog->containsTable(transaction, copyFromInfo->tableName)) { |
| 145 | const auto& relGroupEntry = |
| 146 | catalog->getTableCatalogEntry(transaction, copyFromInfo->tableName) |
| 147 | ->constCast<RelGroupCatalogEntry>(); |
| 148 | directions = relGroupEntry.getRelDataDirections(); |
| 149 | } |
| 150 | |
| 151 | auto sink = std::make_unique<DummySimpleSink>(fTable, getOperatorID()); |
| 152 | for (auto direction : directions) { |
| 153 | auto insertInfo = std::make_unique<RelBatchInsertInfo>(copyFromInfo->tableName, |
| 154 | copyVector(warningColumnTypes), fromTableID, toTableID, direction); |
| 155 | auto printInfo = std::make_unique<RelBatchInsertPrintInfo>(copyFromInfo->tableName); |
| 156 | auto progress = std::make_shared<RelBatchInsertProgressSharedState>(); |
| 157 | auto batchInsert = std::make_unique<RelBatchInsert>(std::move(insertInfo), |
| 158 | partitionerSharedState, batchInsertSharedState, getOperatorID(), std::move(printInfo), |
| 159 | progress, std::make_unique<CopyRelBatchInsert>()); |
| 160 | batchInsert->setDescriptor(std::make_unique<ResultSetDescriptor>(copyFrom.getSchema())); |
| 161 | sink->addChild(std::move(batchInsert)); |
| 162 | } |
| 163 | sink->addChild(std::move(partitioner)); |
| 164 | return sink; |
| 165 | } |
| 166 | |
| 167 | } // namespace processor |
| 168 | } // namespace lbug |
nothing calls this directly
no test coverage detected