From 04e124f2ef7c76d4ee20af03afbf889d2fea1502 Mon Sep 17 00:00:00 2001 From: Martin Vahlensieck Date: Thu, 19 Dec 2024 11:25:11 +0100 Subject: [PATCH] Remove constant method getNamespaceId --- core/src/main/java/org/polypheny/db/nodes/Node.java | 5 ----- .../main/java/org/polypheny/db/processing/QueryContext.java | 2 +- .../java/org/polypheny/db/languages/mql/MqlCreateView.java | 4 +--- .../org/polypheny/db/languages/mql/MqlRenameCollection.java | 5 +---- 4 files changed, 3 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/org/polypheny/db/nodes/Node.java b/core/src/main/java/org/polypheny/db/nodes/Node.java index 60268b7b41..826143642f 100644 --- a/core/src/main/java/org/polypheny/db/nodes/Node.java +++ b/core/src/main/java/org/polypheny/db/nodes/Node.java @@ -21,7 +21,6 @@ import java.util.Set; import org.jetbrains.annotations.Nullable; import org.polypheny.db.algebra.constant.Kind; -import org.polypheny.db.catalog.Catalog; import org.polypheny.db.languages.ParserPos; import org.polypheny.db.languages.QueryLanguage; import org.polypheny.db.util.Litmus; @@ -96,10 +95,6 @@ default boolean isDdl() { return Kind.DDL.contains( getKind() ); } - default long getNamespaceId() { - return Catalog.defaultNamespaceId; - } - @Nullable default String getNamespaceName() { return null; diff --git a/core/src/main/java/org/polypheny/db/processing/QueryContext.java b/core/src/main/java/org/polypheny/db/processing/QueryContext.java index a9f934bb5d..a984b93db7 100644 --- a/core/src/main/java/org/polypheny/db/processing/QueryContext.java +++ b/core/src/main/java/org/polypheny/db/processing/QueryContext.java @@ -107,7 +107,7 @@ public static ParsedQueryContext fromQuery( String query, Node queryNode, QueryC long namespaceId = context.namespaceId; if ( queryNode != null && queryNode.getNamespaceName() != null ) { - namespaceId = Catalog.snapshot().getNamespace( queryNode.getNamespaceName() ).map( n -> n.id ).orElse( queryNode.getNamespaceId() ); + namespaceId = Catalog.snapshot().getNamespace( queryNode.getNamespaceName() ).map( n -> n.id ).orElse( namespaceId ); } if ( context.transactions.stream().anyMatch( t -> !t.isActive() ) ) { diff --git a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlCreateView.java b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlCreateView.java index b33839ed74..b55898ff6f 100644 --- a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlCreateView.java +++ b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlCreateView.java @@ -52,9 +52,7 @@ public MqlCreateView( ParserPos pos, String name, String namespace, String sourc @Override public void execute( Context context, Statement statement, ParsedQueryContext parsedQueryContext ) { - long database = parsedQueryContext.getQueryNode().orElseThrow().getNamespaceId(); - - long namespaceId = context.getSnapshot().getNamespace( database ).orElseThrow().id; + long namespaceId = context.getSnapshot().getNamespace( parsedQueryContext.getNamespaceId() ).orElseThrow().id; QueryContext queryContext = QueryContext.builder() .query( buildQuery() ) diff --git a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlRenameCollection.java b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlRenameCollection.java index 8c934b9b78..c62451e807 100644 --- a/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlRenameCollection.java +++ b/plugins/mql-language/src/main/java/org/polypheny/db/languages/mql/MqlRenameCollection.java @@ -48,16 +48,13 @@ public Type getMqlKind() { @Override public void execute( Context context, Statement statement, ParsedQueryContext parsedQueryContext ) { - long namespaceId = parsedQueryContext.getQueryNode().orElseThrow().getNamespaceId(); - - LogicalCollection collection = context.getSnapshot().doc().getCollection( namespaceId, getCollection() ).orElseThrow(); + LogicalCollection collection = context.getSnapshot().doc().getCollection( parsedQueryContext.getNamespaceId(), getCollection() ).orElseThrow(); if ( dropTarget ) { DdlManager.getInstance().dropCollection( collection, statement ); } DdlManager.getInstance().renameCollection( collection, newName, statement ); - }