generated from duckdb/extension-template
-
Notifications
You must be signed in to change notification settings - Fork 8
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 #184 from cwida/pragma_show_property_graphs
Add pragma show_property_graphs
- Loading branch information
Showing
6 changed files
with
130 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
set(EXTENSION_SOURCES | ||
${CMAKE_CURRENT_SOURCE_DIR}/show_property_graphs.cpp | ||
${EXTENSION_SOURCES} | ||
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,27 @@ | ||
#include "duckdb/function/pragma_function.hpp" | ||
#include "duckdb/main/extension_util.hpp" | ||
#include <duckpgq/core/pragma/duckpgq_pragma.hpp> | ||
|
||
namespace duckpgq { | ||
|
||
namespace core { | ||
|
||
static string PragmaShowPropertyGraphs(ClientContext &context, const FunctionParameters ¶meters) { | ||
return "SELECT DISTINCT property_graph from __duckpgq_internal"; | ||
} | ||
|
||
void CorePGQPragma::RegisterShowPropertyGraphs(DatabaseInstance &instance) { | ||
// Define the pragma function | ||
auto pragma_func = PragmaFunction::PragmaCall( | ||
"show_property_graphs", // Name of the pragma | ||
PragmaShowPropertyGraphs, // Query substitution function | ||
{} // Parameter types (mail_limit is an integer) | ||
); | ||
|
||
// Register the pragma function | ||
ExtensionUtil::RegisterFunction(instance, pragma_func); | ||
} | ||
|
||
} // namespace core | ||
|
||
} // namespace duckpgq |
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,32 @@ | ||
//===----------------------------------------------------------------------===// | ||
// DuckDB | ||
// | ||
// duckpgq/include/core/pragma/show_property_graphs.hpp | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#pragma once | ||
#include "duckpgq/common.hpp" | ||
|
||
namespace duckpgq { | ||
|
||
namespace core { | ||
|
||
//! Class to register the PRAGMA create_inbox function | ||
class CorePGQPragma { | ||
public: | ||
//! Register the PRAGMA function | ||
static void Register(DatabaseInstance &instance) { | ||
RegisterShowPropertyGraphs(instance); | ||
} | ||
|
||
private: | ||
static void RegisterShowPropertyGraphs(DatabaseInstance &instance); | ||
|
||
}; | ||
|
||
|
||
|
||
} // namespace core | ||
|
||
} // namespace duckpgq |
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,61 @@ | ||
|
||
require duckpgq | ||
|
||
statement ok | ||
import database 'duckdb/data/SNB0.003'; | ||
|
||
statement ok | ||
-CREATE PROPERTY GRAPH snb | ||
VERTEX TABLES ( | ||
Person LABEL Person, | ||
Forum LABEL Forum, | ||
Organisation LABEL Organisation IN typemask(company, university), | ||
Place LABEL Place, | ||
Tag LABEL Tag, | ||
TagClass LABEL TagClass, | ||
Country LABEL Country, | ||
City LABEL City, | ||
Message LABEL Message | ||
) | ||
EDGE TABLES ( | ||
Person_knows_person SOURCE KEY (Person1Id) REFERENCES Person (id) | ||
DESTINATION KEY (Person2Id) REFERENCES Person (id) | ||
LABEL Knows, | ||
Forum_hasMember_Person SOURCE KEY (ForumId) REFERENCES Forum (id) | ||
DESTINATION KEY (PersonId) REFERENCES Person (id) | ||
LABEL hasMember, | ||
Forum_hasTag_Tag SOURCE KEY (ForumId) REFERENCES Forum (id) | ||
DESTINATION KEY (TagId) REFERENCES Tag (id) | ||
LABEL Forum_hasTag, | ||
Person_hasInterest_Tag SOURCE KEY (PersonId) REFERENCES Person (id) | ||
DESTINATION KEY (TagId) REFERENCES Tag (id) | ||
LABEL hasInterest, | ||
person_workAt_Organisation SOURCE KEY (PersonId) REFERENCES Person (id) | ||
DESTINATION KEY (OrganisationId) REFERENCES Organisation (id) | ||
LABEL workAt_Organisation, | ||
Person_likes_Message SOURCE KEY (PersonId) REFERENCES Person (id) | ||
DESTINATION KEY (id) REFERENCES Message (id) | ||
LABEL likes_Message, | ||
Message_hasTag_Tag SOURCE KEY (id) REFERENCES Message (id) | ||
DESTINATION KEY (TagId) REFERENCES Tag (id) | ||
LABEL message_hasTag, | ||
Message_hasAuthor_Person SOURCE KEY (messageId) REFERENCES Message (id) | ||
DESTINATION KEY (PersonId) REFERENCES Person (id) | ||
LABEL hasAuthor, | ||
Message_replyOf_Message SOURCE KEY (messageId) REFERENCES Message (id) | ||
DESTINATION KEY (ParentMessageId) REFERENCES Message (id) | ||
LABEL replyOf | ||
); | ||
|
||
query I | ||
pragma show_property_graphs; | ||
---- | ||
snb | ||
|
||
statement ok | ||
-drop property graph snb; | ||
|
||
query I | ||
pragma show_property_graphs; | ||
---- | ||
|