From d2d61770aaf92c06c6a1232bc81b2a70805b4101 Mon Sep 17 00:00:00 2001 From: Rafael Bey Date: Thu, 19 Sep 2024 10:57:52 -0400 Subject: [PATCH] Fix DuckDB flows + add test case --- .../toPureGraph/DuckDBCompilerExtension.java | 9 +++ .../TestDuckDBConnectionCompiler.java | 59 +++++++++++++++++++ .../TestDuckDBConnectionGrammarRoundtrip.java | 2 +- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/TestDuckDBConnectionCompiler.java diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DuckDBCompilerExtension.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DuckDBCompilerExtension.java index 04bcacab954..b831de1ee70 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DuckDBCompilerExtension.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/main/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/DuckDBCompilerExtension.java @@ -18,7 +18,10 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.list.MutableList; import org.finos.legend.engine.language.pure.compiler.toPureGraph.extension.CompilerExtension; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.DatabaseType; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.authentication.AuthenticationStrategy; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.authentication.TestDatabaseAuthenticationStrategy; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.flows.DatabaseAuthenticationFlowKey; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.specification.DatasourceSpecification; import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.connection.specification.DuckDBDatasourceSpecification; import org.finos.legend.pure.generated.Root_meta_pure_alloy_connections_alloy_authentication_AuthenticationStrategy; @@ -63,4 +66,10 @@ public CompilerExtension build() { return new DuckDBCompilerExtension(); } + + @Override + public List getFlowKeys() + { + return Lists.mutable.of(DatabaseAuthenticationFlowKey.newKey(DatabaseType.DuckDB, DuckDBDatasourceSpecification.class, TestDatabaseAuthenticationStrategy.class)); + } } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/TestDuckDBConnectionCompiler.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/TestDuckDBConnectionCompiler.java new file mode 100644 index 00000000000..837782285dd --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/compiler/toPureGraph/TestDuckDBConnectionCompiler.java @@ -0,0 +1,59 @@ +// Copyright 2024 Goldman Sachs +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +package org.finos.legend.engine.language.pure.compiler.toPureGraph; + +import org.finos.legend.engine.language.pure.compiler.test.TestCompilationFromGrammar; +import org.finos.legend.engine.language.pure.grammar.test.TestGrammarRoundtrip; +import org.junit.Ignore; +import org.junit.Test; + +public class TestDuckDBConnectionCompiler extends TestCompilationFromGrammar.TestCompilationFromGrammarTestSuite +{ + @Test + public void testDuckDbDatabaseConnection() + { + test("###Connection\n" + + "RelationalDatabaseConnection simple::DuckDBConnection\n" + + "{\n" + + " store: apps::pure::studio::relational::tests::dbInc;\n" + + " type: DuckDB;\n" + + " specification: DuckDB\n" + + " {\n" + + " path: '/test';\n" + + " };\n" + + " auth: Test;\n" + + "}\n"); + } + + @Override + protected String getDuplicatedElementTestCode() + { + throw new UnsupportedOperationException(); + } + + @Override + protected String getDuplicatedElementTestExpectedErrorMessage() + { + throw new UnsupportedOperationException(); + } + + @Test + @Ignore("N/A - no new elements on extension") + public void testDuplicatedElement() + { + throw new UnsupportedOperationException(); + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestDuckDBConnectionGrammarRoundtrip.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestDuckDBConnectionGrammarRoundtrip.java index 4228c6d66b1..65fe98e0601 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestDuckDBConnectionGrammarRoundtrip.java +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-dbExtension/legend-engine-xt-relationalStore-duckdb/legend-engine-xt-relationalStore-duckdb-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/TestDuckDBConnectionGrammarRoundtrip.java @@ -19,7 +19,7 @@ public class TestDuckDBConnectionGrammarRoundtrip extends TestGrammarRoundtrip.TestGrammarRoundtripTestSuite { @Test - public void testDeltaLakeDatabaseConnection() + public void testDuckDbDatabaseConnection() { test("###Connection\n" + "RelationalDatabaseConnection simple::DuckDBConnection\n" +