| 67 | } |
| 68 | |
| 69 | static 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 | |
| 90 | static void writeCopyRelStatement(stringstream& ss, const ClientContext* context, |
| 91 | const TableCatalogEntry* entry, const FileScanInfo* info, |
no test coverage detected