| 42 | } |
| 43 | |
| 44 | std::unique_ptr<PhysicalOperator> PlanMapper::mapCopyNodeFrom( |
| 45 | const LogicalOperator* logicalOperator) { |
| 46 | auto& copyFrom = logicalOperator->constCast<LogicalCopyFrom>(); |
| 47 | const auto copyFromInfo = copyFrom.getInfo(); |
| 48 | const auto outFSchema = copyFrom.getSchema(); |
| 49 | auto prevOperator = mapOperator(copyFrom.getChild(0).get()); |
| 50 | // A node COPY always returns the three-column result schema (result, |
| 51 | // skipped_duplicate_pk_count, skipped_duplicate_pks) regardless of the active ignore mode. |
| 52 | auto fTable = FactorizedTableUtils::getNodeCopyResultFTable(MemoryManager::Get(*clientContext)); |
| 53 | |
| 54 | auto sharedState = std::make_shared<NodeBatchInsertSharedState>(fTable); |
| 55 | sharedState->skipDuplicatePK = copyFromInfo->getSkipDuplicatePKOption(); |
| 56 | if (prevOperator->getOperatorType() == PhysicalOperatorType::TABLE_FUNCTION_CALL) { |
| 57 | const auto call = prevOperator->ptrCast<TableFunctionCall>(); |
| 58 | sharedState->tableFuncSharedState = call->getSharedState().get(); |
| 59 | } |
| 60 | std::vector<std::unique_ptr<evaluator::ExpressionEvaluator>> columnEvaluators; |
| 61 | auto exprMapper = ExpressionMapper(outFSchema); |
| 62 | for (auto& expr : copyFromInfo->columnExprs) { |
| 63 | columnEvaluators.push_back(exprMapper.getEvaluator(expr)); |
| 64 | } |
| 65 | std::vector<LogicalType> warningColumnTypes; |
| 66 | for (auto& column : copyFromInfo->getWarningColumns()) { |
| 67 | warningColumnTypes.push_back(column->getDataType().copy()); |
| 68 | } |
| 69 | auto info = std::make_unique<NodeBatchInsertInfo>(copyFromInfo->tableName, |
| 70 | std::move(warningColumnTypes), std::move(columnEvaluators), |
| 71 | copyFromInfo->columnEvaluateTypes, copyFromInfo->getSkipDuplicatePKOption()); |
| 72 | auto printInfo = std::make_unique<NodeBatchInsertPrintInfo>(copyFromInfo->tableName); |
| 73 | auto batchInsert = std::make_unique<NodeBatchInsert>(std::move(info), std::move(sharedState), |
| 74 | std::move(prevOperator), getOperatorID(), std::move(printInfo)); |
| 75 | batchInsert->setDescriptor(std::make_unique<ResultSetDescriptor>(copyFrom.getSchema())); |
| 76 | return batchInsert; |
| 77 | } |
| 78 | |
| 79 | std::unique_ptr<PhysicalOperator> PlanMapper::mapPartitioner( |
| 80 | const LogicalOperator* logicalOperator) { |
nothing calls this directly
no test coverage detected