diff --git a/src/binder/bind/bind_import_database.cpp b/src/binder/bind/bind_import_database.cpp index 2f0566e601b..d47a3bb6418 100644 --- a/src/binder/bind/bind_import_database.cpp +++ b/src/binder/bind/bind_import_database.cpp @@ -1,7 +1,6 @@ #include #include "binder/binder.h" -#include "binder/copy/bound_file_scan_info.h" #include "binder/copy/bound_import_database.h" #include "common/exception/binder.h" #include "common/file_system/virtual_file_system.h" @@ -15,25 +14,6 @@ using namespace kuzu::parser; namespace kuzu { namespace binder { -// std::string replaceCopyFromPath(common::VirtualFileSystem* vfs, const std::string boundFilePath, -// std::string query){ -// auto parsedStatements = Parser::parseQuery(query); -// auto result = std::string(); -// for(auto &parsedStatement : parsedStatements){ -// KU_ASSERT(parsedStatement->getStatementType()==StatementType::COPY_FROM); -// auto copyFromStatement = ku_dynamic_cast(parsedStatement.get()); KU_ASSERT(copyFromStatement->getFilePath().size()==1); -// auto csvFilePath = copyFromStatement->getFilePath()[0]; -// auto extractedFileName = vfs->extractName(csvFilePath); -// csvFilePath=vfs->joinPath(boundFilePath, extractedFileName); -// auto csvConfig = -// CSVReaderConfig::construct(bindParsingOptions(copyFromStatement->getParsingOptionsRef())); -// result+="COPY "+ copyFromStatement->getTableName()+ " FROM '"+csvFilePath+" -// "+csvConfig.option.toCypher()+"';"; -// } -// return result; -//} - std::string getQueryFromFile( common::VirtualFileSystem* vfs, const std::string boundFilePath, const std::string fileName) { auto filePath = vfs->joinPath(boundFilePath, fileName); @@ -48,10 +28,7 @@ std::string getQueryFromFile( auto fsize = fileInfo->getFileSize(); auto buffer = std::make_unique(fsize); fileInfo->readFile(buffer.get(), fsize); - auto query = std::string(buffer.get(), fsize); - return query; - // fileName==ImportDBConstants::COPY_NAME? - // replaceCopyFromPath(vfs,boundFilePath,query):std::string(buffer.get(), fsize); + return std::string(buffer.get(), fsize); } std::unique_ptr Binder::bindImportDatabaseClause(const Statement& statement) { @@ -69,10 +46,14 @@ std::unique_ptr Binder::bindImportDatabaseClause(const Statement KU_ASSERT(parsedStatement->getStatementType() == StatementType::COPY_FROM); auto copyFromStatement = ku_dynamic_cast(parsedStatement.get()); - KU_ASSERT(copyFromStatement->getFilePath().size() == 1); - auto csvFilePath = copyFromStatement->getFilePath()[0]; + KU_ASSERT(copyFromStatement->getSource()->type == common::ScanSourceType::FILE); + auto filePaths = ku_dynamic_cast( + copyFromStatement->getSource()) + ->filePaths; + KU_ASSERT(filePaths.size() == 1); + auto csvFilePath = filePaths[0]; auto extractedFileName = fs->extractName(csvFilePath); - csvFilePath = fs->joinPath(boundFilePath, extractedFileName); + csvFilePath = boundFilePath + "/" + extractedFileName; auto csvConfig = CSVReaderConfig::construct( bindParsingOptions(copyFromStatement->getParsingOptionsRef())); auto csvQuery = "COPY " + copyFromStatement->getTableName() + " FROM '" + csvFilePath + diff --git a/src/include/parser/copy.h b/src/include/parser/copy.h index 6a0e1c7f33c..bbc9b23ad80 100644 --- a/src/include/parser/copy.h +++ b/src/include/parser/copy.h @@ -30,11 +30,6 @@ class CopyFrom : public Copy { inline bool byColumn() const { return byColumn_; } inline BaseScanSource* getSource() const { return source.get(); } - inline std::vector getFilePath() const { - KU_ASSERT(source->type == common::ScanSourceType::FILE); - auto fileSource = dynamic_cast(source.get()); - return fileSource->filePaths; - } inline std::string getTableName() const { return tableName; }