-
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
Showing
23 changed files
with
355 additions
and
260 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
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
add_library(kuzu_function_table_functions | ||
OBJECT | ||
current_setting.cpp | ||
db_version.cpp | ||
show_tables.cpp | ||
table_info.cpp) | ||
|
||
set(ALL_OBJECT_FILES | ||
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:kuzu_function_table_functions> | ||
PARENT_SCOPE) |
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,45 @@ | ||
#include "function/table_functions/current_setting.h" | ||
|
||
#include "common/vector/value_vector.h" | ||
#include "function/table_functions/bind_data.h" | ||
#include "function/table_functions/bind_input.h" | ||
#include "main/client_context.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
namespace kuzu::function { | ||
struct CurrentSettingBindData : public TableFuncBindData { | ||
std::string result; | ||
|
||
CurrentSettingBindData(std::string result, std::vector<common::LogicalType> returnTypes, | ||
std::vector<std::string> returnColumnNames, common::offset_t maxOffset) | ||
: result{std::move(result)}, TableFuncBindData{std::move(returnTypes), | ||
std::move(returnColumnNames), maxOffset} {} | ||
|
||
std::unique_ptr<TableFuncBindData> copy() override { | ||
return std::make_unique<CurrentSettingBindData>( | ||
result, returnTypes, returnColumnNames, maxOffset); | ||
} | ||
}; | ||
|
||
void CurrentSettingFunction::tableFunc(std::pair<offset_t, offset_t> morsel, | ||
function::TableFuncBindData* bindData, std::vector<ValueVector*> outputVectors) { | ||
auto currentSettingBindData = reinterpret_cast<CurrentSettingBindData*>(bindData); | ||
auto outputVector = outputVectors[0]; | ||
auto pos = outputVector->state->selVector->selectedPositions[0]; | ||
outputVectors[0]->setValue(pos, currentSettingBindData->result); | ||
outputVectors[0]->setNull(pos, false); | ||
outputVector->state->selVector->selectedSize = 1; | ||
} | ||
|
||
std::unique_ptr<TableFuncBindData> CurrentSettingFunction::bindFunc(main::ClientContext* context, | ||
kuzu::function::TableFuncBindInput input, catalog::CatalogContent* catalog) { | ||
auto optionName = input.inputs[0].getValue<std::string>(); | ||
std::vector<std::string> returnColumnNames; | ||
std::vector<LogicalType> returnTypes; | ||
returnColumnNames.emplace_back(optionName); | ||
returnTypes.emplace_back(LogicalTypeID::STRING); | ||
return std::make_unique<CurrentSettingBindData>(context->getCurrentSetting(optionName), | ||
std::move(returnTypes), std::move(returnColumnNames), 1 /* one row result */); | ||
} | ||
} // namespace kuzu::function |
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 @@ | ||
#include "function/table_functions/db_version.h" | ||
|
||
#include "common/vector/value_vector.h" | ||
#include "function/table_functions/bind_data.h" | ||
#include "function/table_functions/bind_input.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
namespace kuzu::function { | ||
void DBVersionFunction::tableFunc(std::pair<offset_t, offset_t> morsel, | ||
function::TableFuncBindData* bindData, std::vector<ValueVector*> outputVectors) { | ||
auto outputVector = outputVectors[0]; | ||
auto pos = outputVector->state->selVector->selectedPositions[0]; | ||
outputVectors[0]->setValue(pos, std::string(KUZU_VERSION)); | ||
outputVectors[0]->setNull(pos, false); | ||
outputVector->state->selVector->selectedSize = 1; | ||
} | ||
|
||
std::unique_ptr<TableFuncBindData> DBVersionFunction::bindFunc(main::ClientContext* context, | ||
kuzu::function::TableFuncBindInput input, catalog::CatalogContent* catalog) { | ||
std::vector<std::string> returnColumnNames; | ||
std::vector<LogicalType> returnTypes; | ||
returnColumnNames.emplace_back("version"); | ||
returnTypes.emplace_back(LogicalTypeID::STRING); | ||
return std::make_unique<TableFuncBindData>( | ||
std::move(returnTypes), std::move(returnColumnNames), 1 /* one row result */); | ||
} | ||
|
||
} // namespace kuzu::function |
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,57 @@ | ||
#include "function/table_functions/show_tables.h" | ||
|
||
#include "catalog/catalog_content.h" | ||
#include "catalog/table_schema.h" | ||
#include "common/vector/value_vector.h" | ||
#include "function/table_functions/bind_data.h" | ||
#include "function/table_functions/bind_input.h" | ||
|
||
using namespace kuzu::common; | ||
|
||
namespace kuzu::function { | ||
|
||
struct ShowTablesBindData : public TableFuncBindData { | ||
std::vector<catalog::TableSchema*> tables; | ||
|
||
ShowTablesBindData(std::vector<catalog::TableSchema*> tables, | ||
std::vector<common::LogicalType> returnTypes, std::vector<std::string> returnColumnNames, | ||
common::offset_t maxOffset) | ||
: tables{std::move(tables)}, TableFuncBindData{std::move(returnTypes), | ||
std::move(returnColumnNames), maxOffset} {} | ||
|
||
inline std::unique_ptr<TableFuncBindData> copy() override { | ||
return std::make_unique<ShowTablesBindData>( | ||
tables, returnTypes, returnColumnNames, maxOffset); | ||
} | ||
}; | ||
|
||
void ShowTablesFunction::tableFunc(std::pair<offset_t, offset_t> morsel, | ||
function::TableFuncBindData* bindData, std::vector<ValueVector*> outputVectors) { | ||
auto tables = reinterpret_cast<function::ShowTablesBindData*>(bindData)->tables; | ||
auto numTablesToOutput = morsel.second - morsel.first; | ||
for (auto i = 0u; i < numTablesToOutput; i++) { | ||
auto tableSchema = tables[morsel.first + i]; | ||
outputVectors[0]->setValue(i, tableSchema->tableName); | ||
std::string typeString = TableTypeUtils::toString(tableSchema->tableType); | ||
outputVectors[1]->setValue(i, typeString); | ||
outputVectors[2]->setValue(i, tableSchema->comment); | ||
} | ||
outputVectors[0]->state->selVector->selectedSize = numTablesToOutput; | ||
} | ||
|
||
std::unique_ptr<TableFuncBindData> ShowTablesFunction::bindFunc(main::ClientContext* context, | ||
kuzu::function::TableFuncBindInput input, catalog::CatalogContent* catalog) { | ||
std::vector<std::string> returnColumnNames; | ||
std::vector<LogicalType> returnTypes; | ||
returnColumnNames.emplace_back("name"); | ||
returnTypes.emplace_back(LogicalTypeID::STRING); | ||
returnColumnNames.emplace_back("type"); | ||
returnTypes.emplace_back(LogicalTypeID::STRING); | ||
returnColumnNames.emplace_back("comment"); | ||
returnTypes.emplace_back(LogicalTypeID::STRING); | ||
|
||
return std::make_unique<ShowTablesBindData>(catalog->getTableSchemas(), std::move(returnTypes), | ||
std::move(returnColumnNames), catalog->getTableCount()); | ||
} | ||
|
||
} // namespace kuzu::function |
Oops, something went wrong.