Skip to content

Commit

Permalink
Format fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dtenwolde committed Jan 18, 2024
1 parent abdb35b commit e930586
Show file tree
Hide file tree
Showing 8 changed files with 1,150 additions and 1,109 deletions.
33 changes: 15 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
cmake_minimum_required(VERSION 2.8.12)

# Set extension name here
#<<<<<<< HEAD
#set(TARGET_NAME duckpgq)
# Set extension name here <<<<<<< HEAD set(TARGET_NAME duckpgq)
#
#set(EXTENSION_NAME ${TARGET_NAME}_extension)
#project(${TARGET_NAME})
#set(CMAKE_CXX_STANDARD 11)
# set(EXTENSION_NAME ${TARGET_NAME}_extension) project(${TARGET_NAME})
# set(CMAKE_CXX_STANDARD 11)
#
#include_directories(duckpgq/include)
#add_subdirectory(duckpgq/src)
# include_directories(duckpgq/include) add_subdirectory(duckpgq/src)
#
#include_directories(../duckdb-pgq/third_party/libpg_query/include)
# include_directories(../duckdb-pgq/third_party/libpg_query/include)
#
#add_library(${EXTENSION_NAME} STATIC ${EXTENSION_SOURCES})
# add_library(${EXTENSION_NAME} STATIC ${EXTENSION_SOURCES})
#
#set(PARAMETERS "-warnings")
#build_loadable_extension(${TARGET_NAME} ${PARAMETERS} ${EXTENSION_SOURCES})
#=======
# set(PARAMETERS "-warnings") build_loadable_extension(${TARGET_NAME}
# ${PARAMETERS} ${EXTENSION_SOURCES})
# =======
set(TARGET_NAME duckpgq)
set(CMAKE_CXX_STANDARD 11)
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be added in ./vcpkg.json and then
# used in cmake with find_package. Feel free to remove or replace with other dependencies.
# Note that it should also be removed from vcpkg.json to prevent needlessly installing it..
# DuckDB's extension distribution supports vcpkg. As such, dependencies can be
# added in ./vcpkg.json and then used in cmake with find_package. Feel free to
# remove or replace with other dependencies. Note that it should also be removed
# from vcpkg.json to prevent needlessly installing it..
find_package(OpenSSL REQUIRED)

set(EXTENSION_NAME ${TARGET_NAME}_extension)
Expand All @@ -33,15 +30,15 @@ include_directories(duckpgq/include)
add_subdirectory(duckpgq/src)
include_directories(../duckdb-pgq/third_party/libpg_query/include)

#set(EXTENSION_SOURCES duckpgq/src/duckpgq_extension.cpp)
# set(EXTENSION_SOURCES duckpgq/src/duckpgq_extension.cpp)

build_static_extension(${TARGET_NAME} ${EXTENSION_SOURCES})
build_loadable_extension(${TARGET_NAME} " " ${EXTENSION_SOURCES})

