Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions extension/duckdb/test/test_files/duckdb.test
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ Attached database successfully.
-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 8
0|movies|ATTACHED|tinysnb(DUCKDB)|
0|person_copy|NODE|local(lbug)|
0|person_copy|NODE|main(graph)|
0|person|ATTACHED|Other1(DUCKDB)|
1|organisation|ATTACHED|tinysnb(DUCKDB)|
1|person_copy1|NODE|local(lbug)|
1|person_copy1|NODE|main(graph)|
2|person|ATTACHED|tinysnb(DUCKDB)|
3|tableOfTypes|ATTACHED|tinysnb(DUCKDB)|
4|tableOfTypes1|ATTACHED|tinysnb(DUCKDB)|
Expand Down Expand Up @@ -206,10 +206,10 @@ Attached database successfully.
---- 9
0|employee|ATTACHED|lbug(DUCKDB)|
0|movies|ATTACHED|tinysnb(DUCKDB)|
0|person_copy|NODE|local(lbug)|
0|person_copy|NODE|main(graph)|
0|person|ATTACHED|Other1(DUCKDB)|
1|organisation|ATTACHED|tinysnb(DUCKDB)|
1|person_copy1|NODE|local(lbug)|
1|person_copy1|NODE|main(graph)|
2|person|ATTACHED|tinysnb(DUCKDB)|
3|tableOfTypes|ATTACHED|tinysnb(DUCKDB)|
4|tableOfTypes1|ATTACHED|tinysnb(DUCKDB)|
Expand Down
1 change: 1 addition & 0 deletions extension/fts/src/function/drop_fts_index.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "function/drop_fts_index.h"

#include "catalog/catalog.h"
#include "function/fts_bind_data.h"
#include "function/fts_index_utils.h"
#include "function/table/bind_data.h"
Expand Down
1 change: 1 addition & 0 deletions extension/fts/src/function/query_fts_bind_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "binder/binder.h"
#include "binder/expression/expression_util.h"
#include "catalog/catalog.h"
#include "catalog/fts_index_catalog_entry.h"
#include "common/exception/binder.h"
#include "common/string_utils.h"
Expand Down
1 change: 1 addition & 0 deletions extension/fts/src/function/query_fts_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "binder/expression/expression_util.h"
#include "binder/expression/literal_expression.h"
#include "binder/query/reading_clause/bound_table_function_call.h"
#include "catalog/catalog.h"
#include "catalog/fts_index_catalog_entry.h"
#include "common/exception/binder.h"
#include "common/types/internal_id_util.h"
Expand Down
1 change: 1 addition & 0 deletions extension/fts/src/index/fts_internal_table_info.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "index/fts_internal_table_info.h"

#include "catalog/catalog.h"
#include "storage/storage_manager.h"
#include "utils/fts_utils.h"

Expand Down
12 changes: 6 additions & 6 deletions extension/fts/test/test_files/fts_small.test
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ name_stopwords
Binder exception: Table 0_docIdx_docs does not exist.
-STATEMENT call show_tables() return *
---- 6
0|doc|NODE|local(lbug)|
1|city_stopwords|NODE|local(lbug)|
2|name_stopwords|NODE|local(lbug)|
4|likes|REL|local(lbug)|
5|INVALID_STOPWORDS|NODE|local(lbug)|
6|INVALID_STOPWORDS_COL_TYPE|NODE|local(lbug)|
0|doc|NODE|main(graph)|
1|city_stopwords|NODE|main(graph)|
2|name_stopwords|NODE|main(graph)|
4|likes|REL|main(graph)|
5|INVALID_STOPWORDS|NODE|main(graph)|
6|INVALID_STOPWORDS_COL_TYPE|NODE|main(graph)|
-STATEMENT DROP TABLE `0_docIdx_docs`
---- error
Binder exception: Table 0_docIdx_docs does not exist.
Expand Down
24 changes: 12 additions & 12 deletions extension/neo4j/test/test_files/doc_example.test
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ Follows_User_User|since|INT64|["Long"]

-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 4
0|User|NODE|local(lbug)|
1|City|NODE|local(lbug)|
2|Follows|REL|local(lbug)|
3|LivesIn|REL|local(lbug)|
0|User|NODE|main(graph)|
1|City|NODE|main(graph)|
2|Follows|REL|main(graph)|
3|LivesIn|REL|main(graph)|
-STATEMENT match (u:User)-[f:Follows]->(u1:User) return max(f.since);
---- 1
2022
Expand All @@ -40,14 +40,14 @@ Follows_User_User|since|INT64|["Long"]

