-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kuzu CI
committed
Feb 27, 2024
1 parent
29f2534
commit 14dc603
Showing
45 changed files
with
3,515 additions
and
3,171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <fstream> | ||
#include <iostream> | ||
|
||
#include "binder/copy/bound_import_database.h" | ||
#include "binder/query/bound_regular_query.h" | ||
#include "common/exception/binder.h" | ||
#include "parser/parser.h" | ||
#include "parser/port_db.h" | ||
|
||
using namespace kuzu::binder; | ||
using namespace kuzu::common; | ||
using namespace kuzu::parser; | ||
using namespace kuzu::catalog; | ||
using namespace kuzu::transaction; | ||
using namespace kuzu::storage; | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
std::unique_ptr<BoundStatement> Binder::bindImportDatabaseClause(const Statement& statement) { | ||
auto& importDatabaseStatement = ku_dynamic_cast<const Statement&, const ImportDB&>(statement); | ||
auto boundFilePath = importDatabaseStatement.getFilePath(); | ||
std::vector<std::string> files = {"schema.cypher", "copy.cypher", "macro.cypher"}; | ||
std::string finalQueryStatements; | ||
for (auto& file : files) { | ||
auto filePath = vfs->joinPath(boundFilePath, file); | ||
std::ifstream cypherFile(filePath); | ||
if (!cypherFile.is_open()) { | ||
throw Exception(stringFormat("Error opening file: {}, errno: {}.", filePath, errno)); | ||
} | ||
std::string line; | ||
while (getline(cypherFile, line)) { | ||
finalQueryStatements += line; | ||
} | ||
} | ||
return std::make_unique<BoundImportDatabase>(boundFilePath, finalQueryStatements); | ||
} | ||
} // namespace binder | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
#include "binder/binder.h" | ||
#include "binder/bound_statement.h" | ||
#include "common/copier_config/csv_reader_config.h" | ||
#include "common/copier_config/reader_config.h" | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
class BoundImportDatabase : public BoundStatement { | ||
public: | ||
BoundImportDatabase(std::string filePath, std::string query) | ||
: BoundStatement{common::StatementType::IMPORT_DATABASE, | ||
BoundStatementResult::createEmptyResult()}, | ||
filePath{std::move(filePath)}, query{query} {} | ||
|
||
inline std::string getFilePath() const { return filePath; } | ||
inline std::string getQuery() const { return query; } | ||
|
||
private: | ||
std::string filePath; | ||
std::string query; | ||
}; | ||
|
||
} // namespace binder | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/include/planner/operator/persistent/logical_import_db.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include "planner/operator/logical_operator.h" | ||
|
||
namespace kuzu { | ||
namespace planner { | ||
|
||
class LogicalImportDatabase : public LogicalOperator { | ||
public: | ||
explicit LogicalImportDatabase(std::string query) | ||
: LogicalOperator{LogicalOperatorType::IMPORT_DATABASE}, query{query} {} | ||
|
||
inline std::string getExpressionsForPrinting() const override { return std::string{}; } | ||
|
||
void computeFactorizedSchema() override; | ||
void computeFlatSchema() override; | ||
|
||
inline std::string getQuery() const { return query; } | ||
|
||
inline std::unique_ptr<LogicalOperator> copy() override { | ||
return make_unique<LogicalImportDatabase>(query); | ||
} | ||
|
||
private: | ||
std::string query; | ||
}; | ||
|
||
} // namespace planner | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "common/copier_config/reader_config.h" | ||
#include "processor/operator/physical_operator.h" | ||
|
||
namespace kuzu { | ||
namespace processor { | ||
|
||
class ImportDB : public PhysicalOperator { | ||
public: | ||
ImportDB(std::string query, uint32_t id, const std::string& paramsString) | ||
: PhysicalOperator{PhysicalOperatorType::IMPORT_DATABASE, id, paramsString}, query{query} {} | ||
|
||
bool canParallel() const override { return false; } | ||
|
||
bool isSource() const override { return true; } | ||
|
||
bool getNextTuplesInternal(ExecutionContext* context) override; | ||
|
||
inline std::unique_ptr<PhysicalOperator> clone() override { | ||
return std::make_unique<ImportDB>(query, id, paramsString); | ||
} | ||
|
||
private: | ||
std::string query; | ||
}; | ||
} // namespace processor | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.