MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / mapCopyNodeFrom

Method mapCopyNodeFrom

src/processor/map/map_copy_from.cpp:44–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44std::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
79std::unique_ptr<PhysicalOperator> PlanMapper::mapPartitioner(
80 const LogicalOperator* logicalOperator) {

Callers

nothing calls this directly

Calls 12

ExpressionMapperClass · 0.85
getOperatorIDFunction · 0.85
getEvaluatorMethod · 0.80
getDataTypeMethod · 0.80
getInfoMethod · 0.45
getMethod · 0.45
getChildMethod · 0.45
getSharedStateMethod · 0.45
push_backMethod · 0.45
getWarningColumnsMethod · 0.45
copyMethod · 0.45

Tested by

no test coverage detected