-STATEMENT CALL SHOW_TABLES() RETURN *;
---- 8
0|okLabel|NODE|local(lbug)|
3|badLabel|NODE|local(lbug)|
1|greatLabel|NODE|local(lbug)|
6|Follows|REL|local(lbug)|
4|User|NODE|local(lbug)|
2|City|NODE|local(lbug)|
5|LivesIn|REL|local(lbug)|
7|RANDOMREl|REL|local(lbug)|
0|okLabel|NODE|main(graph)|
3|badLabel|NODE|main(graph)|
1|greatLabel|NODE|main(graph)|
6|Follows|REL|main(graph)|
4|User|NODE|main(graph)|
2|City|NODE|main(graph)|
5|LivesIn|REL|main(graph)|
7|RANDOMREl|REL|main(graph)|

-STATEMENT match (u:User)-[f:Follows]->(u1:User) return max(f.since);
---- 1
Expand Down
2 changes: 1 addition & 1 deletion extension/postgres/test/test_files/postgres.test
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The 😂😃🧘🏻‍♂️🌍🌦️🍞🚗 movie
---- 9
0|movies|ATTACHED|pgscan(POSTGRES)|
0|movies|ATTACHED|tinysnb(POSTGRES)|
0|person_copy|NODE|local(lbug)|
0|person_copy|NODE|main(graph)|
1|organisation|ATTACHED|pgscan(POSTGRES)|
1|organisation|ATTACHED|tinysnb(POSTGRES)|
2|person|ATTACHED|pgscan(POSTGRES)|
Expand Down
1 change: 1 addition & 0 deletions extension/vector/src/function/create_hnsw_index.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "catalog/catalog.h"
#include "catalog/catalog_entry/function_catalog_entry.h"
#include "catalog/catalog_entry/node_table_catalog_entry.h"
#include "catalog/hnsw_index_catalog_entry.h"
Expand Down
1 change: 1 addition & 0 deletions extension/vector/src/function/query_hnsw_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "binder/expression/expression_util.h"
#include "binder/expression/literal_expression.h"
#include "binder/query/reading_clause/bound_table_function_call.h"
#include "catalog/catalog.h"
#include "catalog/catalog_entry/node_table_catalog_entry.h"
#include "catalog/hnsw_index_catalog_entry.h"
#include "common/exception/binder.h"
Expand Down
1 change: 1 addition & 0 deletions extension/vector/src/index/hnsw_index.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "index/hnsw_index.h"

