| 16 | namespace binder { |
| 17 | |
| 18 | static std::string getQueryFromFile(VirtualFileSystem* vfs, const std::string& boundFilePath, |
| 19 | const std::string& fileName, main::ClientContext* context) { |
| 20 | auto filePath = vfs->joinPath(boundFilePath, fileName); |
| 21 | if (!vfs->fileOrPathExists(filePath, context)) { |
| 22 | if (fileName == PortDBConstants::COPY_FILE_NAME) { |
| 23 | return ""; |
| 24 | } |
| 25 | if (fileName == PortDBConstants::INDEX_FILE_NAME) { |
| 26 | return ""; |
| 27 | } |
| 28 | throw BinderException(std::format("File {} does not exist.", filePath)); |
| 29 | } |
| 30 | auto fileInfo = vfs->openFile(filePath, FileOpenFlags(FileFlags::READ_ONLY |
| 31 | #ifdef _WIN32 |
| 32 | | FileFlags::BINARY |
| 33 | #endif |
| 34 | )); |
| 35 | auto fsize = fileInfo->getFileSize(); |
| 36 | auto buffer = std::make_unique<char[]>(fsize); |
| 37 | fileInfo->readFile(buffer.get(), fsize); |
| 38 | return std::string(buffer.get(), fsize); |
| 39 | } |
| 40 | |
| 41 | static std::string getColumnNamesToCopy(const CopyFrom& copyFrom) { |
| 42 | std::string columns = ""; |
no test coverage detected