-
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.
Merge pull request #1717 from kuzudb/call
Implement call statement
- Loading branch information
Showing
42 changed files
with
4,288 additions
and
3,762 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
add_library( | ||
kuzu_binder_bind | ||
OBJECT | ||
bind_call.cpp | ||
bind_copy.cpp | ||
bind_ddl.cpp | ||
bind_graph_pattern.cpp | ||
|
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,24 @@ | ||
#include "binder/binder.h" | ||
#include "binder/call/bound_call.h" | ||
#include "common/string_utils.h" | ||
#include "parser/call/call.h" | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
std::unique_ptr<BoundStatement> Binder::bindCallClause(const parser::Statement& statement) { | ||
auto& callStatement = reinterpret_cast<const parser::Call&>(statement); | ||
auto option = main::DBConfig::getOptionByName(callStatement.getOptionName()); | ||
if (option == nullptr) { | ||
throw common::BinderException{ | ||
"Invalid option name: " + callStatement.getOptionName() + "."}; | ||
} | ||
auto optionValue = expressionBinder.bindLiteralExpression(*callStatement.getOptionValue()); | ||
// TODO(Ziyi): add casting rule for option value. | ||
ExpressionBinder::validateExpectedDataType(*optionValue, option->parameterType); | ||
auto boundCall = std::make_unique<BoundCall>(*option, std::move(optionValue)); | ||
return boundCall; | ||
} | ||
|
||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "binder/expression/expression.h" | ||
#include "main/db_config.h" | ||
|
||
namespace kuzu { | ||
namespace binder { | ||
|
||
class BoundCall : public BoundStatement { | ||
public: | ||
BoundCall(main::ConfigurationOption option, std::shared_ptr<Expression> optionValue) | ||
: BoundStatement{common::StatementType::CALL, BoundStatementResult::createEmptyResult()}, | ||
option{option}, optionValue{optionValue} {} | ||
|
||
inline main::ConfigurationOption getOption() const { return option; } | ||
|
||
inline std::shared_ptr<Expression> getOptionValue() const { return optionValue; } | ||
|
||
private: | ||
main::ConfigurationOption option; | ||
std::shared_ptr<Expression> optionValue; | ||
}; | ||
|
||
} // 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,23 @@ | ||
#pragma once | ||
|
||
#include "common/types/types.h" | ||
#include "main/client_context.h" | ||
|
||
namespace kuzu { | ||
namespace main { | ||
|
||
typedef void (*set_context)(ClientContext* context, const common::Value& parameter); | ||
|
||
struct ConfigurationOption { | ||
const char* name; | ||
common::LogicalTypeID parameterType; | ||
set_context setContext; | ||
}; | ||
|
||
class DBConfig { | ||
public: | ||
static ConfigurationOption* getOptionByName(const std::string& optionName); | ||
}; | ||
|
||
} // namespace main | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#pragma once | ||
|
||
#include "common/types/value.h" | ||
#include "main/client_context.h" | ||
|
||
namespace kuzu { | ||
namespace main { | ||
|
||
struct ThreadsSetting { | ||
static constexpr const char* name = "threads"; | ||
static constexpr const common::LogicalTypeID inputType = common::LogicalTypeID::INT64; | ||
static void setContext(ClientContext* context, const common::Value& parameter) { | ||
assert(parameter.getDataType().getLogicalTypeID() == common::LogicalTypeID::INT64); | ||
context->numThreadsForExecution = parameter.getValue<int64_t>(); | ||
} | ||
}; | ||
|
||
struct TimeoutSetting { | ||
static constexpr const char* name = "timeout"; | ||
static constexpr const common::LogicalTypeID inputType = common::LogicalTypeID::INT64; | ||
static void setContext(ClientContext* context, const common::Value& parameter) { | ||
assert(parameter.getDataType().getLogicalTypeID() == common::LogicalTypeID::INT64); | ||
context->timeoutInMS = parameter.getValue<int64_t>(); | ||
context->startTimingIfEnabled(); | ||
} | ||
}; | ||
|
||
} // namespace main | ||
} // 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include "parser/expression/parsed_expression.h" | ||
#include "parser/statement.h" | ||
|
||
namespace kuzu { | ||
namespace parser { | ||
|
||
class Call : public Statement { | ||
public: | ||
explicit Call(std::string optionName, std::unique_ptr<ParsedExpression> optionValue) | ||
: Statement{common::StatementType::CALL}, optionName{std::move(optionName)}, | ||
optionValue{std::move(optionValue)} {} | ||
|
||
inline std::string getOptionName() const { return optionName; } | ||
|
||
inline ParsedExpression* getOptionValue() const { return optionValue.get(); } | ||
|
||
private: | ||
std::string optionName; | ||
std::unique_ptr<ParsedExpression> optionValue; | ||
}; | ||
|
||
} // namespace parser | ||
} // 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.