#include "catalog/catalog.h"
#include "catalog/catalog_entry/index_catalog_entry.h"
#include "catalog/hnsw_index_catalog_entry.h"
#include "function/hnsw_index_functions.h"
Expand Down
18 changes: 9 additions & 9 deletions extension/vector/test/test_files/small.test
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@
---- ok
-STATEMENT CALL show_tables() return *;
---- 1
0|embeddings|NODE|local(lbug)|
0|embeddings|NODE|main(graph)|
-STATEMENT CALL ENABLE_INTERNAL_CATALOG=true;
---- ok
-STATEMENT CALL show_tables() return *;
---- 3
0|embeddings|NODE|local(lbug)|
9223372036854775808|_0_e_hnsw_index_UPPER|REL|local(lbug)|
9223372036854775809|_0_e_hnsw_index_LOWER|REL|local(lbug)|
0|embeddings|NODE|main(graph)|
9223372036854775808|_0_e_hnsw_index_UPPER|REL|main(graph)|
9223372036854775809|_0_e_hnsw_index_LOWER|REL|main(graph)|
-STATEMENT MATCH (t1:embeddings)-[r:_0_e_hnsw_index_UPPER]->(t2:embeddings) HINT (t1 JOIN r) JOIN t2 WITH t1.id as id, count(*) as cnt RETURN max(cnt);
---- 1
30
Expand All @@ -211,14 +211,14 @@
---- ok
-STATEMENT CALL show_tables() return *;
---- 1
0|embeddings|NODE|local(lbug)|
0|embeddings|NODE|main(graph)|
-STATEMENT CALL ENABLE_INTERNAL_CATALOG=true;
---- ok
-STATEMENT CALL show_tables() return *;
---- 3
0|embeddings|NODE|local(lbug)|
9223372036854775808|_0_e_hnsw_index_UPPER|REL|local(lbug)|
9223372036854775809|_0_e_hnsw_index_LOWER|REL|local(lbug)|
0|embeddings|NODE|main(graph)|
9223372036854775808|_0_e_hnsw_index_UPPER|REL|main(graph)|
9223372036854775809|_0_e_hnsw_index_LOWER|REL|main(graph)|
-STATEMENT MATCH (t1:embeddings)-[r:_0_e_hnsw_index_UPPER]->(t2:embeddings) HINT (t1 JOIN r) JOIN t2 WITH t1.id as id, count(*) as cnt RETURN max(cnt);
---- 1
30
Expand Down Expand Up @@ -362,7 +362,7 @@ Binder exception: _0_e_hnsw_index_UPPER already exists in catalog.
Binder exception: _0_e_hnsw_index_LOWER already exists in catalog.
-STATEMENT CALL show_tables() RETURN *
---- 1
0|embeddings|NODE|local(lbug)|
0|embeddings|NODE|main(graph)|
-STATEMENT EXPORT DATABASE '${LBUG_EXPORT_DB_DIRECTORY}_hnsw/small'
---- ok
-IMPORT_DATABASE "${LBUG_EXPORT_DB_DIRECTORY}_hnsw/small"
Expand Down
2 changes: 1 addition & 1 deletion extension/vector/test/test_files/transaction.test
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ Binder exception: CREATE_VECTOR_INDEX is only supported in auto transaction mode
-RELOADDB
-STATEMENT CALL show_tables() RETURN *;
---- 1
0|embeddings|NODE|local(lbug)|
0|embeddings|NODE|main(graph)|
-STATEMENT CALL show_indexes() RETURN *;
---- 0

Expand Down
12 changes: 10 additions & 2 deletions scripts/antlr4/Cypher.g4
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,9 @@ oC_Statement
| kU_ImportDatabase
| kU_AttachDatabase
| kU_DetachDatabase
| kU_UseDatabase;
| kU_UseDatabase
| kU_CreateGraph
| kU_UseGraph;

kU_CopyFrom
: COPY SP oC_SchemaName kU_ColumnNames? SP FROM SP kU_ScanSource ( SP? '(' SP? kU_Options SP? ')' )? ;
Expand Down Expand Up @@ -317,6 +319,12 @@ kU_DetachDatabase
kU_UseDatabase
: USE SP oC_SchemaName;

kU_CreateGraph
: CREATE SP GRAPH SP oC_SchemaName;

kU_UseGraph
: USE SP GRAPH SP oC_SchemaName;

kU_StandaloneCall
: CALL SP oC_SymbolicName SP? '=' SP? oC_Expression
| CALL SP oC_FunctionInvocation;
Expand Down Expand Up @@ -396,7 +404,7 @@ kU_IfExists
: IF SP EXISTS ;

kU_Drop
: DROP SP (TABLE | SEQUENCE | MACRO) SP (kU_IfExists SP)? oC_SchemaName ;
: DROP SP (TABLE | SEQUENCE | MACRO | GRAPH) SP (kU_IfExists SP)? oC_SchemaName ;

kU_AlterTable
: ALTER SP TABLE SP oC_SchemaName SP kU_AlterOptions ;
Expand Down
2 changes: 1 addition & 1 deletion scripts/antlr4/hash.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3f763bc647d64c15286c2616518546df
23abc548c739e12a248ee838ffeb96d1
12 changes: 10 additions & 2 deletions src/antlr4/Cypher.g4
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ oC_Statement
| kU_ImportDatabase
| kU_AttachDatabase
| kU_DetachDatabase
| kU_UseDatabase;
| kU_UseDatabase
| kU_CreateGraph
| kU_UseGraph;

kU_CopyFrom
: COPY SP oC_SchemaName kU_ColumnNames? SP FROM SP kU_ScanSource ( SP? '(' SP? kU_Options SP? ')' )? ;
Expand Down Expand Up @@ -70,6 +72,12 @@ kU_DetachDatabase
kU_UseDatabase
: USE SP oC_SchemaName;

