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

Function writeCopyNodeStatement

src/processor/operator/simple/export_db.cpp:69–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67}
68
69static void writeCopyNodeStatement(stringstream& ss, const TableCatalogEntry* entry,
70 const FileScanInfo* info,
71 const std::unordered_map<std::string, const std::atomic<bool>*>& canUseParallelReader) {
72 const auto csvConfig = CSVReaderConfig::construct(info->options);
73 // TODO(Ziyi): We should pass fileName from binder phase to here.
74 auto fileName = entry->getName() + "." + StringUtils::getLower(info->fileTypeInfo.fileTypeStr);
75 std::string columns = getTablePropertyDefinitions(entry);
76 bool useParallelReader = true;
77 if (canUseParallelReader.contains(fileName)) {
78 useParallelReader = canUseParallelReader.at(fileName)->load();
79 }
80 auto copyOptionsCypher = CSVOption::toCypher(csvConfig.option.toOptionsMap(useParallelReader));
81 if (columns.empty()) {
82 ss << std::format("COPY `{}` FROM \"{}\" {};\n", entry->getName(), fileName,
83 copyOptionsCypher);
84 } else {
85 ss << std::format("COPY `{}` ({}) FROM \"{}\" {};\n", entry->getName(), columns, fileName,
86 copyOptionsCypher);
87 }
88}
89
90static void writeCopyRelStatement(stringstream& ss, const ClientContext* context,
91 const TableCatalogEntry* entry, const FileScanInfo* info,

Callers 1

getCopyCypherFunction · 0.85

Calls 8

constructFunction · 0.85
toOptionsMapMethod · 0.80
toCypherFunction · 0.50
getNameMethod · 0.45
containsMethod · 0.45
loadMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected