| 213 | } |
| 214 | |
| 215 | BoundCopyFromInfo Binder::bindCopyRelFromInfo(std::string tableName, |
| 216 | const std::vector<PropertyDefinition>& properties, const BaseScanSource* source, |
| 217 | const options_t& parsingOptions, const std::vector<std::string>& expectedColumnNames, |
| 218 | const std::vector<LogicalType>& expectedColumnTypes, const NodeTableCatalogEntry* fromTable, |
| 219 | const NodeTableCatalogEntry* toTable) { |
| 220 | if (getBoolCopyOption(parsingOptions, CopyConstants::SKIP_DUPLICATE_PK_OPTION_NAME, |
| 221 | CopyConstants::DEFAULT_SKIP_DUPLICATE_PK)) { |
| 222 | throw BinderException("IGNORE_ERRORS=true (DUPLICATE_PK_ONLY) is only supported for COPY " |
| 223 | "FROM files into node tables."); |
| 224 | } |
| 225 | auto boundSource = |
| 226 | bindScanSource(source, parsingOptions, expectedColumnNames, expectedColumnTypes); |
| 227 | expression_vector warningDataExprs = boundSource->getWarningColumns(); |
| 228 | auto columns = boundSource->getColumns(); |
| 229 | auto offset = |
| 230 | createInvisibleVariable(std::string(InternalKeyword::ROW_OFFSET), LogicalType::INT64()); |
| 231 | auto srcOffset = createVariable(std::string(InternalKeyword::SRC_OFFSET), LogicalType::INT64()); |
| 232 | auto dstOffset = createVariable(std::string(InternalKeyword::DST_OFFSET), LogicalType::INT64()); |
| 233 | expression_vector columnExprs{srcOffset, dstOffset, offset}; |
| 234 | std::vector<ColumnEvaluateType> evaluateTypes{ColumnEvaluateType::REFERENCE, |
| 235 | ColumnEvaluateType::REFERENCE, ColumnEvaluateType::REFERENCE}; |
| 236 | for (auto i = 1u; i < properties.size(); ++i) { // skip internal ID |
| 237 | auto& property = properties[i]; |
| 238 | auto [evaluateType, column] = |
| 239 | matchColumnExpression(boundSource->getColumns(), property, expressionBinder); |
| 240 | columnExprs.push_back(column); |
| 241 | evaluateTypes.push_back(evaluateType); |
| 242 | } |
| 243 | columnExprs.insert(columnExprs.end(), warningDataExprs.begin(), warningDataExprs.end()); |
| 244 | std::shared_ptr<Expression> srcKey = nullptr, dstKey = nullptr; |
| 245 | if (expectedColumnTypes[0] != columns[0]->getDataType()) { |
| 246 | srcKey = expressionBinder.forceCast(columns[0], expectedColumnTypes[0]); |
| 247 | } else { |
| 248 | srcKey = columns[0]; |
| 249 | } |
| 250 | if (expectedColumnTypes[1] != columns[1]->getDataType()) { |
| 251 | dstKey = expressionBinder.forceCast(columns[1], expectedColumnTypes[1]); |
| 252 | } else { |
| 253 | dstKey = columns[1]; |
| 254 | } |
| 255 | auto srcLookUpInfo = |
| 256 | IndexLookupInfo(fromTable->getTableID(), srcOffset, srcKey, warningDataExprs); |
| 257 | auto dstLookUpInfo = |
| 258 | IndexLookupInfo(toTable->getTableID(), dstOffset, dstKey, warningDataExprs); |
| 259 | auto lookupInfos = std::vector<IndexLookupInfo>{srcLookUpInfo, dstLookUpInfo}; |
| 260 | auto internalIDColumnIndices = std::vector<idx_t>{0, 1, 2}; |
| 261 | auto extraCopyRelInfo = std::make_unique<ExtraBoundCopyRelInfo>(fromTable->getName(), |
| 262 | toTable->getName(), internalIDColumnIndices, lookupInfos); |
| 263 | return BoundCopyFromInfo(tableName, TableType::REL, boundSource->copy(), offset, |
| 264 | std::move(columnExprs), std::move(evaluateTypes), std::move(extraCopyRelInfo), false); |
| 265 | } |
| 266 | |
| 267 | std::unique_ptr<BoundStatement> Binder::bindCopyRelFrom(const Statement& statement, |
| 268 | RelGroupCatalogEntry& relGroupEntry, const std::string& fromTableName, |
nothing calls this directly
no test coverage detected