kU_CreateGraph
: CREATE SP GRAPH SP oC_SchemaName;

kU_UseGraph
: USE SP GRAPH SP oC_SchemaName;

kU_StandaloneCall
: CALL SP oC_SymbolicName SP? '=' SP? oC_Expression
| CALL SP oC_FunctionInvocation;
Expand Down Expand Up @@ -149,7 +157,7 @@ kU_IfExists
: IF SP EXISTS ;

kU_Drop
: DROP SP (TABLE | SEQUENCE | MACRO) SP (kU_IfExists SP)? oC_SchemaName ;
: DROP SP (TABLE | SEQUENCE | MACRO | GRAPH) SP (kU_IfExists SP)? oC_SchemaName ;

kU_AlterTable
: ALTER SP TABLE SP oC_SchemaName SP kU_AlterOptions ;
Expand Down
1 change: 1 addition & 0 deletions src/binder/bind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ add_library(
bind_explain.cpp
bind_extension_clause.cpp
bind_file_scan.cpp
bind_graph.cpp
bind_graph_pattern.cpp
bind_projection_clause.cpp
bind_query.cpp
Expand Down
19 changes: 19 additions & 0 deletions src/binder/bind/bind_graph.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "binder/binder.h"
#include "binder/bound_graph_statement.h"
#include "parser/graph_statement.h"

namespace lbug {
namespace binder {

std::unique_ptr<BoundStatement> Binder::bindCreateGraph(const parser::Statement& statement) {
auto createGraph = statement.constCast<parser::CreateGraph>();
return std::make_unique<BoundCreateGraph>(createGraph.getGraphName());
}

std::unique_ptr<BoundStatement> Binder::bindUseGraph(const parser::Statement& statement) {
auto useGraph = statement.constCast<parser::UseGraph>();
return std::make_unique<BoundUseGraph>(useGraph.getGraphName());
}

} // namespace binder
} // namespace lbug
6 changes: 6 additions & 0 deletions src/binder/binder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ std::unique_ptr<BoundStatement> Binder::bind(const Statement& statement) {
case StatementType::USE_DATABASE: {
boundStatement = bindUseDatabase(statement);
} break;
case StatementType::CREATE_GRAPH: {
boundStatement = bindCreateGraph(statement);
} break;
case StatementType::USE_GRAPH: {
boundStatement = bindUseGraph(statement);
} break;
case StatementType::EXTENSION_CLAUSE: {
boundStatement = bindExtensionClause(statement);
} break;
Expand Down
6 changes: 6 additions & 0 deletions src/binder/bound_statement_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ void BoundStatementVisitor::visit(const BoundStatement& statement) {
case StatementType::USE_DATABASE: {
visitUseDatabase(statement);
} break;
case StatementType::CREATE_GRAPH: {
visitCreateGraph(statement);
} break;
case StatementType::USE_GRAPH: {
visitUseGraph(statement);
} break;
case StatementType::STANDALONE_CALL_FUNCTION: {
visitStandaloneCallFunction(statement);
} break;
Expand Down
11 changes: 9 additions & 2 deletions src/catalog/catalog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "extension/extension_manager.h"
#include "function/function_collection.h"
#include "main/client_context.h"
#include "main/database_manager.h"
#include "transaction/transaction.h"

using namespace lbug::binder;
Expand All @@ -35,9 +36,15 @@ Catalog::Catalog() : version{0} {
Catalog* Catalog::Get(const main::ClientContext& context) {
if (context.getAttachedDatabase()) {
return context.getAttachedDatabase()->getCatalog();
} else {
return context.getDatabase()->getCatalog();
}
auto dbManager = main::DatabaseManager::Get(context);
if (dbManager->hasDefaultGraph()) {
auto graphCatalog = dbManager->getDefaultGraphCatalog();
if (graphCatalog != nullptr) {
return graphCatalog;
}
}
return context.getDatabase()->getCatalog();
}

void Catalog::initCatalogSets() {
Expand Down
4 changes: 4 additions & 0 deletions src/common/enums/drop_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ std::string DropTypeUtils::toString(DropType type) {
return "Table";
case DropType::SEQUENCE:
return "Sequence";
case DropType::MACRO:
return "Macro";
case DropType::GRAPH:
return "Graph";
default:
KU_UNREACHABLE;
}
Expand Down
Loading