# Link OpenSSL in both the static library as the loadable extension
target_link_libraries(${EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
target_link_libraries(${LOADABLE_EXTENSION_NAME} OpenSSL::SSL OpenSSL::Crypto)
#>>>>>>> template/main
# >>>>>>> template/main

install(
TARGETS ${EXTENSION_NAME}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ test_release_python: release_python

#### Misc
format:
find src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --sort-includes=0 -style=file -i
find duckpgq/ -iname *.hpp -o -iname *.cpp | xargs clang-format --sort-includes=0 -style=file -i
cmake-format -i CMakeLists.txt
update:
git submodule update --remote --merge
Expand Down
249 changes: 127 additions & 122 deletions duckpgq/include/duckpgq/functions/tablefunctions/match.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,126 +16,131 @@
#include "duckdb/parser/path_pattern.hpp"

namespace duckdb {
struct PGQMatchFunction : public TableFunction {
public:
PGQMatchFunction() {
name = "duckpgq_match";
bind_replace = MatchBindReplace;
}

struct MatchBindData : public TableFunctionData {
bool done = false;
};


static shared_ptr<PropertyGraphTable>
FindGraphTable(const string& label, CreatePropertyGraphInfo& pg_table);

static void
CheckInheritance(const shared_ptr<PropertyGraphTable>& tableref,
PathElement* element,
vector<unique_ptr<ParsedExpression>>& conditions);

static void
CheckEdgeTableConstraints(const string& src_reference,
const string& dst_reference,
const shared_ptr<PropertyGraphTable>& edge_table);

static unique_ptr<ParsedExpression> CreateMatchJoinExpression(
vector<string> vertex_keys, vector<string> edge_keys,
const string& vertex_alias, const string& edge_alias);

static PathElement*
GetPathElement(const unique_ptr<PathReference>& path_reference);

static unique_ptr<SubqueryExpression>
GetCountTable(const shared_ptr<PropertyGraphTable>& edge_table,
const string& prev_binding);

static unique_ptr<JoinRef>
GetJoinRef(const shared_ptr<PropertyGraphTable>& edge_table,
const string& edge_binding, const string& prev_binding,
const string& next_binding);

static unique_ptr<SubqueryRef> CreateCountCTESubquery();

static unique_ptr<CommonTableExpressionInfo>
CreateCSRCTE(const shared_ptr<PropertyGraphTable>& edge_table,
const string& edge_binding, const string& prev_binding,
const string& next_binding);

static void EdgeTypeAny(const shared_ptr<PropertyGraphTable>& edge_table,
const string& edge_binding,
const string& prev_binding,
const string& next_binding,
vector<unique_ptr<ParsedExpression>>& conditions);

static void EdgeTypeLeft(const shared_ptr<PropertyGraphTable>& edge_table,
const string& next_table_name,
const string& prev_table_name,
const string& edge_binding,
const string& prev_binding,
const string& next_binding,
vector<unique_ptr<ParsedExpression>>& conditions);

static void EdgeTypeRight(const shared_ptr<PropertyGraphTable>& edge_table,
const string& next_table_name,
const string& prev_table_name,
const string& edge_binding,
const string& prev_binding,
const string& next_binding,
vector<unique_ptr<ParsedExpression>>& conditions);

static void EdgeTypeLeftRight(
const shared_ptr<PropertyGraphTable>& edge_table, const string& edge_binding,
const string& prev_binding, const string& next_binding,
vector<unique_ptr<ParsedExpression>>& conditions,
unordered_map<string, string>& alias_map, int32_t& extra_alias_counter);

static PathElement*
HandleNestedSubPath(unique_ptr<PathReference>& path_reference,
vector<unique_ptr<ParsedExpression>>& conditions,
idx_t element_idx);

static unique_ptr<TableRef> MatchBindReplace(ClientContext& context,
TableFunctionBindInput& input);

static unique_ptr<SubqueryRef> GenerateSubpathPatternSubquery(
unique_ptr<PathPattern>& path_pattern, CreatePropertyGraphInfo* pg_table,
vector<unique_ptr<ParsedExpression>>& column_list,
unordered_set<string>& named_subpaths);

static unique_ptr<ParsedExpression>
CreatePathFindingFunction(vector<unique_ptr<PathReference>> &path_list, CreatePropertyGraphInfo &pg_table);


static void AddPathFinding(const unique_ptr<SelectNode>& select_node,
unique_ptr<TableRef>& from_clause,
vector<unique_ptr<ParsedExpression>>& conditions,
const string& prev_binding, const string& edge_binding, const string& next_binding,
const shared_ptr<PropertyGraphTable>& edge_table,
const SubPath* subpath);

static void AddEdgeJoins(const unique_ptr<SelectNode>& select_node,
const shared_ptr<PropertyGraphTable>& edge_table,
const shared_ptr<PropertyGraphTable>& previous_vertex_table,
const shared_ptr<PropertyGraphTable>& next_vertex_table,
PGQMatchType edge_type,
const string& edge_binding,
const string& prev_binding,
const string& next_binding,
vector<unique_ptr<ParsedExpression>>& conditions,
unordered_map<string, string>& alias_map,
int32_t& extra_alias_counter);

static void ProcessPathList(vector<unique_ptr<PathReference>>& path_pattern,
vector<unique_ptr<ParsedExpression>>& conditions,
unique_ptr<TableRef>& from_clause, unique_ptr<SelectNode>& select_node,
unordered_map<string, string>& alias_map,
CreatePropertyGraphInfo& pg_table, int32_t& extra_alias_counter,
vector<unique_ptr<ParsedExpression>>& column_list);

static void CheckNamedSubpath(SubPath &subpath, vector<unique_ptr<ParsedExpression>>& column_list,
CreatePropertyGraphInfo &pg_table);
};
struct PGQMatchFunction : public TableFunction {
public:
PGQMatchFunction() {
name = "duckpgq_match";
bind_replace = MatchBindReplace;
}

struct MatchBindData : public TableFunctionData {
bool done = false;
};

static shared_ptr<PropertyGraphTable>
FindGraphTable(const string &label, CreatePropertyGraphInfo &pg_table);

static void
CheckInheritance(const shared_ptr<PropertyGraphTable> &tableref,
PathElement *element,
vector<unique_ptr<ParsedExpression>> &conditions);

static void
CheckEdgeTableConstraints(const string &src_reference,
const string &dst_reference,
const shared_ptr<PropertyGraphTable> &edge_table);

static unique_ptr<ParsedExpression> CreateMatchJoinExpression(
vector<string> vertex_keys, vector<string> edge_keys,
const string &vertex_alias, const string &edge_alias);

static PathElement *
GetPathElement(const unique_ptr<PathReference> &path_reference);

static unique_ptr<SubqueryExpression>
GetCountTable(const shared_ptr<PropertyGraphTable> &edge_table,
const string &prev_binding);

static unique_ptr<JoinRef>
GetJoinRef(const shared_ptr<PropertyGraphTable> &edge_table,
const string &edge_binding, const string &prev_binding,
const string &next_binding);

static unique_ptr<SubqueryRef> CreateCountCTESubquery();

static unique_ptr<CommonTableExpressionInfo>
CreateCSRCTE(const shared_ptr<PropertyGraphTable> &edge_table,
const string &edge_binding, const string &prev_binding,
const string &next_binding);

static void EdgeTypeAny(const shared_ptr<PropertyGraphTable> &edge_table,
const string &edge_binding,
const string &prev_binding,
const string &next_binding,
vector<unique_ptr<ParsedExpression>> &conditions);

static void EdgeTypeLeft(const shared_ptr<PropertyGraphTable> &edge_table,
const string &next_table_name,
const string &prev_table_name,
const string &edge_binding,
const string &prev_binding,
const string &next_binding,
vector<unique_ptr<ParsedExpression>> &conditions);

static void EdgeTypeRight(const shared_ptr<PropertyGraphTable> &edge_table,
const string &next_table_name,
const string &prev_table_name,
const string &edge_binding,
const string &prev_binding,
const string &next_binding,
vector<unique_ptr<ParsedExpression>> &conditions);

static void
EdgeTypeLeftRight(const shared_ptr<PropertyGraphTable> &edge_table,
const string &edge_binding, const string &prev_binding,
const string &next_binding,
vector<unique_ptr<ParsedExpression>> &conditions,
unordered_map<string, string> &alias_map,
int32_t &extra_alias_counter);

static PathElement *
HandleNestedSubPath(unique_ptr<PathReference> &path_reference,
vector<unique_ptr<ParsedExpression>> &conditions,
idx_t element_idx);

static unique_ptr<TableRef> MatchBindReplace(ClientContext &context,
TableFunctionBindInput &input);

static unique_ptr<SubqueryRef> GenerateSubpathPatternSubquery(
unique_ptr<PathPattern> &path_pattern, CreatePropertyGraphInfo *pg_table,
vector<unique_ptr<ParsedExpression>> &column_list,
unordered_set<string> &named_subpaths);

static unique_ptr<ParsedExpression>
CreatePathFindingFunction(vector<unique_ptr<PathReference>> &path_list,
CreatePropertyGraphInfo &pg_table);

static void AddPathFinding(const unique_ptr<SelectNode> &select_node,
unique_ptr<TableRef> &from_clause,
vector<unique_ptr<ParsedExpression>> &conditions,
const string &prev_binding,
const string &edge_binding,
const string &next_binding,
const shared_ptr<PropertyGraphTable> &edge_table,
const SubPath *subpath);

static void
AddEdgeJoins(const unique_ptr<SelectNode> &select_node,
const shared_ptr<PropertyGraphTable> &edge_table,
const shared_ptr<PropertyGraphTable> &previous_vertex_table,
const shared_ptr<PropertyGraphTable> &next_vertex_table,
PGQMatchType edge_type, const string &edge_binding,
const string &prev_binding, const string &next_binding,
vector<unique_ptr<ParsedExpression>> &conditions,
unordered_map<string, string> &alias_map,
int32_t &extra_alias_counter);

static void ProcessPathList(
vector<unique_ptr<PathReference>> &path_pattern,
vector<unique_ptr<ParsedExpression>> &conditions,
unique_ptr<TableRef> &from_clause, unique_ptr<SelectNode> &select_node,
unordered_map<string, string> &alias_map,
CreatePropertyGraphInfo &pg_table, int32_t &extra_alias_counter,
vector<unique_ptr<ParsedExpression>> &column_list);

static void
CheckNamedSubpath(SubPath &subpath,
vector<unique_ptr<ParsedExpression>> &column_list,
CreatePropertyGraphInfo &pg_table);
};
} // namespace duckdb
4 changes: 2 additions & 2 deletions duckpgq/include/duckpgq/functions/tablefunctions/pgq_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ struct CSRScanPtrData : public TableFunctionData {
public:
static unique_ptr<FunctionData>
ScanCSRPtrBind(ClientContext &context, TableFunctionBindInput &input,
vector<LogicalType> &return_types, vector<string> &names) {
vector<LogicalType> &return_types, vector<string> &names) {
auto result = make_uniq<CSRScanPtrData>();
result->csr_id = input.inputs[0].GetValue<int32_t>();
return_types.emplace_back(LogicalType::UBIGINT);
names.emplace_back("ptr");
return std::move(result);
}
}

public:
int32_t csr_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ CreatePropertyGraphFunction::CreatePropertyGraphBind(
CheckPropertyGraphTableLabels(vertex_table, table);

v_table_names.insert(vertex_table->table_name);
if (vertex_table->hasTableNameAlias()) {
v_table_names.insert(vertex_table->table_name_alias);
}
if (vertex_table->hasTableNameAlias()) {
v_table_names.insert(vertex_table->table_name_alias);
}
}

for (auto &edge_table : info->edge_tables) {
Expand Down
Loading

0 comments on commit e930586

Please sign in to comment.