From 24666c81f9af5d8ecfd801da4eae47aa66458b37 Mon Sep 17 00:00:00 2001 From: "Sherjan, Haroon" Date: Thu, 19 Oct 2023 16:53:37 -0400 Subject: [PATCH 1/2] Connection DSL does not require store --- .../connection/MongoDBConnectionParseTreeWalker.java | 7 +------ .../grammar/integration/TestMongoDBConnectionCompiler.java | 2 -- .../integration/TestMongoDBConnectionGrammarParser.java | 1 - .../from/RelationalDatabaseConnectionParseTreeWalker.java | 5 ----- .../test/TestRelationalCompilationFromGrammar.java | 3 +-- .../test/TestRelationalConnectionGrammarParser.java | 2 +- 6 files changed, 3 insertions(+), 17 deletions(-) diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java index 9b468941432..8b0ab2aa19d 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java @@ -42,18 +42,13 @@ public MongoDBConnectionParseTreeWalker(ParseTreeWalkerSourceInformation walkerS public void visitMongoDBConnectionValue(MongoDBConnectionParserGrammar.DefinitionContext ctx, MongoDBConnection connectionValue, boolean isEmbedded) { // store (optional if the store is provided by embedding context, if not provided, it is required) - MongoDBConnectionParserGrammar.ConnectionStoreContext connectionStoreContext = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation); + MongoDBConnectionParserGrammar.ConnectionStoreContext connectionStoreContext = PureGrammarParserUtility.validateAndExtractOptionalField(ctx.connectionStore(), "store", connectionValue.sourceInformation); if (connectionStoreContext != null) { connectionValue.element = PureGrammarParserUtility.fromQualifiedName(connectionStoreContext.qualifiedName().packagePath() == null ? Collections.emptyList() : connectionStoreContext.qualifiedName().packagePath().identifier(), connectionStoreContext.qualifiedName().identifier()); connectionValue.elementSourceInformation = this.walkerSourceInformation.getSourceInformation(connectionStoreContext.qualifiedName()); connectionValue.type = DatabaseType.MongoDb; } - else if (!isEmbedded) - { - // Copied from service store, do we need this?? - PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation); - } // database type MongoDBDatasourceSpecification dsSpecification = getMongoDBDatasourceSpecification(ctx, connectionValue); connectionValue.dataSourceSpecification = dsSpecification; diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java index 4899126013e..ce721fb3ed6 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java @@ -28,7 +28,6 @@ protected String getDuplicatedElementTestCode() "MongoDBConnection test::mongodb::connection" + "{\n" + " database: legend_db;\n" + - " store: mongo::test::db;\n" + " serverURLs: [localhost:27071];\n" + " authentication: # UserPassword {\n" + " username: 'mongo_ro';\n" + @@ -60,7 +59,6 @@ public void testMongoDBConnectionDefinitionv1() "MongoDBConnection test::testConnection\n" + "{\n" + " database: legend_db;\n" + - " store: meta::external::store::mongodb::showcase::store::PersonDatabase;\n" + " serverURLs: [localhost:27071];\n" + " authentication: # UserPassword {\n" + " username: 'mongo_ro';\n" + diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionGrammarParser.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionGrammarParser.java index a2b236777d1..e02bd27b11d 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionGrammarParser.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionGrammarParser.java @@ -37,7 +37,6 @@ public String getParserGrammarIdentifierInclusionTestCode(List keywords) "MongoDBConnection " + ListAdapter.adapt(keywords).makeString("::") + "\n" + "{\n" + " database: legend_db;\n" + - " store: mongo::test::db;\n" + " serverURLs: [localhost:27071];\n" + " authentication: # UserPassword {\n" + " username: 'mongo_ro';\n" + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalDatabaseConnectionParseTreeWalker.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalDatabaseConnectionParseTreeWalker.java index d14fe27502a..848debb5114 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalDatabaseConnectionParseTreeWalker.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/RelationalDatabaseConnectionParseTreeWalker.java @@ -50,11 +50,6 @@ public void visitRelationalDatabaseConnectionValue(RelationalDatabaseConnectionP connectionValue.element = PureGrammarParserUtility.fromQualifiedName(storeContext.qualifiedName().packagePath() == null ? Collections.emptyList() : storeContext.qualifiedName().packagePath().identifier(), storeContext.qualifiedName().identifier()); connectionValue.elementSourceInformation = this.walkerSourceInformation.getSourceInformation(storeContext.qualifiedName()); } - else if (!isEmbedded) - { - // non-embedded connection requires store - PureGrammarParserUtility.validateAndExtractRequiredField(ctx.connectionStore(), "store", connectionValue.sourceInformation); - } // database type RelationalDatabaseConnectionParserGrammar.DbTypeContext dbTypeCtx = PureGrammarParserUtility.validateAndExtractRequiredField(ctx.dbType(), "type", connectionValue.sourceInformation); try diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java index 2278dfbd4f8..aaf0ccca908 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/test/TestRelationalCompilationFromGrammar.java @@ -2170,7 +2170,6 @@ public void testForMultipleRelationalConnections() "###Connection\n" + "RelationalDatabaseConnection relational::graphFetch::RelationalConnection\n" + "{\n" + - " store: relational::graphFetch::dbInc;\n" + " type: H2;\n" + " specification: Static\n" + " {\n" + @@ -2225,7 +2224,7 @@ public void testForMultipleRelationalConnections() " connection_1: relational::graphFetch::OneMappingConnection\n" + " ]\n" + " ];\n" + - "}\n", "COMPILATION error at [90:1-108:1]: Found 2 connections against store [dbInc] under a single runtime."); + "}\n", "COMPILATION error at [89:1-107:1]: Found 2 connections against store [dbInc] under a single runtime."); } @Test diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalConnectionGrammarParser.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalConnectionGrammarParser.java index 717141de685..0decfd55cbf 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalConnectionGrammarParser.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestRelationalConnectionGrammarParser.java @@ -60,7 +60,7 @@ public void testRelationalDatabaseConnection() test("###Connection\n" + "RelationalDatabaseConnection meta::mySimpleConnection\n" + "{\n" + - "}\n\n", "PARSER error at [2:1-4:1]: Field 'store' is required"); + "}\n\n", "PARSER error at [2:1-4:1]: Field 'type' is required"); test("###Connection\n" + "RelationalDatabaseConnection meta::mySimpleConnection\n" + "{\n" + From 9be121e62d645a74eea12f8e6e470a8270627134 Mon Sep 17 00:00:00 2001 From: Haroon Sherjan Date: Fri, 5 Jan 2024 16:53:23 -0500 Subject: [PATCH 2/2] Update Mongodb test for DSL update --- .../connection/MongoDBConnectionParseTreeWalker.java | 2 +- .../pure/grammar/integration/TestMongoDBConnectionCompiler.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java index 8b0ab2aa19d..d3b8032020c 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/main/java/org/finos/legend/engine/language/pure/grammar/integration/connection/MongoDBConnectionParseTreeWalker.java @@ -47,9 +47,9 @@ public void visitMongoDBConnectionValue(MongoDBConnectionParserGrammar.Definitio { connectionValue.element = PureGrammarParserUtility.fromQualifiedName(connectionStoreContext.qualifiedName().packagePath() == null ? Collections.emptyList() : connectionStoreContext.qualifiedName().packagePath().identifier(), connectionStoreContext.qualifiedName().identifier()); connectionValue.elementSourceInformation = this.walkerSourceInformation.getSourceInformation(connectionStoreContext.qualifiedName()); - connectionValue.type = DatabaseType.MongoDb; } // database type + connectionValue.type = DatabaseType.MongoDb; MongoDBDatasourceSpecification dsSpecification = getMongoDBDatasourceSpecification(ctx, connectionValue); connectionValue.dataSourceSpecification = dsSpecification; diff --git a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java index ce721fb3ed6..c2e61c3c0ca 100644 --- a/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java +++ b/legend-engine-xts-mongodb/legend-engine-xt-nonrelationalStore-mongodb-grammar-integration/src/test/java/org/finos/legend/engine/language/pure/grammar/integration/TestMongoDBConnectionCompiler.java @@ -46,7 +46,7 @@ protected String getDuplicatedElementTestCode() @Override protected String getDuplicatedElementTestExpectedErrorMessage() { - return "COMPILATION error at [16:1-18:1]: Duplicated element 'test::mongodb::connection'"; + return "COMPILATION error at [15:1-17:1]: Duplicated element 'test::mongodb::connection'"; } @Test