diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java index d354ba7af1f..f85cd75da61 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-data-cube/src/main/java/org/finos/legend/engine/repl/dataCube/commands/DataCube__DEV__runDuckDBSelectSQL.java @@ -29,7 +29,7 @@ import java.sql.Statement; import java.util.List; -import static org.finos.legend.engine.repl.relational.shared.ResultHelper.prettyGridPrint; +import static org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResultGridPrintUtility.prettyGridPrint; public class DataCube__DEV__runDuckDBSelectSQL implements Command { diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java index 5641ed2c348..8ed446d7587 100644 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java +++ b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/RelationalReplExtension.java @@ -16,9 +16,9 @@ import org.eclipse.collections.api.list.MutableList; import org.eclipse.collections.impl.factory.Lists; -import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.plan.execution.result.Result; import org.finos.legend.engine.plan.execution.stores.relational.AlloyH2Server; +import org.finos.legend.engine.plan.execution.stores.relational.result.RealizedRelationalResult; import org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult; import org.finos.legend.engine.repl.client.Client; import org.finos.legend.engine.repl.core.Command; @@ -30,10 +30,9 @@ import org.finos.legend.engine.repl.relational.local.LocalConnectionManagement; import org.finos.legend.engine.repl.relational.local.LocalConnectionType; -import java.sql.ResultSet; import java.sql.SQLException; -import static org.finos.legend.engine.repl.relational.shared.ResultHelper.prettyGridPrint; +import static org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResultGridPrintUtility.prettyGridPrint; public class RelationalReplExtension implements ReplExtension { @@ -91,20 +90,21 @@ public MutableList getExtraCommands() @Override public boolean supports(Result res) { - return res instanceof RelationalResult; + return res instanceof RelationalResult || res instanceof RealizedRelationalResult; } @Override public String print(Result res) { - RelationalResult relationalResult = (RelationalResult) res; - try (ResultSet rs = relationalResult.resultSet) + if (res instanceof RelationalResult) { - return prettyGridPrint(rs, relationalResult.sqlColumns, ListIterate.collect(relationalResult.getSQLResultColumns(), col -> col.dataType), maxRowSize, 60); + RelationalResult relationalResult = (RelationalResult) res; + return prettyGridPrint(relationalResult, maxRowSize, 60); } - catch (Exception e) + else { - throw new RuntimeException(e); + RealizedRelationalResult relationalResult = (RealizedRelationalResult) res; + return prettyGridPrint(relationalResult, maxRowSize, 60); } } diff --git a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/shared/ResultHelper.java b/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/shared/ResultHelper.java deleted file mode 100644 index e349ef31d48..00000000000 --- a/legend-engine-config/legend-engine-repl/legend-engine-repl-relational/src/main/java/org/finos/legend/engine/repl/relational/shared/ResultHelper.java +++ /dev/null @@ -1,148 +0,0 @@ -// 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.repl.relational.shared; - -import org.eclipse.collections.api.block.function.Function; -import org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction; -import org.eclipse.collections.api.list.MutableList; -import org.eclipse.collections.impl.factory.Lists; - -import java.sql.ResultSet; -import java.util.List; - -public class ResultHelper -{ - public static String prettyGridPrint(ResultSet resultSet, List columnNames, List columnTypes, int maxRowSize, int maxColSize) - { - MutableList columns = Lists.mutable.empty(); - MutableList size = Lists.mutable.empty(); - MutableList> values = Lists.mutable.empty(); - - try - { - int columnCount = columnNames.size(); - - // collect data - for (int i = 0; i < columnCount; i++) - { - columns.add(columnNames.get(i)); - values.add(Lists.mutable.empty()); - } - while (resultSet.next()) - { - for (int i = 1; i <= columnCount; i++) - { - String value = resultSet.getObject(i) == null ? "" : resultSet.getObject(i).toString(); - values.get(i - 1).add(value); - } - } - - // determine the max size for each column - for (int i = 0; i < columnCount; i++) - { - size.add(values.get(i).injectInto(Math.max(columns.get(i).length(), columnTypes.get(i).length()), (IntObjectToIntFunction) (a, b) -> Math.max(b.length(), a))); - } - size = Lists.mutable.withAll(size.collect(s -> Math.min(maxColSize, s + 2))); - - // print the result - StringBuilder builder = new StringBuilder(); - - drawSeparation(builder, columnCount, size); - drawRow(builder, columnCount, size, columns::get, maxColSize); - drawRow(builder, columnCount, size, columnTypes::get, maxColSize); - drawSeparation(builder, columnCount, size); - - int rows = values.get(0).size(); - if (rows <= maxRowSize) - { - for (int k = 0; k < rows; k++) - { - final int fk = k; - drawRow(builder, columnCount, size, i -> values.get(i).get(fk), maxColSize); - } - } - else - { - int topRows = (int) Math.ceil((float) maxRowSize / 2); - int bottomRows = maxRowSize - topRows; - for (int k = 0; k < topRows; k++) - { - final int fk = k; - drawRow(builder, columnCount, size, i -> values.get(i).get(fk), maxColSize); - } - for (int k = 0; k < 3; k++) - { - drawRow(builder, columnCount, size, i -> ".", maxColSize); - } - for (int k = rows - bottomRows; k < rows; k++) - { - final int fk = k; - drawRow(builder, columnCount, size, i -> values.get(i).get(fk), maxColSize); - } - } - - - drawSeparation(builder, columnCount, size); - - // add summary - builder.append(rows + " rows " + (rows > maxRowSize ? ("(" + maxRowSize + " shown) ") : "") + "-- " + columns.size() + " columns"); - return builder.toString(); - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - - private static void drawSeparation(StringBuilder builder, int count, MutableList size) - { - builder.append("+"); - for (int i = 0; i < count; i++) - { - repeat('-', size.get(i), builder); - builder.append("+"); - } - builder.append("\n"); - } - - private static void repeat(char value, int length, StringBuilder builder) - { - for (int k = 0; k < length; k++) - { - builder.append(value); - } - } - - private static void drawRow(StringBuilder builder, int count, MutableList size, Function getter, int maxColSize) - { - builder.append("|"); - for (int i = 0; i < count; i++) - { - String val = printValue(getter.apply(i), maxColSize); - int space = (size.get(i) - val.length()) / 2; - repeat(' ', space, builder); - builder.append(val); - repeat(' ', size.get(i) - val.length() - space, builder); - builder.append("|"); - } - - builder.append("\n"); - } - - private static String printValue(String str, int max) - { - return str.length() >= max ? str.substring(0, max - 3 - 2) + "..." : str; - } -} diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java index f750b4509cc..86d39bca21a 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/PlanExecutor.java @@ -368,7 +368,7 @@ public ExecutionState buildDefaultExecutionState(SingleExecutionPlan executionPl return buildDefaultExecutionState(executionPlan, vars, null); } - private ExecutionState buildDefaultExecutionState(SingleExecutionPlan executionPlan, Map vars, PlanExecutionContext planExecutionContext) + public ExecutionState buildDefaultExecutionState(SingleExecutionPlan executionPlan, Map vars, PlanExecutionContext planExecutionContext) { ExecutionState executionState = new ExecutionState(vars, executionPlan.templateFunctions, this.extraExecutors.collect(StoreExecutor::buildStoreExecutionState), this.isJavaCompilationAllowed, null, this.graphFetchExecutionConfiguration, this.logSQLWithParamValues); diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java index 22617a5098e..0eaec46331f 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/main/java/org/finos/legend/engine/language/pure/grammar/from/domain/DomainParser.java @@ -88,7 +88,7 @@ public Lambda parseLambda(String code, PureGrammarParserContext parserContext, S { ParseTreeWalkerSourceInformation lambdaWalkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(sourceId, lineOffset, columnOffset).withReturnSourceInfo(returnSourceInfo).build(); String prefix = "function go():Any[*]{"; - String fullCode = prefix + code + "}"; + String fullCode = prefix + code + "\n}"; ParseTreeWalkerSourceInformation walkerSourceInformation = new ParseTreeWalkerSourceInformation.Builder(lambdaWalkerSourceInformation) // NOTE: as we prepend the lambda with this prefix, we need to subtract this prefix length from the column offset .withColumnOffset(lambdaWalkerSourceInformation.getColumnOffset() - prefix.length()).build(); diff --git a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java index 027ff3041c3..5d1d254e02e 100644 --- a/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java +++ b/legend-engine-core/legend-engine-core-base/legend-engine-core-language-pure/legend-engine-language-pure-grammar/src/test/java/org/finos/legend/engine/language/pure/grammar/test/roundtrip/TestLambdaRoundtrip.java @@ -435,6 +435,12 @@ public void testRenderingFunctionExpressionWithSinglePrimitiveArgument() testLambda("|%9999-12-30T19:00:00.0000->someDateFn()", "|someDateFn(%9999-12-30T19:00:00.0000)"); } + @Test + public void testLambdaEndingOnComment() + { + testLambda("|1 + 1// comment here", "|1 + 1"); + } + static void testLambda(String text) { testLambda(text, text); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResultGridPrintUtility.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResultGridPrintUtility.java new file mode 100644 index 00000000000..c4e8e8114b7 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/main/java/org/finos/legend/engine/plan/execution/stores/relational/result/RelationalResultGridPrintUtility.java @@ -0,0 +1,195 @@ +// 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.plan.execution.stores.relational.result; + +import java.sql.ResultSet; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; +import org.eclipse.collections.api.block.function.Function; +import org.eclipse.collections.api.block.function.primitive.IntObjectToIntFunction; +import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.factory.Lists; +import org.eclipse.collections.impl.utility.ListIterate; +import org.finos.legend.engine.protocol.pure.v1.model.packageableElement.store.relational.model.result.SQLResultColumn; + +public class RelationalResultGridPrintUtility +{ + public static String prettyGridPrint(ResultSet resultSet, List columnNames, List columnTypes, int maxRowSize, int maxColSize) + { + List> values = Lists.mutable.empty(); + + try + { + + // collect data + for (int i = 0; i < columnNames.size(); i++) + { + values.add(Lists.mutable.empty()); + } + while (resultSet.next()) + { + for (int i = 1; i <= columnNames.size(); i++) + { + String value = resultSet.getObject(i) == null ? "" : resultSet.getObject(i).toString(); + values.get(i - 1).add(value); + } + } + + return prettyGridPrint(columnNames, columnTypes, maxRowSize, maxColSize, values); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + public static String prettyGridPrint(RelationalResult relationalResult, int maxRowSize, int maxColSize) + { + try (ResultSet rs = relationalResult.resultSet) + { + return prettyGridPrint(rs, relationalResult.sqlColumns, ListIterate.collect(relationalResult.getSQLResultColumns(), col -> col.dataType), maxRowSize, maxColSize); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + public static String prettyGridPrint(RealizedRelationalResult resultSet, int maxRowSize, int maxColSize) + { + List> data = resultSet.transformedRows; + List columnNames = resultSet.columns.stream().map(SQLResultColumn::getNonQuotedLabel).collect(Collectors.toList()); + List columnTypes = resultSet.columns.stream().map(x -> x.dataType).collect(Collectors.toList()); + + + List> rows = Lists.mutable.empty(); + + // collect data in columnar fashion + for (int i = 0; i < columnNames.size(); i++) + { + rows.add(Lists.mutable.empty()); + } + for (List row : data) + { + for (int i = 0; i < columnNames.size(); i++) + { + rows.get(i).add(row.get(i)); + } + } + + return prettyGridPrint(columnNames, columnTypes, maxRowSize, maxColSize, rows); + } + + private static String prettyGridPrint(List columnNames, List columnTypes, int maxRowSize, int maxColSize, List> values) + { + int columnCount = columnNames.size(); + + MutableList size = Lists.mutable.empty(); + + // determine the max size for each column + for (int i = 0; i < columnCount; i++) + { + int currMax = Math.max(columnNames.get(i).length(), columnTypes.get(i).length()); + size.add(Lists.adapt(values.get(i)).injectInto(currMax, (IntObjectToIntFunction) (a, b) -> Math.max(Objects.toString(b).length(), a))); + } + size = Lists.mutable.withAll(size.collect(s -> Math.min(maxColSize, s + 2))); + + // print the result + StringBuilder builder = new StringBuilder(); + + drawSeparation(builder, columnCount, size); + drawRow(builder, columnCount, size, columnNames::get, maxColSize); + drawRow(builder, columnCount, size, columnTypes::get, maxColSize); + drawSeparation(builder, columnCount, size); + + int rows = values.get(0).size(); + if (rows <= maxRowSize) + { + for (int k = 0; k < rows; k++) + { + final int fk = k; + drawRow(builder, columnCount, size, i -> Objects.toString(values.get(i).get(fk)), maxColSize); + } + } + else + { + int topRows = (int) Math.ceil((float) maxRowSize / 2); + int bottomRows = maxRowSize - topRows; + for (int k = 0; k < topRows; k++) + { + final int fk = k; + drawRow(builder, columnCount, size, i -> Objects.toString(values.get(i).get(fk)), maxColSize); + } + for (int k = 0; k < 3; k++) + { + drawRow(builder, columnCount, size, i -> ".", maxColSize); + } + for (int k = rows - bottomRows; k < rows; k++) + { + final int fk = k; + drawRow(builder, columnCount, size, i -> Objects.toString(values.get(i).get(fk)), maxColSize); + } + } + + + drawSeparation(builder, columnCount, size); + + // add summary + builder.append(rows).append(" rows ").append(rows > maxRowSize ? ("(" + maxRowSize + " shown) ") : "").append("-- ").append(columnCount).append(" columns"); + return builder.toString(); + } + + private static void drawSeparation(StringBuilder builder, int count, MutableList size) + { + builder.append("+"); + for (int i = 0; i < count; i++) + { + repeat('-', size.get(i), builder); + builder.append("+"); + } + builder.append("\n"); + } + + private static void repeat(char value, int length, StringBuilder builder) + { + for (int k = 0; k < length; k++) + { + builder.append(value); + } + } + + private static void drawRow(StringBuilder builder, int count, MutableList size, Function getter, int maxColSize) + { + builder.append("|"); + for (int i = 0; i < count; i++) + { + String val = printValue(getter.apply(i), maxColSize); + int space = (size.get(i) - val.length()) / 2; + repeat(' ', space, builder); + builder.append(val); + repeat(' ', size.get(i) - val.length() - space, builder); + builder.append("|"); + } + + builder.append("\n"); + } + + private static String printValue(String str, int max) + { + return str.length() > max ? str.substring(0, max - 3) + "..." : str; + } +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/result/TestRelationalResultGridPrintUtility.java b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/result/TestRelationalResultGridPrintUtility.java new file mode 100644 index 00000000000..19e32bd7690 --- /dev/null +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-execution/legend-engine-xt-relationalStore-executionPlan/src/test/java/org/finos/legend/engine/plan/execution/stores/relational/result/TestRelationalResultGridPrintUtility.java @@ -0,0 +1,149 @@ +// 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.plan.execution.stores.relational.result; + +import java.sql.SQLException; +import java.sql.Statement; +import org.eclipse.collections.impl.factory.Maps; +import org.finos.legend.engine.plan.execution.stores.relational.connection.AlloyTestServer; +import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan; +import org.junit.Assert; +import org.junit.Test; + +public class TestRelationalResultGridPrintUtility extends AlloyTestServer +{ + @Test + public void prettyPrintRelationalResult() + { + Assert.assertEquals( + "+----+----+\n" + + "|name|i...|\n" + + "|V...|V...|\n" + + "+----+----+\n" + + "|R...|RBH |\n" + + "| . | . |\n" + + "| . | . |\n" + + "| . | . |\n" + + "|E...|ERP |\n" + + "+----+----+\n" + + "4 rows (2 shown) -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(execute(), 2, 4) + ); + Assert.assertEquals( + "+------+------+\n" + + "| name |ini...|\n" + + "|VAR...|VAR...|\n" + + "+------+------+\n" + + "|Rafael| RBH |\n" + + "| Jose | JJS |\n" + + "| Juan | JHS |\n" + + "|Enr...| ERP |\n" + + "+------+------+\n" + + "4 rows -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(execute(), 10, 6) + ); + } + + @Test + public void prettyPrintRealizeRelationalResult() + { + RelationalResult result = execute(); + RealizedRelationalResult realizeInMemory = (RealizedRelationalResult) result.realizeInMemory(); + + Assert.assertEquals( + "+----+----+\n" + + "|name|i...|\n" + + "|V...|V...|\n" + + "+----+----+\n" + + "|R...|RBH |\n" + + "| . | . |\n" + + "| . | . |\n" + + "| . | . |\n" + + "|E...|ERP |\n" + + "+----+----+\n" + + "4 rows (2 shown) -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(realizeInMemory, 2, 4) + ); + Assert.assertEquals( + "+------+------+\n" + + "| name |ini...|\n" + + "|VAR...|VAR...|\n" + + "+------+------+\n" + + "|Rafael| RBH |\n" + + "| Jose | JJS |\n" + + "| Juan | JHS |\n" + + "|Enr...| ERP |\n" + + "+------+------+\n" + + "4 rows -- 2 columns", + RelationalResultGridPrintUtility.prettyGridPrint(realizeInMemory, 10, 6) + ); + } + + private RelationalResult execute() + { + String func = "function local::func(): Any[*]{ |#>{local::db.person}#->select()->from(test::Runtime) }"; + String db = "###Relational\n" + + "Database local::db" + + "(" + + " Table person" + + "(" + + "name varchar(100)," + + "initials varchar(100)" + + ")" + + ")"; + + String mapping = "###Mapping\n" + + "Mapping test::Map()"; + + String runtime = "###Runtime\n" + + "Runtime test::Runtime\n" + + "{\n" + + " mappings:\n" + + " [\n" + + " ];\n" + + " connections:\n" + + " [\n" + + " local::db:\n" + + " [\n" + + " c1: #{\n" + + " RelationalDatabaseConnection\n" + + " {\n" + + " type: H2;\n" + + " specification: LocalH2 {};\n" + + " auth: DefaultH2;\n" + + " }\n" + + " }#\n" + + " ]\n" + + " ];\n" + + "}\n"; + + SingleExecutionPlan singleExecutionPlan = this.buildPlan(func + "\n" + db + "\n" + runtime + "\n" + mapping); + RelationalResult result = (RelationalResult) planExecutor.execute(singleExecutionPlan, Maps.mutable.empty(), null); + return result; + } + + @Override + protected void insertTestData(Statement s) throws SQLException + { + s.execute("Create Schema default;"); + s.execute("Drop table if exists person;"); + s.execute("Create Table person(name VARCHAR(100) NOT NULL, INITIALS VARCHAR(10));"); + s.execute("insert into person (name, initials) values ('Rafael', 'RBH');"); + s.execute("insert into person (name, initials) values ('Jose', 'JJS');"); + s.execute("insert into person (name, initials) values ('Juan', 'JHS');"); + s.execute("insert into person (name, initials) values ('Enrique', 'ERP');"); + } +}