| 88 | } |
| 89 | |
| 90 | static void writeCopyRelStatement(stringstream& ss, const ClientContext* context, |
| 91 | const TableCatalogEntry* entry, const FileScanInfo* info, |
| 92 | const std::unordered_map<std::string, const std::atomic<bool>*>& canUseParallelReader) { |
| 93 | const auto csvConfig = CSVReaderConfig::construct(info->options); |
| 94 | std::string columns = getTablePropertyDefinitions(entry); |
| 95 | auto transaction = Transaction::Get(*context); |
| 96 | const auto catalog = Catalog::Get(*context); |
| 97 | for (auto& entryInfo : entry->constCast<RelGroupCatalogEntry>().getRelEntryInfos()) { |
| 98 | auto fromTableName = |
| 99 | catalog->getTableCatalogEntry(transaction, entryInfo.nodePair.srcTableID)->getName(); |
| 100 | auto toTableName = |
| 101 | catalog->getTableCatalogEntry(transaction, entryInfo.nodePair.dstTableID)->getName(); |
| 102 | // TODO(Ziyi): We should pass fileName from binder phase to here. |
| 103 | auto fileName = std::format("{}_{}_{}.{}", entry->getName(), fromTableName, toTableName, |
| 104 | StringUtils::getLower(info->fileTypeInfo.fileTypeStr)); |
| 105 | bool useParallelReader = true; |
| 106 | if (canUseParallelReader.contains(fileName)) { |
| 107 | useParallelReader = canUseParallelReader.at(fileName)->load(); |
| 108 | } |
| 109 | auto copyOptionsMap = csvConfig.option.toOptionsMap(useParallelReader); |
| 110 | copyOptionsMap["from"] = std::format("'{}'", fromTableName); |
| 111 | copyOptionsMap["to"] = std::format("'{}'", toTableName); |
| 112 | auto copyOptions = CSVOption::toCypher(copyOptionsMap); |
| 113 | if (columns.empty()) { |
| 114 | ss << std::format("COPY `{}` FROM \"{}\" {};\n", entry->getName(), fileName, |
| 115 | copyOptions); |
| 116 | } else { |
| 117 | ss << std::format("COPY `{}` ({}) FROM \"{}\" {};\n", entry->getName(), columns, |
| 118 | fileName, copyOptions); |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | static void exportLoadedExtensions(stringstream& ss, const ClientContext* clientContext) { |
| 124 | auto extensionCypher = extension::ExtensionManager::Get(*clientContext)->toCypher(); |
no test coverage detected