From 274385d2c5ed114ab7f6f75a0b55bea12f799ced Mon Sep 17 00:00:00 2001 From: pbt-santos <60274019+pbt-santos@users.noreply.github.com> Date: Sun, 15 Oct 2023 11:40:15 -0400 Subject: [PATCH] Make H2 more backward compatible (#2277) * Make H2 more backward compatible Makes dates and timestamps more explicit. Uses transformers to make values conform to model specifications. Wraps checks to boolean strings as a boolean value to avoid varchar to boolean comparisons. Adds assertion function to verify expected values depending on H2 value to preserve compatibility with prior version. * Make more h2 tests compatible --- .../transformer/SetImplTransformers.java | 32 +- .../functions/in/TestPlanExecutionForIn.java | 24 +- .../executionPlanTest.pure | 376 +++++++++++++- .../test/rewrite/NOP/nonAggregationAware.pure | 32 +- .../test/rewrite/NOP/nonGroupBy.pure | 20 +- .../test/rewrite/objectGroupBy.pure | 10 +- .../tests/testCalendarFunctions.pure | 156 ++++-- .../tests/executionPlanTest.pure | 388 ++++++++++++-- .../tests/projection/testAggregation.pure | 7 +- .../tests/projection/testDateFilters.pure | 55 +- .../projection/testGroupWithWindowSubset.pure | 13 +- .../functions/tests/projection/testIn.pure | 7 +- .../tests/testCalculatingDistance.pure | 50 +- .../functions/tests/testFilters.pure | 13 +- .../relational/functions/tests/testMap.pure | 13 +- .../functions/tests/testModelGroupBy.pure | 43 +- .../tests/testGraphFetchMilestoning.pure | 4 +- .../tests/testBiTemporalDateMilestoning.pure | 140 ++++- .../tests/testBusinessDateMilestoning.pure | 477 +++++++++++++++--- .../testBusinessSnapshotMilestoning.pure | 105 +++- .../tests/testGetAllForEachDate.pure | 8 +- ...InheritanceMappingWithMilestonedTypes.pure | 31 +- .../testMilestoningContextPropagation.pure | 213 ++++++-- .../tests/testMilestoningWithDistinct.pure | 8 +- .../tests/testMilestoningWithInclusive.pure | 61 ++- .../milestoning/tests/testOtherwise.pure | 14 +- .../tests/testProcessingDateMilestoning.pure | 19 +- .../milestoning/tests/testTemporalDate.pure | 14 +- .../testTemporalMilestoningPostProcessor.pure | 7 +- .../tests/testTemporalRangeQuery.pure | 62 ++- ...tionWithHybridMilestoningAcrossTables.pure | 19 +- .../m2m2rShowcase.pure | 13 +- .../pureToSQLQuery/tests/testMergeRules.pure | 13 +- .../dbSpecific/h2/h2Extension.pure | 27 +- .../dbSpecific/h2/h2Extension2_1_214.pure | 265 +++++++++- .../relational/tds/tests/testGroupBy.pure | 9 +- .../relational/tds/tests/testTDSExtend.pure | 10 +- .../relational/tds/tests/testTDSProject.pure | 15 +- .../tds/tests/testTDSWindowColumn.pure | 6 +- .../tests/testDataGeneration.pure | 158 +++++- .../advanced/testContractMoneyScenario.pure | 13 +- .../tests/advanced/testForcedMilestoning.pure | 25 +- .../testClassMappingFilterWithInnerJoin.pure | 25 +- .../mapping/embedded/testEmbeddedMapping.pure | 7 +- .../testEmbeddedOtherwiseMapping.pure | 21 +- .../embedded/testInlineEmbeddedMapping.pure | 15 +- .../embedded/testInlineEmbeddedNested.pure | 15 +- .../embedded/testInlineEmbeddedTargetIds.pure | 15 +- .../testSqlFunctionsInMapping.pure | 25 +- .../testUnionWithMultipleChainedJoins.pure | 68 ++- .../relational/tests/query/datePeriods.pure | 214 ++++++-- .../relational/tests/query/testQualifier.pure | 7 +- .../relational/tests/query/testView.pure | 7 +- .../tests/query/testWithFunction.pure | 49 +- .../fromPure/tests/testToSQLString.pure | 19 +- .../tests/testValidationWithMilestoning.pure | 80 ++- 56 files changed, 3010 insertions(+), 532 deletions(-) diff --git a/legend-engine-core/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/transformer/SetImplTransformers.java b/legend-engine-core/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/transformer/SetImplTransformers.java index 5353321f219..56b63e79d73 100644 --- a/legend-engine-core/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/transformer/SetImplTransformers.java +++ b/legend-engine-core/legend-engine-core-executionPlan-execution/legend-engine-executionPlan-execution/src/main/java/org/finos/legend/engine/plan/execution/result/transformer/SetImplTransformers.java @@ -16,6 +16,7 @@ import org.eclipse.collections.api.block.function.Function; import org.eclipse.collections.api.list.MutableList; +import org.eclipse.collections.impl.block.factory.Functions; import org.eclipse.collections.impl.factory.Lists; import org.eclipse.collections.impl.utility.ListIterate; import org.finos.legend.engine.plan.dependencies.domain.date.PureDate; @@ -84,22 +85,25 @@ else if (o instanceof Number) private Function buildTransformer(TransformerInput transformerInput) { - if (transformerInput.type != null && transformerInput.test.valueOf(transformerInput.identifier)) + if (transformerInput.type != null) { - return transformerInput.transformer.valueOf(transformerInput.identifier); - } - else if (transformerInput.type != null && transformerInput.type.equals("Boolean")) - { - return o -> toBoolean(o); - } - else if (transformerInput.type != null && (transformerInput.type.equals("StrictDate") || transformerInput.type.equals("DateTime") || transformerInput.type.equals("Date"))) - { - return o -> o instanceof Date ? DateFunctions.fromDate((Date) o) : o; - } - else - { - return o -> o; + if (transformerInput.test.valueOf(transformerInput.identifier)) + { + return transformerInput.transformer.valueOf(transformerInput.identifier); + } + + switch (transformerInput.type) + { + case "Boolean": + return this::toBoolean; + case "StrictDate": + case "DateTime": + case "Date": + return o -> o instanceof Date ? DateFunctions.fromDate((Date) o) : o; + } } + + return Functions.identity(); } } 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/test/full/functions/in/TestPlanExecutionForIn.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/test/full/functions/in/TestPlanExecutionForIn.java index ff74c07607e..64687f9b2dc 100644 --- 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/test/full/functions/in/TestPlanExecutionForIn.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/test/full/functions/in/TestPlanExecutionForIn.java @@ -19,6 +19,7 @@ import org.eclipse.collections.api.factory.Lists; import org.eclipse.collections.api.factory.Maps; import org.finos.legend.engine.plan.execution.stores.relational.connection.AlloyTestServer; +import org.finos.legend.engine.plan.execution.stores.relational.connection.driver.vendors.h2.H2Manager; import org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan; import org.finos.legend.engine.plan.execution.stores.relational.serialization.RelationalResultToJsonDefaultSerializer; import org.junit.Assert; @@ -33,6 +34,7 @@ public class TestPlanExecutionForIn extends AlloyTestServer { + private static final int LEGACY_H2_VERSION = 1; public static final String LOGICAL_MODEL = "###Pure\n" + "Class test::Person\n" + @@ -276,8 +278,15 @@ public void testInExecutionWithDateTimeList() throws JsonProcessingException Map paramWithMultipleValues = Maps.mutable.with("birthTime", Lists.mutable.with("2020-12-12 20:00:00", "2020-12-13 20:00:00")); String expectedResWithEmptyList = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in (null)\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[]}}"; - String expectedResWithSingleValue = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]}]}}"; - String expectedResWithMultipleValues = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00','2020-12-13 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]},{\"values\":[\"P2\"]},{\"values\":[\"SpecialName'1\"]},{\"values\":[\"SpecialName'2\"]}]}}"; + String expectedResWithSingleValue = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in (TIMESTAMP'2020-12-12 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]}]}}"; + String expectedResWithMultipleValues = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in (TIMESTAMP'2020-12-12 20:00:00',TIMESTAMP'2020-12-13 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]},{\"values\":[\"P2\"]},{\"values\":[\"SpecialName'1\"]},{\"values\":[\"SpecialName'2\"]}]}}"; + + int h2MajorVersion = H2Manager.getMajorVersion(); + if (h2MajorVersion == LEGACY_H2_VERSION) + { + expectedResWithSingleValue = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]}]}}"; + expectedResWithMultipleValues = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00','2020-12-13 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]},{\"values\":[\"P2\"]},{\"values\":[\"SpecialName'1\"]},{\"values\":[\"SpecialName'2\"]}]}}"; + } Assert.assertEquals(expectedResWithEmptyList, RelationalResultToJsonDefaultSerializer.removeComment(executePlan(plan, paramWithEmptyList))); Assert.assertEquals(expectedResWithSingleValue, RelationalResultToJsonDefaultSerializer.removeComment(executePlan(plan, paramWithSingleValue))); @@ -301,8 +310,15 @@ public void testInExecutionWithDateTimeListAndTimeZone() throws JsonProcessingEx Map paramWithMultipleValues = Maps.mutable.with("birthTime", Lists.mutable.with("2020-12-13 03:00:00", "2020-12-14 03:00:00")); String expectedResWithEmptyList = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in (null)\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[]}}"; - String expectedResWithSingleValue = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]}]}}"; - String expectedResWithMultipleValues = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00','2020-12-13 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]},{\"values\":[\"P2\"]},{\"values\":[\"SpecialName'1\"]},{\"values\":[\"SpecialName'2\"]}]}}"; + String expectedResWithSingleValue = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in (TIMESTAMP'2020-12-12 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]}]}}"; + String expectedResWithMultipleValues = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in (TIMESTAMP'2020-12-12 20:00:00',TIMESTAMP'2020-12-13 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]},{\"values\":[\"P2\"]},{\"values\":[\"SpecialName'1\"]},{\"values\":[\"SpecialName'2\"]}]}}"; + + int h2MajorVersion = H2Manager.getMajorVersion(); + if (h2MajorVersion == LEGACY_H2_VERSION) + { + expectedResWithSingleValue = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]}]}}"; + expectedResWithMultipleValues = "{\"builder\":{\"_type\":\"tdsBuilder\",\"columns\":[{\"name\":\"fullName\",\"type\":\"String\",\"relationalType\":\"VARCHAR(100)\"}]},\"activities\":[{\"_type\":\"relational\",\"sql\":\"select \\\"root\\\".fullName as \\\"fullName\\\" from PERSON as \\\"root\\\" where \\\"root\\\".birthTime in ('2020-12-12 20:00:00','2020-12-13 20:00:00')\"}],\"result\":{\"columns\":[\"fullName\"],\"rows\":[{\"values\":[\"P1\"]},{\"values\":[\"P2\"]},{\"values\":[\"SpecialName'1\"]},{\"values\":[\"SpecialName'2\"]}]}}"; + } Assert.assertEquals(expectedResWithEmptyList, RelationalResultToJsonDefaultSerializer.removeComment(executePlan(plan, paramWithEmptyList))); Assert.assertEquals(expectedResWithSingleValue, RelationalResultToJsonDefaultSerializer.removeComment(executePlan(plan, paramWithSingleValue))); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-javaPlatformBinding-pure/src/main/resources/core_relational_java_platform_binding/legendJavaPlatformBinding/executionPlanTest.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-javaPlatformBinding-pure/src/main/resources/core_relational_java_platform_binding/legendJavaPlatformBinding/executionPlanTest.pure index 7fd95d60899..40b2a12800e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-javaPlatformBinding-pure/src/main/resources/core_relational_java_platform_binding/legendJavaPlatformBinding/executionPlanTest.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-javaPlatformBinding-pure/src/main/resources/core_relational_java_platform_binding/legendJavaPlatformBinding/executionPlanTest.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::mapping::modelToModel::test::createInstances::*; import meta::relational::postProcessor::*; import meta::pure::extension::*; @@ -55,7 +56,7 @@ function <> meta::relational::executionPlan::platformBinding::legendJ let res = meta::pure::executionPlan::executionPlan($lambda,simpleRelationalMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - let expected = + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ @@ -85,11 +86,45 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' )\n'+ ')\n'; - assertEquals($expected, $res->planToString(meta::relational::extension::relationalExtensions())); + let expectedNewH2 = + 'Sequence\n'+ + '(\n'+ + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ + ' (\n'+ + ' Allocation\n'+ + ' (\n'+ + ' type = DateTime\n'+ + ' resultSizeRange = 1\n'+ + ' name = x\n'+ + ' value = \n'+ + ' (\n'+ + ' PureExp\n'+ + ' (\n'+ + ' type = DateTime\n'+ + ' resultSizeRange = 1\n'+ + ' expression = now()\n'+ + ' )\n'+ + ' )\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ + ' resultColumns = [("firstName", VARCHAR(200))]\n' + + ' sql = select "root".FIRSTNAME as "firstName" from personTable as "root" where TIMESTAMP\'${x}\' > dateadd(DAY, -1, current_timestamp())\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + + assertEqualsH2Compatible( + $expectedLegacyH2, + $expectedNewH2, + $res->planToString(meta::relational::extension::relationalExtensions()) + ); let withJava = $res->generatePlatformCode(meta::pure::executionPlan::platformBinding::legendJava::legendJavaPlatformBindingId(), ^meta::pure::executionPlan::platformBinding::legendJava::LegendJavaPlatformBindingConfig(), relationalExtensionsWithLegendJavaPlatformBinding()); - let expectedJava = + let expectedJavaLegacyH2 = 'Sequence\n' + '(\n' + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + @@ -123,7 +158,45 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' )\n' + ')\n'; - assertEquals($expectedJava, $withJava->planToString(meta::relational::extension::relationalExtensions())); + let expectedJavaNewH2 = + 'Sequence\n' + + '(\n' + + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + + ' (\n' + + ' Allocation\n' + + ' (\n' + + ' type = DateTime\n' + + ' resultSizeRange = 1\n'+ + ' name = x\n' + + ' value = \n' + + ' (\n' + + ' PureExp\n' + + ' (\n' + + ' type = DateTime\n' + + ' resultSizeRange = 1\n'+ + ' expression = now()\n' + + ' implementation\n' + + ' (\n' + + ' calls = org.finos.legend.engine.plan.dependencies.store.platform.PredefinedExpressions.now\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Relational\n' + + ' (\n' + + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + + ' resultColumns = [("firstName", VARCHAR(200))]\n' + + ' sql = select "root".FIRSTNAME as "firstName" from personTable as "root" where TIMESTAMP\'${x}\' > dateadd(DAY, -1, current_timestamp())\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ')\n'; + + assertEqualsH2Compatible( + $expectedJavaLegacyH2, + $expectedJavaNewH2, + $withJava->planToString(meta::relational::extension::relationalExtensions()) + ); } function <> meta::relational::executionPlan::platformBinding::legendJava::tests::withNestedSequenceNode() : Boolean[1] @@ -268,7 +341,7 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ->filter(p|$x>now()->adjust(-1, DurationUnit.DAYS)) ->project([col({p:meta::relational::tests::model::simple::Person[1]|$p.firstName}, 'firstName')]);}; let res = meta::pure::executionPlan::executionPlan($lambda,simpleRelationalMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - let expected = + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ @@ -298,11 +371,45 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' )\n'+ ')\n'; - assertEquals($expected, $res->planToString(meta::relational::extension::relationalExtensions())); + let expectedNewH2 = + 'Sequence\n'+ + '(\n'+ + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ + ' (\n'+ + ' Allocation\n'+ + ' (\n'+ + ' type = Date\n'+ + ' resultSizeRange = 1\n'+ + ' name = x\n'+ + ' value = \n'+ + ' (\n'+ + ' PureExp\n'+ + ' (\n'+ + ' type = Date\n'+ + ' resultSizeRange = 1\n'+ + ' expression = now() -> adjust(1, Enumeration DurationUnit -> extractEnumValue(\'DAYS\'))\n'+ + ' )\n'+ + ' )\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ + ' resultColumns = [("firstName", VARCHAR(200))]\n' + + ' sql = select "root".FIRSTNAME as "firstName" from personTable as "root" where TIMESTAMP\'${x}\' > dateadd(DAY, -1, current_timestamp())\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + + assertEqualsH2Compatible( + $expectedLegacyH2, + $expectedNewH2, + $res->planToString(meta::relational::extension::relationalExtensions()) + ); let withJava = $res->generatePlatformCode(meta::pure::executionPlan::platformBinding::legendJava::legendJavaPlatformBindingId(), ^meta::pure::executionPlan::platformBinding::legendJava::LegendJavaPlatformBindingConfig(), relationalExtensionsWithLegendJavaPlatformBinding()); - let expectedJava = + let expectedJavaLegacyH2 = 'Sequence\n' + '(\n' + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + @@ -364,7 +471,74 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' 0023 }\n' + ' 0024 }\n' + ')\n'; - assertEquals($expectedJava, $withJava->planToString(true, meta::relational::extension::relationalExtensions())); + + let expectedJavaNewH2 = + 'Sequence\n' + + '(\n' + + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + + ' (\n' + + ' Allocation\n' + + ' (\n' + + ' type = Date\n' + + ' resultSizeRange = 1\n'+ + ' name = x\n' + + ' value = \n' + + ' (\n' + + ' PureExp\n' + + ' (\n' + + ' type = Date\n' + + ' resultSizeRange = 1\n'+ + ' expression = now() -> adjust(1, Enumeration DurationUnit -> extractEnumValue(\'DAYS\'))\n' + + ' implementation\n' + + ' (\n' + + ' calls = _pure.plan.root.n1.n1.Execute.execute\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Relational\n' + + ' (\n' + + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + + ' resultColumns = [("firstName", VARCHAR(200))]\n' + + ' sql = select "root".FIRSTNAME as "firstName" from personTable as "root" where TIMESTAMP\'${x}\' > dateadd(DAY, -1, current_timestamp())\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ')\n' + + 'globalImplementationSupport\n' + + '(\n' + + ' classes =\n' + + ' _pure.plan.root.n1.n1.Execute\n' + + ' 0001 package _pure.plan.root.n1.n1;\n' + + ' 0002 \n' + + ' 0003 import java.util.Date;\n' + + ' 0004 import org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\n' + + ' 0005 import org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\n' + + ' 0006 import org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\n' + + ' 0007 import org.finos.legend.engine.plan.dependencies.util.Library;\n' + + ' 0008 \n' + + ' 0009 public class Execute\n' + + ' 0010 {\n' + + ' 0011 public static PureDate execute(IExecutionNodeContext context)\n' + + ' 0012 {\n' + + ' 0013 try\n' + + ' 0014 {\n' + + ' 0015 return Library.adjustDate(PureDate.fromDate(new Date()),\n' + + ' 0016 1L,\n' + + ' 0017 DurationUnit.getEnumFromPureName("DAYS"));\n' + + ' 0018 }\n' + + ' 0019 catch (Exception e)\n' + + ' 0020 {\n' + + ' 0021 throw new RuntimeException("Failed in node: root.n1.n1", e);\n' + + ' 0022 }\n' + + ' 0023 }\n' + + ' 0024 }\n' + + ')\n'; + assertEqualsH2Compatible( + $expectedJavaLegacyH2, + $expectedJavaNewH2, + $withJava->planToString(true, meta::relational::extension::relationalExtensions()) + ); } function <> meta::relational::executionPlan::platformBinding::legendJava::tests::letVariableFunctionAdjustDateLiteral() : Boolean[1] @@ -375,7 +549,7 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ->project([col({p:meta::relational::tests::model::simple::Person[1]|$p.firstName}, 'firstName')]);}; let res = meta::pure::executionPlan::executionPlan($lambda,simpleRelationalMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - let expected = + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ @@ -404,12 +578,45 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' )\n'+ ' )\n'+ ')\n'; + let expectedNewH2 = + 'Sequence\n'+ + '(\n'+ + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ + ' (\n'+ + ' Allocation\n'+ + ' (\n'+ + ' type = Date\n'+ + ' resultSizeRange = 1\n'+ + ' name = x\n'+ + ' value = \n'+ + ' (\n'+ + ' PureExp\n'+ + ' (\n'+ + ' type = Date\n'+ + ' resultSizeRange = 1\n'+ + ' expression = 2005-10-10 -> adjust(1, Enumeration DurationUnit -> extractEnumValue(\'DAYS\'))\n'+ + ' )\n'+ + ' )\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n'+ + ' resultColumns = [("firstName", VARCHAR(200))]\n' + + ' sql = select "root".FIRSTNAME as "firstName" from personTable as "root" where TIMESTAMP\'${x}\' > dateadd(DAY, -1, DATE\'2005-10-10\')\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; - assertEquals($expected, $res->planToString(meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + $expectedLegacyH2, + $expectedNewH2, + $res->planToString(meta::relational::extension::relationalExtensions()) + ); let withJava = $res->generatePlatformCode(meta::pure::executionPlan::platformBinding::legendJava::legendJavaPlatformBindingId(), ^meta::pure::executionPlan::platformBinding::legendJava::LegendJavaPlatformBindingConfig(), relationalExtensionsWithLegendJavaPlatformBinding()); - let expectedJava = + let expectedJavaLegacyH2 = 'Sequence\n' + '(\n' + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + @@ -470,7 +677,73 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' 0022 }\n' + ' 0023 }\n' + ')\n'; - assertEquals($expectedJava, $withJava->planToString(true, meta::relational::extension::relationalExtensions())); + + let expectedJavaNewH2 = + 'Sequence\n' + + '(\n' + + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + + ' (\n' + + ' Allocation\n' + + ' (\n' + + ' type = Date\n' + + ' resultSizeRange = 1\n'+ + ' name = x\n' + + ' value = \n' + + ' (\n' + + ' PureExp\n' + + ' (\n' + + ' type = Date\n' + + ' resultSizeRange = 1\n'+ + ' expression = 2005-10-10 -> adjust(1, Enumeration DurationUnit -> extractEnumValue(\'DAYS\'))\n' + + ' implementation\n' + + ' (\n' + + ' calls = _pure.plan.root.n1.n1.Execute.execute\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Relational\n' + + ' (\n' + + ' type = TDS[(firstName, String, VARCHAR(200), "")]\n' + + ' resultColumns = [("firstName", VARCHAR(200))]\n' + + ' sql = select "root".FIRSTNAME as "firstName" from personTable as "root" where TIMESTAMP\'${x}\' > dateadd(DAY, -1, DATE\'2005-10-10\')\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ')\n' + + 'globalImplementationSupport\n' + + '(\n' + + ' classes =\n' + + ' _pure.plan.root.n1.n1.Execute\n' + + ' 0001 package _pure.plan.root.n1.n1;\n' + + ' 0002 \n' + + ' 0003 import org.finos.legend.engine.plan.dependencies.domain.date.DurationUnit;\n' + + ' 0004 import org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\n' + + ' 0005 import org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\n' + + ' 0006 import org.finos.legend.engine.plan.dependencies.util.Library;\n' + + ' 0007 \n' + + ' 0008 public class Execute\n' + + ' 0009 {\n' + + ' 0010 public static PureDate execute(IExecutionNodeContext context)\n' + + ' 0011 {\n' + + ' 0012 try\n' + + ' 0013 {\n' + + ' 0014 return Library.adjustDate(PureDate.parsePureDate("2005-10-10"),\n' + + ' 0015 1L,\n' + + ' 0016 DurationUnit.getEnumFromPureName("DAYS"));\n' + + ' 0017 }\n' + + ' 0018 catch (Exception e)\n' + + ' 0019 {\n' + + ' 0020 throw new RuntimeException("Failed in node: root.n1.n1", e);\n' + + ' 0021 }\n' + + ' 0022 }\n' + + ' 0023 }\n' + + ')\n'; + assertEqualsH2Compatible( + $expectedJavaLegacyH2, + $expectedJavaNewH2, + $withJava->planToString(true, meta::relational::extension::relationalExtensions()) + ); } function <> meta::relational::executionPlan::platformBinding::legendJava::tests::javaGenerationLetVariablePureExpression() : Boolean[1] @@ -483,7 +756,76 @@ function <> meta::relational::executionPlan::platformBinding::legendJ let res = meta::pure::executionPlan::executionPlan($lambda,meta::relational::tests::milestoning::milestoningmap, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let withJava = $res->generatePlatformCode(meta::pure::executionPlan::platformBinding::legendJava::legendJavaPlatformBindingId(), ^meta::pure::executionPlan::platformBinding::legendJava::LegendJavaPlatformBindingConfig(), relationalExtensionsWithLegendJavaPlatformBinding()); - let expectedJava = + let expectedJavaLegacyH2 = + 'Sequence\n'+ + '(\n' + + ' type = TDS[(classificationType, String, VARCHAR(200), \"\")]\n' + + ' (\n' + + ' FunctionParametersValidationNode\n' + + ' (\n' + + ' functionParameters = [businessDate:StrictDate[0..1], CLSFtype:String[1]]\n' + + ' )\n' + + ' Allocation\n' + + ' (\n' + + ' type = Date\n' + + ' resultSizeRange = 1\n'+ + ' name = asOf\n' + + ' value = \n' + + ' (\n' + + ' PureExp\n' + + ' (\n' + + ' type = Date\n' + + ' resultSizeRange = 1\n'+ + ' requires = [businessDate(StrictDate[0..1])]\n' + + ' expression = $businessDate -> isNotEmpty() -> if([Routed Func: | $businessDate -> toOne();], [Routed Func: | now();])\n' + + ' implementation\n' + + ' (\n' + + ' calls = _pure.plan.root.n2.n1.Execute.execute\n'+ + ' )\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Relational\n' + + ' (\n' + + ' type = TDS[(classificationType, String, VARCHAR(200), \"\")]\n' + + ' resultColumns = [(\"classificationType\", VARCHAR(200))]\n' + + ' sql = select distinct "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'${asOf}\' and "productclassificationtable_0".thru_z > \'${asOf}\') where "productclassificationtable_0".type = \'${CLSFtype?replace("\'", "\'\'")}\' and "root".from_z <= \'${asOf}\' and "root".thru_z > \'${asOf}\'\n' + + ' connection = TestDatabaseConnection(type = \"H2\")\n' + + ' )\n' + + ' )\n' + + ')\n' + + 'globalImplementationSupport\n' + + '(\n' + + ' classes =\n' + + ' _pure.plan.root.n2.n1.Execute\n' + + ' 0001 package _pure.plan.root.n2.n1;\n' + + ' 0002 \n' + + ' 0003 import java.util.Date;\n' + + ' 0004 import java.util.function.Supplier;\n' + + ' 0005 import org.finos.legend.engine.plan.dependencies.domain.date.PureDate;\n' + + ' 0006 import org.finos.legend.engine.plan.dependencies.store.shared.IExecutionNodeContext;\n' + + ' 0007 import org.finos.legend.engine.plan.dependencies.util.Library;\n' + + ' 0008 \n' + + ' 0009 public class Execute\n' + + ' 0010 {\n' + + ' 0011 public static PureDate execute(IExecutionNodeContext context)\n' + + ' 0012 {\n' + + ' 0013 try\n' + + ' 0014 {\n' + + ' 0015 PureDate businessDate = context.getResult(\"businessDate\", PureDate.class);\n' + + ' 0016 return businessDate != null ? ((Supplier) () -> Library.toOne(businessDate))\n' + + ' 0017 .get()\n' + + ' 0018 : ((Supplier) () -> PureDate.fromDate(new Date()))\n' + + ' 0019 .get();\n' + + ' 0020 }\n' + + ' 0021 catch (Exception e)\n' + + ' 0022 {\n' + + ' 0023 throw new RuntimeException(\"Failed in node: root.n2.n1\", e);\n' + + ' 0024 }\n' + + ' 0025 }\n' + + ' 0026 }\n' + + ')\n'; + let expectedJavaNewH2 = 'Sequence\n'+ '(\n' + ' type = TDS[(classificationType, String, VARCHAR(200), \"\")]\n' + @@ -516,7 +858,7 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' (\n' + ' type = TDS[(classificationType, String, VARCHAR(200), \"\")]\n' + ' resultColumns = [(\"classificationType\", VARCHAR(200))]\n' + - ' sql = select distinct \"productclassificationtable_0\".type as \"classificationType\" from ProductTable as \"root\" left outer join ProductClassificationTable as \"productclassificationtable_0\" on (\"root\".type = \"productclassificationtable_0\".type and \"productclassificationtable_0\".from_z <= \'${asOf}\' and \"productclassificationtable_0\".thru_z > \'${asOf}\') where \"productclassificationtable_0\".type = \'${CLSFtype?replace("\'", "\'\'")}\' and \"root\".from_z <= \'${asOf}\' and \"root\".thru_z > \'${asOf}\'\n' + + ' sql = select distinct "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= TIMESTAMP\'${asOf}\' and "productclassificationtable_0".thru_z > TIMESTAMP\'${asOf}\') where "productclassificationtable_0".type = \'${CLSFtype?replace("\'", "\'\'")}\' and "root".from_z <= TIMESTAMP\'${asOf}\' and "root".thru_z > TIMESTAMP\'${asOf}\'\n' + ' connection = TestDatabaseConnection(type = \"H2\")\n' + ' )\n' + ' )\n' + @@ -552,7 +894,11 @@ function <> meta::relational::executionPlan::platformBinding::legendJ ' 0025 }\n' + ' 0026 }\n' + ')\n'; - assertEquals($expectedJava, $withJava->planToString(true, meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + $expectedJavaLegacyH2, + $expectedJavaNewH2, + $withJava->planToString(true, meta::relational::extension::relationalExtensions()) + ); } function <> meta::relational::executionPlan::platformBinding::legendJava::tests::javaGenerationWithMatchInMapping() : Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonAggregationAware.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonAggregationAware.pure index 242f9291fac..af5304e524d 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonAggregationAware.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonAggregationAware.pure @@ -1,3 +1,5 @@ +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::pure::router::printer::*; import meta::pure::extension::*; @@ -16,7 +18,11 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); assertEmpty($result.activities->filter(s|$s->instanceOf(meta::pure::mapping::aggregationAware::AggregationAwareActivity))); - assertSameSQL('select "root".id as "pk_0", "root".sales_date as "pk_1", "root".is_cancelled_flag as "pk_2", "root".product_id as "pk_3", "root".revenue as "pk_4", "root".emp_id as "pk_5", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "isCancelled", "root".discount as "discount" from base_view.SalesTable as "root"', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".sales_date as "pk_1", "root".is_cancelled_flag as "pk_2", "root".product_id as "pk_3", "root".revenue as "pk_4", "root".emp_id as "pk_5", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "isCancelled", "root".discount as "discount" from base_view.SalesTable as "root"', + 'select "root".id as "pk_0", "root".sales_date as "pk_1", "root".is_cancelled_flag as "pk_2", "root".product_id as "pk_3", "root".revenue as "pk_4", "root".emp_id as "pk_5", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "isCancelled", "root".discount as "discount" from base_view.SalesTable as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::aggregationAware::testRewriteAsNOP::nonAggregationAware::testRewriteFilter():Boolean[1] @@ -64,7 +70,11 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); assertEmpty($result.activities->filter(s|$s->instanceOf(meta::pure::mapping::aggregationAware::AggregationAwareActivity))); - assertSameSQL('select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', $result); + assertEqualsH2Compatible( + 'select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + 'select "product_0".prod_id as "Product ID", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::aggregationAware::testRewriteAsNOP::nonAggregationAware::testRewriteProjectColMulti():Boolean[1] @@ -76,7 +86,11 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); assertEmpty($result.activities->filter(s|$s->instanceOf(meta::pure::mapping::aggregationAware::AggregationAwareActivity))); - assertSameSQL('select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', $result); + assertEqualsH2Compatible( + 'select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + 'select "product_0".prod_id as "Product ID", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::aggregationAware::testRewriteAsNOP::nonAggregationAware::testRewriteTDSOperation():Boolean[1] @@ -92,7 +106,11 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); assertEmpty($result.activities->filter(s|$s->instanceOf(meta::pure::mapping::aggregationAware::AggregationAwareActivity))); - assertSameSQL('select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled", ("product_0".prod_id + 2) as "Product ID Added 2" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', $result); + assertEqualsH2Compatible( + 'select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled", ("product_0".prod_id + 2) as "Product ID Added 2" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + 'select "product_0".prod_id as "Product ID", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "Is Cancelled", ("product_0".prod_id + 2) as "Product ID Added 2" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::aggregationAware::testRewriteAsNOP::nonAggregationAware::testRewriteTDSGroupBy():Boolean[1] @@ -108,5 +126,9 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); assertEmpty($result.activities->filter(s|$s->instanceOf(meta::pure::mapping::aggregationAware::AggregationAwareActivity))); - assertSameSQL('select case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled", max("product_0".prod_id) as "Max Product ID" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) group by "Is Cancelled"', $result); + assertEqualsH2Compatible( + 'select case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled", max("product_0".prod_id) as "Max Product ID" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) group by "Is Cancelled"', + 'select cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "Is Cancelled", max("product_0".prod_id) as "Max Product ID" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) group by "Is Cancelled"', + $result->sqlRemoveFormatting() + ); } \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonGroupBy.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonGroupBy.pure index f49e8cba919..a35b4fd6d97 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonGroupBy.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/NOP/nonGroupBy.pure @@ -1,3 +1,5 @@ +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::pure::router::printer::*; import meta::pure::extension::*; import meta::relational::extension::*; @@ -17,7 +19,11 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); assertEquals(' | [SCT_Main Class Wholesales].all();', $result.activities->filter(s|$s->instanceOf(meta::pure::mapping::aggregationAware::AggregationAwareActivity))->at(0)->cast(@meta::pure::mapping::aggregationAware::AggregationAwareActivity).rewrittenQuery); - assertSameSQL('select "root".id as "pk_0", "root".sales_date as "pk_1", "root".is_cancelled_flag as "pk_2", "root".product_id as "pk_3", "root".revenue as "pk_4", "root".emp_id as "pk_5", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "isCancelled", "root".discount as "discount" from base_view.SalesTable as "root"', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".sales_date as "pk_1", "root".is_cancelled_flag as "pk_2", "root".product_id as "pk_3", "root".revenue as "pk_4", "root".emp_id as "pk_5", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "isCancelled", "root".discount as "discount" from base_view.SalesTable as "root"', + 'select "root".id as "pk_0", "root".sales_date as "pk_1", "root".is_cancelled_flag as "pk_2", "root".product_id as "pk_3", "root".revenue as "pk_4", "root".emp_id as "pk_5", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "isCancelled", "root".discount as "discount" from base_view.SalesTable as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::aggregationAware::testRewriteAsNOP::nonGroupBy::testRewriteFilter():Boolean[1] @@ -64,7 +70,11 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); assertEquals(' | [SCT_Main Class Wholesales].all() -> project([x:meta::relational::tests::aggregationAware::domain::Wholesales[1] | $x.product -> map(v_automap:meta::relational::tests::aggregationAware::domain::Product[1] | $v_automap.productId;);, x:meta::relational::tests::aggregationAware::domain::Wholesales[1] | $x.isCancelled;], [\'Product ID\', \'Is Cancelled\']);', $result.activities->filter(s|$s->instanceOf(meta::pure::mapping::aggregationAware::AggregationAwareActivity))->at(0)->cast(@meta::pure::mapping::aggregationAware::AggregationAwareActivity).rewrittenQuery); - assertSameSQL('select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', $result); + assertEqualsH2Compatible( + 'select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + 'select "product_0".prod_id as "Product ID", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::aggregationAware::testRewriteAsNOP::nonGroupBy::testRewriteProjectColMulti():Boolean[1] @@ -75,7 +85,11 @@ function <> meta::relational::tests::aggregationAware::testRewriteAsN let result = execute($query, $mapping, $runtime, relationalExtensions()); - assertSameSQL('select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', $result); + assertEqualsH2Compatible( + 'select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + 'select "product_0".prod_id as "Product ID", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "Is Cancelled" from base_view.SalesTable as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::aggregationAware::testRewriteAsNOP::nonGroupBy::testRewriteTDSOperation():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/objectGroupBy.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/objectGroupBy.pure index 664f1406b06..0ea9663460e 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/objectGroupBy.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/aggregationAware/test/rewrite/objectGroupBy.pure @@ -1,3 +1,5 @@ +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::pure::router::printer::*; import meta::pure::extension::*; @@ -108,7 +110,7 @@ function <> meta::relational::tests::aggregationAware::testRewrite::o let result = execute($query, $mapping, $runtime, relationalExtensions()); - assertSameSQL('select "salestable_month_0"."Product ID" as "Product ID", "salestable_month_0"."Total Price 1" as "Total Price 1", "salestable_month_0"."Total Price 2" as "Total Price 2" from (select "salestable_month_1"."Product ID" as "Product ID", "salestable_month_1"."Is Cancelled" as "Is Cancelled", "salestable_month_1"."Total Price 1" as "Total Price 1", "salestable_month_3"."Total Price 2" as "Total Price 2" from (select "product_0".prod_id as "Product ID", case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as "Is Cancelled", sum("root".revenue) as "Total Price 1" from user_view_agg.SalesTable_Month as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) where (case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end = \'N\' and "product_0".prod_id = 2238011724) group by "Product ID","Is Cancelled") as "salestable_month_1" inner join (select "product_0".prod_id as "Product ID", sum("root".revenue) as "Total Price 2" from user_view_agg.SalesTable_Month as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) where "product_0".prod_id = 2238011724 group by "Product ID") as "salestable_month_3" on ("salestable_month_1"."Product ID" = "salestable_month_3"."Product ID")) as "salestable_month_0" where abs(("salestable_month_0"."Total Price 1" - "salestable_month_0"."Total Price 2")) > 1', $result); + assertSameSQL('select "salestable_month_0"."Product ID" as "Product ID", "salestable_month_0"."Total Price 1" as "Total Price 1", "salestable_month_0"."Total Price 2" as "Total Price 2" from (select "salestable_month_1"."Product ID" as "Product ID", "salestable_month_1"."Is Cancelled" as "Is Cancelled", "salestable_month_1"."Total Price 1" as "Total Price 1", "salestable_month_3"."Total Price 2" as "Total Price 2" from (select "product_0".prod_id as "Product ID", cast(case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end as boolean) as "Is Cancelled", sum("root".revenue) as "Total Price 1" from user_view_agg.SalesTable_Month as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) where (case when "root".is_cancelled_flag = \'Y\' then \'true\' else \'false\' end = \'N\' and "product_0".prod_id = 2238011724) group by "Product ID","Is Cancelled") as "salestable_month_1" inner join (select "product_0".prod_id as "Product ID", sum("root".revenue) as "Total Price 2" from user_view_agg.SalesTable_Month as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) where "product_0".prod_id = 2238011724 group by "Product ID") as "salestable_month_3" on ("salestable_month_1"."Product ID" = "salestable_month_3"."Product ID")) as "salestable_month_0" where abs(("salestable_month_0"."Total Price 1" - "salestable_month_0"."Total Price 2")) > 1', $result); } function <> meta::relational::tests::aggregationAware::testRewrite::objectGroupBy::testRewriteSwitchToProductMonthTable():Boolean[1] @@ -238,5 +240,9 @@ function <> meta::relational::tests::aggregationAware::testRewrite::o let runtime = runtime(); let result = execute($query, $mapping, $runtime, relationalExtensions()); - assertSameSQL('select "product_0".prod_id as "Product ID", concat("productdescription_0".prod_description, \':\', \'abc\') as "Product Description", sum("root".revenue) as "Revenue/Total Price Sum" from user_view_multi_agg.SalesTable_Product_Month as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) left outer join (select "productdescription_1".prod_description as prod_description, "productdescription_1".prod_id as prod_id from base_view.ProductDescription as "productdescription_1" where "productdescription_1".from_z <= \'2021-01-01\' and "productdescription_1".thru_z > \'2021-01-01\') as "productdescription_0" on ("product_0".prod_id = "productdescription_0".prod_id) group by "Product ID","Product Description"', $result); + assertEqualsH2Compatible( + 'select "product_0".prod_id as "Product ID", concat("productdescription_0".prod_description, \':\', \'abc\') as "Product Description", sum("root".revenue) as "Revenue/Total Price Sum" from user_view_multi_agg.SalesTable_Product_Month as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) left outer join (select "productdescription_1".prod_description as prod_description, "productdescription_1".prod_id as prod_id from base_view.ProductDescription as "productdescription_1" where "productdescription_1".from_z <= \'2021-01-01\' and "productdescription_1".thru_z > \'2021-01-01\') as "productdescription_0" on ("product_0".prod_id = "productdescription_0".prod_id) group by "Product ID","Product Description"', + 'select "product_0".prod_id as "Product ID", concat("productdescription_0".prod_description, \':\', \'abc\') as "Product Description", sum("root".revenue) as "Revenue/Total Price Sum" from user_view_multi_agg.SalesTable_Product_Month as "root" left outer join base_view.Product as "product_0" on ("root".product_id = "product_0".prod_id) left outer join (select "productdescription_1".prod_description as prod_description, "productdescription_1".prod_id as prod_id from base_view.ProductDescription as "productdescription_1" where "productdescription_1".from_z <= DATE\'2021-01-01\' and "productdescription_1".thru_z > DATE\'2021-01-01\') as "productdescription_0" on ("product_0".prod_id = "productdescription_0".prod_id) group by "Product ID","Product Description"', + $result->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/tests/testCalendarFunctions.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/tests/testCalendarFunctions.pure index 987833b37ff..f061f522b48 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/tests/testCalendarFunctions.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/calendarAggregation/tests/testCalendarFunctions.pure @@ -33,6 +33,8 @@ Mapping meta::relational::tests::functions::pureToSqlQuery::calendarAggregations ) ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::pure::functions::date::calendar::*; import meta::relational::extension::*; import meta::relational::functions::asserts::*; @@ -785,7 +787,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | annualized($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','annualized']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear then ((1.0 * "root".fteFactor) / ((1.0 * "ny_calendar_1".fiscalDay) / "ny_calendar_1".numberOfFiscalDaysInYear)) else null end) as "annualized" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear then ((1.0 * "root".fteFactor) / ((1.0 * "ny_calendar_1".fiscalDay) / "ny_calendar_1".numberOfFiscalDaysInYear)) else null end) as "annualized" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,annualized,Campus,9.812850678733032,Lateral,9.267692307692307,'], toCSV($result.values)->replace('\n', ',')); } @@ -798,7 +800,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | cme($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','cme']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentMonthNum = "ny_calendar_1".currentMonthNum then ((1.0 * "root".fteFactor) / ((1.0 * "ny_calendar_1".fiscalDay) / "ny_calendar_1".numberOfFiscalDaysInMonth)) else null end) as "cme" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentMonthNum = "ny_calendar_1".currentMonthNum then ((1.0 * "root".fteFactor) / ((1.0 * "ny_calendar_1".fiscalDay) / "ny_calendar_1".numberOfFiscalDaysInMonth)) else null end) as "cme" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,cme,Campus,0.5131221719457013,Lateral,0.5644343891402714,'], toCSV($result.values)->replace('\n', ',')); } @@ -811,7 +813,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | cw($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','cw']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - case when "ny_calendar_1".shortNameWeekDay in (\'Sat\', \'Sun\') then 1 else 0 end) then "root".fteFactor else null end) as "cw" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - case when "ny_calendar_1".shortNameWeekDay in (\'Sat\', \'Sun\') then 1 else 0 end) then "root".fteFactor else null end) as "cw" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - case when "ny_calendar_1".shortNameWeekDay in (\'Sat\', \'Sun\') then 1 else 0 end) then "root".fteFactor else null end) as "cw" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,cw,Campus,1.65,Lateral,2.2,'], toCSV($result.values)->replace('\n', ',')); } @@ -824,7 +830,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | cw_fm($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','cw_fm']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = "ny_calendar_1".fiscalWeekOffset then "root".fteFactor else null end) as "cw_fm" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = "ny_calendar_1".fiscalWeekOffset then "root".fteFactor else null end) as "cw_fm" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = "ny_calendar_1".fiscalWeekOffset then "root".fteFactor else null end) as "cw_fm" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,cw_fm,Campus,1.65,Lateral,2.2,'], toCSV($result.values)->replace('\n', ',')); } @@ -837,7 +847,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | CYMinus2($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','CYMinus2']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = ("ny_calendar_1".previousFiscalYear - 1) then "root".fteFactor else null end) as "CYMinus2" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = ("ny_calendar_1".previousFiscalYear - 1) then "root".fteFactor else null end) as "CYMinus2" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = ("ny_calendar_1".previousFiscalYear - 1) then "root".fteFactor else null end) as "CYMinus2" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,CYMinus2,Campus,0.17,Lateral,0.16,'], toCSV($result.values)->replace('\n', ',')); } @@ -850,7 +864,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | CYMinus3($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','CYMinus3']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = ("ny_calendar_1".previousFiscalYear - 2) then "root".fteFactor else null end) as "CYMinus3" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = ("ny_calendar_1".previousFiscalYear - 2) then "root".fteFactor else null end) as "CYMinus3" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = ("ny_calendar_1".previousFiscalYear - 2) then "root".fteFactor else null end) as "CYMinus3" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,CYMinus3,Campus,0.15,Lateral,0.14,'], toCSV($result.values)->replace('\n', ',')); } @@ -863,7 +881,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | mtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','mtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentMonthNum = "ny_calendar_1".currentMonthNum and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "mtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentMonthNum = "ny_calendar_1".currentMonthNum and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "mtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentMonthNum = "ny_calendar_1".currentMonthNum and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "mtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,mtd,Campus,3.0,Lateral,3.5,'], toCSV($result.values)->replace('\n', ',')); } @@ -876,7 +898,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | p12wa($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','p12wa']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior12WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then ((1.0 * "root".fteFactor) / 12) else null end) as "p12wa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior12WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then ((1.0 * "root".fteFactor) / 12) else null end) as "p12wa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,p12wa,Campus,0.383333333333,Lateral,0.391666666667,'], toCSV($result.values)->replace('\n', ',')); } @@ -889,7 +911,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | p12wtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','p12wtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior12WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then "root".fteFactor else null end) as "p12wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior12WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then "root".fteFactor else null end) as "p12wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,p12wtd,Campus,4.6,Lateral,4.7,'], toCSV($result.values)->replace('\n', ',')); } @@ -902,7 +924,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | p4wa($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','p4wa']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior4WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then ((1.0 * "root".fteFactor) / 4) else null end) as "p4wa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior4WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then ((1.0 * "root".fteFactor) / 4) else null end) as "p4wa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,p4wa,Campus,0.8575,Lateral,0.98,'], toCSV($result.values)->replace('\n', ',')); } @@ -915,7 +937,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | p4wtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','p4wtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior4WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then "root".fteFactor else null end) as "p4wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior4WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then "root".fteFactor else null end) as "p4wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,p4wtd,Campus,3.43,Lateral,3.92,'], toCSV($result.values)->replace('\n', ',')); } @@ -928,7 +950,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | p52wtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','p52wtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior52WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then "root".fteFactor else null end) as "p52wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior52WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then "root".fteFactor else null end) as "p52wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,p52wtd,Campus,6.84,Lateral,6.98,'], toCSV($result.values)->replace('\n', ',')); } @@ -941,7 +963,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | p52wa($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','p52wa']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior52WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then ((1.0 * "root".fteFactor) / 52) else null end) as "p52wa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date >= "ny_calendar_1".prior52WeekDate and "ny_calendar_0".date <= case when "ny_calendar_1".date = "ny_calendar_1".adjustedDate then "ny_calendar_1".adjustedDate else "ny_calendar_1".previousBusinessDay end then ((1.0 * "root".fteFactor) / 52) else null end) as "p52wa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,p52wa,Campus,0.131538461538,Lateral,0.134230769231,'], toCSV($result.values)->replace('\n', ',')); } @@ -954,7 +976,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | p12mtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','p12mtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date > dateadd(YEAR, -1, "ny_calendar_1".date) and "ny_calendar_0".date <= "ny_calendar_1".date then "root".fteFactor else null end) as "p12mtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date > dateadd(YEAR, -1, "ny_calendar_1".date) and "ny_calendar_0".date <= "ny_calendar_1".date then "root".fteFactor else null end) as "p12mtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,p12mtd,Campus,6.84,Lateral,7.24,'], toCSV($result.values)->replace('\n', ',')); } @@ -968,7 +990,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pma($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pma']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_1".currentMonthNum = 1 and "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then ((1.0 * "root".fteFactor) / 12) else case when "ny_calendar_1".currentMonthNum > 1 and "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentMonthNum <= "ny_calendar_1".previousFiscalMonth then ((1.0 * "root".fteFactor) / "ny_calendar_1".previousFiscalMonth) else null end end) as "pma" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_1".currentMonthNum = 1 and "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then ((1.0 * "root".fteFactor) / 12) else case when "ny_calendar_1".currentMonthNum > 1 and "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentMonthNum <= "ny_calendar_1".previousFiscalMonth then ((1.0 * "root".fteFactor) / "ny_calendar_1".previousFiscalMonth) else null end end) as "pma" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,pma,Campus,0.259,Lateral,0.222,'], toCSV($result.values)->replace('\n', ',')); } @@ -981,7 +1003,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pmtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pmtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = case when "ny_calendar_1".currentMonthNum = 1 then "ny_calendar_1".previousFiscalYear else "ny_calendar_1".currentYear end and "ny_calendar_0".currentMonthNum = "ny_calendar_1".previousFiscalMonth and "ny_calendar_0".fiscalDayOfMonth <= "ny_calendar_1".fiscalDayOfMonth then "root".fteFactor else null end) as "pmtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = case when "ny_calendar_1".currentMonthNum = 1 then "ny_calendar_1".previousFiscalYear else "ny_calendar_1".currentYear end and "ny_calendar_0".currentMonthNum = "ny_calendar_1".previousFiscalMonth and "ny_calendar_0".fiscalDayOfMonth <= "ny_calendar_1".fiscalDayOfMonth then "root".fteFactor else null end) as "pmtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = case when "ny_calendar_1".currentMonthNum = 1 then "ny_calendar_1".previousFiscalYear else "ny_calendar_1".currentYear end and "ny_calendar_0".currentMonthNum = "ny_calendar_1".previousFiscalMonth and "ny_calendar_0".fiscalDayOfMonth <= "ny_calendar_1".fiscalDayOfMonth then "root".fteFactor else null end) as "pmtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,pmtd,Campus,0.39,Lateral,0.4,'], toCSV($result.values)->replace('\n', ',')); } @@ -994,7 +1020,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pqtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pqtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = case when "ny_calendar_1".currentQuarterNum = 1 then "ny_calendar_1".previousFiscalYear else "ny_calendar_1".currentYear end and "ny_calendar_0".currentQuarterNum = "ny_calendar_1".previousFiscalQuarter and "ny_calendar_0".fiscalDayOfQuarter <= "ny_calendar_1".fiscalDayOfQuarter then "root".fteFactor else null end) as "pqtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = case when "ny_calendar_1".currentQuarterNum = 1 then "ny_calendar_1".previousFiscalYear else "ny_calendar_1".currentYear end and "ny_calendar_0".currentQuarterNum = "ny_calendar_1".previousFiscalQuarter and "ny_calendar_0".fiscalDayOfQuarter <= "ny_calendar_1".fiscalDayOfQuarter then "root".fteFactor else null end) as "pqtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = case when "ny_calendar_1".currentQuarterNum = 1 then "ny_calendar_1".previousFiscalYear else "ny_calendar_1".currentYear end and "ny_calendar_0".currentQuarterNum = "ny_calendar_1".previousFiscalQuarter and "ny_calendar_0".fiscalDayOfQuarter <= "ny_calendar_1".fiscalDayOfQuarter then "root".fteFactor else null end) as "pqtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,pqtd,Campus,0.33,Lateral,0.34,'], toCSV($result.values)->replace('\n', ',')); } @@ -1007,7 +1037,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | priorDay($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','priorDay']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date = "ny_calendar_1".previousBusinessDay then "root".fteFactor else null end) as "priorDay" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".date = "ny_calendar_1".previousBusinessDay then "root".fteFactor else null end) as "priorDay" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".date = "ny_calendar_1".previousBusinessDay then "root".fteFactor else null end) as "priorDay" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,priorDay,Campus,0.55,Lateral,,'], toCSV($result.values)->replace('\n', ',')); } @@ -1020,7 +1054,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | priorYear($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','priorYear']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then "root".fteFactor else null end) as "priorYear" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then "root".fteFactor else null end) as "priorYear" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,priorYear,Campus,2.84,Lateral,3.06,'], toCSV($result.values)->replace('\n', ',')); } @@ -1033,7 +1067,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pw($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pw']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - case when "ny_calendar_1".shortNameWeekDay in (\'Sat\', \'Sun\') then 2 else 1 end) then "root".fteFactor else null end) as "pw" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - case when "ny_calendar_1".shortNameWeekDay in (\'Sat\', \'Sun\') then 2 else 1 end) then "root".fteFactor else null end) as "pw" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - case when "ny_calendar_1".shortNameWeekDay in (\'Sat\', \'Sun\') then 2 else 1 end) then "root".fteFactor else null end) as "pw" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,pw,Campus,1.47,Lateral,1.44,'], toCSV($result.values)->replace('\n', ',')); } @@ -1046,7 +1084,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pw_fm($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pw_fm']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - 1) then "root".fteFactor else null end) as "pw_fm" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - 1) then "root".fteFactor else null end) as "pw_fm" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - 1) then "root".fteFactor else null end) as "pw_fm" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,pw_fm,Campus,1.47,Lateral,1.44,'], toCSV($result.values)->replace('\n', ',')); } @@ -1059,7 +1101,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pwa($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pwa']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_1".currentWeek <= 5 and "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then (((1.0 * "root".fteFactor) / "ny_calendar_1".numberOfFiscalDaysInYear) * 5) else case when "ny_calendar_1".currentWeek > 5 and "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= ("ny_calendar_1".fiscalDay - "ny_calendar_1".fiscalDayOfWeek) then (((1.0 * "root".fteFactor) / ("ny_calendar_1".fiscalDay - "ny_calendar_1".fiscalDayOfWeek)) * 5) else null end end) as "pwa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_1".currentWeek <= 5 and "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then (((1.0 * "root".fteFactor) / "ny_calendar_1".numberOfFiscalDaysInYear) * 5) else case when "ny_calendar_1".currentWeek > 5 and "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= ("ny_calendar_1".fiscalDay - "ny_calendar_1".fiscalDayOfWeek) then (((1.0 * "root".fteFactor) / ("ny_calendar_1".fiscalDay - "ny_calendar_1".fiscalDayOfWeek)) * 5) else null end end) as "pwa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,pwa,Campus,0.103440366973,Lateral,0.0940366972485,'], toCSV($result.values)->replace('\n', ',')); } @@ -1072,7 +1114,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pwtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pwtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - 1) and "ny_calendar_0".fiscalDayOfWeek <= "ny_calendar_1".fiscalDayOfWeek then "root".fteFactor else null end) as "pwtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - 1) and "ny_calendar_0".fiscalDayOfWeek <= "ny_calendar_1".fiscalDayOfWeek then "root".fteFactor else null end) as "pwtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".fiscalWeekOffset = ("ny_calendar_1".fiscalWeekOffset - 1) and "ny_calendar_0".fiscalDayOfWeek <= "ny_calendar_1".fiscalDayOfWeek then "root".fteFactor else null end) as "pwtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,pwtd,Campus,0.96,Lateral,0.94,'], toCSV($result.values)->replace('\n', ',')); } @@ -1085,7 +1131,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pymtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pymtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".currentMonthNum = "ny_calendar_1".currentMonthNum and "ny_calendar_0".fiscalDayOfMonth <= "ny_calendar_1".fiscalDayOfMonth then "root".fteFactor else null end) as "pymtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".currentMonthNum = "ny_calendar_1".currentMonthNum and "ny_calendar_0".fiscalDayOfMonth <= "ny_calendar_1".fiscalDayOfMonth then "root".fteFactor else null end) as "pymtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,pymtd,Campus,0.69,Lateral,0.46,'], toCSV($result.values)->replace('\n', ',')); } @@ -1098,7 +1144,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pyqtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pyqtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".currentQuarterNum = "ny_calendar_1".currentQuarterNum and "ny_calendar_0".fiscalDayOfQuarter <= "ny_calendar_1".fiscalDayOfQuarter then "root".fteFactor else null end) as "pyqtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".currentQuarterNum = "ny_calendar_1".currentQuarterNum and "ny_calendar_0".fiscalDayOfQuarter <= "ny_calendar_1".fiscalDayOfQuarter then "root".fteFactor else null end) as "pyqtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,pyqtd,Campus,1.4,Lateral,1.36,'], toCSV($result.values)->replace('\n', ',')); } @@ -1111,7 +1157,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pytd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pytd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "pytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "pytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,pytd,Campus,1.59,Lateral,1.54,'], toCSV($result.values)->replace('\n', ',')); } @@ -1124,7 +1170,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pywa($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pywa']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_1".currentWeek <= 5 and "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then (((1.0 * "root".fteFactor) / "ny_calendar_1".numberOfFiscalDaysInYear) * 5) else null end) as "pywa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_1".currentWeek <= 5 and "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then (((1.0 * "root".fteFactor) / "ny_calendar_1".numberOfFiscalDaysInYear) * 5) else null end) as "pywa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_1".currentWeek <= 5 and "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear then (((1.0 * "root".fteFactor) / "ny_calendar_1".numberOfFiscalDaysInYear) * 5) else null end) as "pywa" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,pywa,Campus,,Lateral,,'], toCSV($result.values)->replace('\n', ',')); } @@ -1137,7 +1187,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | pywtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','pywtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".currentWeek = "ny_calendar_1".currentWeek and "ny_calendar_0".fiscalDayOfWeek <= "ny_calendar_1".fiscalDayOfWeek then "root".fteFactor else null end) as "pywtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".currentWeek = "ny_calendar_1".currentWeek and "ny_calendar_0".fiscalDayOfWeek <= "ny_calendar_1".fiscalDayOfWeek then "root".fteFactor else null end) as "pywtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".previousFiscalYear and "ny_calendar_0".currentWeek = "ny_calendar_1".currentWeek and "ny_calendar_0".fiscalDayOfWeek <= "ny_calendar_1".fiscalDayOfWeek then "root".fteFactor else null end) as "pywtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,pywtd,Campus,0.25,Lateral,0.5,'], toCSV($result.values)->replace('\n', ',')); } @@ -1150,7 +1204,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | qtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','qtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentQuarterNum = "ny_calendar_1".currentQuarterNum and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "qtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentQuarterNum = "ny_calendar_1".currentQuarterNum and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "qtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,qtd,Campus,4.23,Lateral,4.32,'], toCSV($result.values)->replace('\n', ',')); } @@ -1163,7 +1217,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | reportEndDay($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','reportEndDay']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".date = "ny_calendar_1".date then "root".fteFactor else null end) as "reportEndDay" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".date = "ny_calendar_1".date then "root".fteFactor else null end) as "reportEndDay" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".date = "ny_calendar_1".date then "root".fteFactor else null end) as "reportEndDay" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,reportEndDay,Campus,,Lateral,0.56,'], toCSV($result.values)->replace('\n', ',')); } @@ -1176,7 +1234,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | wtd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','wtd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentWeek = "ny_calendar_1".currentWeek and "ny_calendar_0".dayOfCalendarYear <= "ny_calendar_1".dayOfCalendarYear then "root".fteFactor else null end) as "wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentWeek = "ny_calendar_1".currentWeek and "ny_calendar_0".dayOfCalendarYear <= "ny_calendar_1".dayOfCalendarYear then "root".fteFactor else null end) as "wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".currentWeek = "ny_calendar_1".currentWeek and "ny_calendar_0".dayOfCalendarYear <= "ny_calendar_1".dayOfCalendarYear then "root".fteFactor else null end) as "wtd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); assertEquals(['hireType,wtd,Campus,1.08,Lateral,1.62,'], toCSV($result.values)->replace('\n', ',')); } @@ -1189,7 +1251,7 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | ytd($p.hireDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','ytd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); + assertSameSQL('select "root".hireType as "hireType", sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) group by "hireType"', $result); assertEquals(['hireType,ytd,Campus,5.59,Lateral,5.72,'], toCSV($result.values)->replace('\n', ',')); } @@ -1550,7 +1612,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | ytd($p.hireDate, 'London', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['hireType','ytd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "london_calendar_0".currentYear = "london_calendar_1".currentYear and "london_calendar_0".fiscalDay <= "london_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.London_Calendar as "london_calendar_0" on ("root".hireDate = "london_calendar_0".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_1" on (\'2022-11-16\' = "london_calendar_1".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "london_calendar_0".currentYear = "london_calendar_1".currentYear and "london_calendar_0".fiscalDay <= "london_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.London_Calendar as "london_calendar_0" on ("root".hireDate = "london_calendar_0".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_1" on (\'2022-11-16\' = "london_calendar_1".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "london_calendar_0".currentYear = "london_calendar_1".currentYear and "london_calendar_0".fiscalDay <= "london_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.London_Calendar as "london_calendar_0" on ("root".hireDate = "london_calendar_0".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_1" on (DATE\'2022-11-16\' = "london_calendar_1".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::functions::pureToSqlQuery::calendarAggregations::testDifferentEndDates():Boolean[1] @@ -1563,7 +1629,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen agg(p | ytd($p.hireDate, 'London', %2022-11-17, $p.fteFactor), y | $y->sum()) ], ['hireType','ytd16', 'ytd17']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select "root".hireType as "hireType", sum(case when "london_calendar_1".currentYear = "london_calendar_0".currentYear and "london_calendar_1".fiscalDay <= "london_calendar_0".fiscalDay then "root".fteFactor else null end) as "ytd16", sum(case when "london_calendar_1".currentYear = "london_calendar_2".currentYear and "london_calendar_1".fiscalDay <= "london_calendar_2".fiscalDay then "root".fteFactor else null end) as "ytd17" from EmployeeTable as "root" left outer join LegendCalendarSchema.London_Calendar as "london_calendar_0" on (\'2022-11-16\' = "london_calendar_0".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_1" on ("root".hireDate = "london_calendar_1".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_2" on (\'2022-11-17\' = "london_calendar_2".date) group by "hireType"', $result); + assertEqualsH2Compatible( + 'select "root".hireType as "hireType", sum(case when "london_calendar_1".currentYear = "london_calendar_0".currentYear and "london_calendar_1".fiscalDay <= "london_calendar_0".fiscalDay then "root".fteFactor else null end) as "ytd16", sum(case when "london_calendar_1".currentYear = "london_calendar_2".currentYear and "london_calendar_1".fiscalDay <= "london_calendar_2".fiscalDay then "root".fteFactor else null end) as "ytd17" from EmployeeTable as "root" left outer join LegendCalendarSchema.London_Calendar as "london_calendar_0" on (\'2022-11-16\' = "london_calendar_0".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_1" on ("root".hireDate = "london_calendar_1".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_2" on (\'2022-11-17\' = "london_calendar_2".date) group by "hireType"', + 'select "root".hireType as "hireType", sum(case when "london_calendar_1".currentYear = "london_calendar_0".currentYear and "london_calendar_1".fiscalDay <= "london_calendar_0".fiscalDay then "root".fteFactor else null end) as "ytd16", sum(case when "london_calendar_1".currentYear = "london_calendar_2".currentYear and "london_calendar_1".fiscalDay <= "london_calendar_2".fiscalDay then "root".fteFactor else null end) as "ytd17" from EmployeeTable as "root" left outer join LegendCalendarSchema.London_Calendar as "london_calendar_0" on (DATE\'2022-11-16\' = "london_calendar_0".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_1" on ("root".hireDate = "london_calendar_1".date) left outer join LegendCalendarSchema.London_Calendar as "london_calendar_2" on (DATE\'2022-11-17\' = "london_calendar_2".date) group by "hireType"', + $result->sqlRemoveFormatting() + ); } @@ -1576,7 +1646,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | ytd($p.employeeDetails.birthDate, 'NY', %2022-11-16, $p.fteFactor), y | $y->sum()) ], ['ytd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join EmployeeDetailsTable as "employeedetailstable_0" on ("root".id = "employeedetailstable_0".id) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("employeedetailstable_0".birthDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date)', $result); + assertEqualsH2Compatible( + 'select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join EmployeeDetailsTable as "employeedetailstable_0" on ("root".id = "employeedetailstable_0".id) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("employeedetailstable_0".birthDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date)', + 'select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "root".fteFactor else null end) as "ytd" from EmployeeTable as "root" left outer join EmployeeDetailsTable as "employeedetailstable_0" on ("root".id = "employeedetailstable_0".id) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("employeedetailstable_0".birthDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date)', + $result->sqlRemoveFormatting() + ); assertEquals(['ytd,0.13,'], toCSV($result.values)->replace('\n', ',')); } @@ -1589,7 +1663,11 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | ytd($p.hireDate, 'NY', %2022-11-16, $p.employeeDetails.yearsOfExperience), y | $y->sum()) ], ['ytd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "employeedetailstable_0".yearsOfExperience else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) left outer join EmployeeDetailsTable as "employeedetailstable_0" on ("root".id = "employeedetailstable_0".id)', $result); + assertEqualsH2Compatible( + 'select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "employeedetailstable_0".yearsOfExperience else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date) left outer join EmployeeDetailsTable as "employeedetailstable_0" on ("root".id = "employeedetailstable_0".id)', + 'select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then "employeedetailstable_0".yearsOfExperience else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date) left outer join EmployeeDetailsTable as "employeedetailstable_0" on ("root".id = "employeedetailstable_0".id)', + $result->sqlRemoveFormatting() + ); assertEquals(['ytd,10.0,'], toCSV($result.values)->replace('\n', ',')); } @@ -1614,5 +1692,9 @@ function <> meta::relational::tests::functions::pureToSqlQuery::calen [ agg(p | ytd($p.hireDate, 'NY', %2022-11-16, $p.fteFactorDyna()), y | $y->sum()) ], ['ytd']) ,EmployeeMapping, testRuntime(), relationalExtensions(), noDebug()); - assertSameSQL('select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then ((1.0 * "root".fteFactor) / 2) else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date)', $result); + assertEqualsH2Compatible( + 'select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then ((1.0 * "root".fteFactor) / 2) else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (\'2022-11-16\' = "ny_calendar_1".date)', + 'select sum(case when "ny_calendar_0".currentYear = "ny_calendar_1".currentYear and "ny_calendar_0".fiscalDay <= "ny_calendar_1".fiscalDay then ((1.0 * "root".fteFactor) / 2) else null end) as "ytd" from EmployeeTable as "root" left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_0" on ("root".hireDate = "ny_calendar_0".date) left outer join LegendCalendarSchema.NY_Calendar as "ny_calendar_1" on (DATE\'2022-11-16\' = "ny_calendar_1".date)', + $result->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/executionPlan/tests/executionPlanTest.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/executionPlan/tests/executionPlanTest.pure index 2348187db3d..1c90f7d05bc 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/executionPlan/tests/executionPlanTest.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/executionPlan/tests/executionPlanTest.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::alloy::connections::alloy::authentication::*; import meta::pure::alloy::connections::alloy::specification::*; import meta::pure::alloy::connections::*; @@ -176,7 +177,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt { let generatedPlan = executionPlan({optionalPnl: Float[0..1]|Order.all()->filter(x|$x.pnl==$optionalPnl)}, simpleRelationalMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ ' resultSizeRange = *\n'+ @@ -195,7 +196,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalPnl:Float[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")]\n'+ + ' sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where (${optionalVarPlaceHolderOperationSelector(optionalPnl![], \'"orderpnlview_0".pnl = ${varPlaceHolderToString(optionalPnl![] "CAST(" " AS FLOAT)" {} "null")}\', \'"orderpnlview_0".pnl is null\')})\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); assertSameElements(templateFunctionsList(),$generatedPlan.processingTemplateFunctions); } @@ -230,7 +250,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt { let generatedPlan = executionPlan({optionalCensusDate: Date[0..1]|Location.all()->filter(t|$t.censusdate==$optionalCensusDate)}, simpleRelationalMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Location | simpleRelationalMappingInc.meta_relational_tests_model_simple_Location)]\n'+ ' resultSizeRange = *\n'+ @@ -249,7 +269,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Location | simpleRelationalMappingInc.meta_relational_tests_model_simple_Location)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalCensusDate:Date[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Location | simpleRelationalMappingInc.meta_relational_tests_model_simple_Location)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("place", VARCHAR(200)), ("censusdate", DATE)]\n'+ + ' sql = select "root".ID as "pk_0", "root".PLACE as "place", "root".date as "censusdate" from locationTable as "root" where (${optionalVarPlaceHolderOperationSelector(optionalCensusDate![], \'"root".date = ${varPlaceHolderToString(optionalCensusDate![] "TIMESTAMP\\\'" "\\\'" {} "null")}\', \'"root".date is null\')})\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); assertSameElements(templateFunctionsList(),$generatedPlan.processingTemplateFunctions); } @@ -257,7 +296,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt { let generatedPlan = executionPlan({optionalSettlementDateTime:DateTime[0..1]|Order.all()->filter(o|$o.settlementDateTime == $optionalSettlementDateTime)}, simpleRelationalMapping, ^Runtime(connections=^DatabaseConnection(element = relationalDB, type=DatabaseType.H2)), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ ' resultSizeRange = *\n'+ @@ -276,7 +315,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalSettlementDateTime:DateTime[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")]\n'+ + ' sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where (${optionalVarPlaceHolderOperationSelector(optionalSettlementDateTime![], \'"root".settlementDateTime = ${varPlaceHolderToString(optionalSettlementDateTime![] "TIMESTAMP\\\'" "\\\'" {} "null")}\', \'"root".settlementDateTime is null\')})\n'+ + ' connection = DatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); assertSameElements(templateFunctionsList(),$generatedPlan.processingTemplateFunctions); } @@ -284,7 +342,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt { let generatedPlan = executionPlan({optionalSettlementDateTime:DateTime[0..1]|Order.all()->filter(o|$o.settlementDateTime == $optionalSettlementDateTime)}, simpleRelationalMapping, ^Runtime(connections=^DatabaseConnection(element = relationalDB, type=DatabaseType.H2, timeZone='US/Arizona')), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ ' resultSizeRange = *\n'+ @@ -303,7 +361,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithOpt ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalSettlementDateTime:DateTime[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")]\n'+ + ' sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where (${optionalVarPlaceHolderOperationSelector(optionalSettlementDateTime![], \'"root".settlementDateTime = ${varPlaceHolderToString(GMTtoTZ( "[US/Arizona]" optionalSettlementDateTime![]) "TIMESTAMP\\\'" "\\\'" {} "null")}\', \'"root".settlementDateTime is null\')})\n'+ + ' connection = DatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); } function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwoOptionalParametersString():Boolean[1] @@ -364,7 +441,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo { let generatedPlan = executionPlan({optionalFloatLeft: Float[0..1], optionalFloatRight :Float[0..1]|Address.all()->filter(a|$optionalFloatLeft==$optionalFloatRight)}, simpleRelationalMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ ' resultSizeRange = *\n'+ @@ -383,7 +460,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalFloatLeft:Float[0..1], optionalFloatRight:Float[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("name", VARCHAR(200)), ("street", VARCHAR(100)), ("type", INT), ("comments", VARCHAR(100))]\n'+ + ' sql = select "root".ID as "pk_0", "root".NAME as "name", "root".STREET as "street", "root".TYPE as "type", "root".COMMENTS as "comments" from addressTable as "root" where (${optionalVarPlaceHolderOperationSelector(optionalFloatLeft![], optionalVarPlaceHolderOperationSelector(optionalFloatRight![], \'${varPlaceHolderToString(optionalFloatLeft![] "CAST(" " AS FLOAT)" {} "null")} = ${varPlaceHolderToString(optionalFloatRight![] "CAST(" " AS FLOAT)" {} "null")}\', \'1 = 0\'), optionalVarPlaceHolderOperationSelector(optionalFloatRight![], \'1 = 0\', \'1 = 1\'))})\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); assertSameElements(templateFunctionsList(),$generatedPlan.processingTemplateFunctions); } @@ -391,7 +487,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo { let generatedPlan = executionPlan({optionalDateLeft: Date[0..1], optionalDateRight :Date[0..1]|Address.all()->filter(a|$optionalDateLeft==$optionalDateRight)}, simpleRelationalMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ ' resultSizeRange = *\n'+ @@ -410,7 +506,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalDateLeft:Date[0..1], optionalDateRight:Date[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("name", VARCHAR(200)), ("street", VARCHAR(100)), ("type", INT), ("comments", VARCHAR(100))]\n'+ + ' sql = select "root".ID as "pk_0", "root".NAME as "name", "root".STREET as "street", "root".TYPE as "type", "root".COMMENTS as "comments" from addressTable as "root" where (${optionalVarPlaceHolderOperationSelector(optionalDateLeft![], optionalVarPlaceHolderOperationSelector(optionalDateRight![], \'${varPlaceHolderToString(optionalDateLeft![] "TIMESTAMP\\\'" "\\\'" {} "null")} = ${varPlaceHolderToString(optionalDateRight![] "TIMESTAMP\\\'" "\\\'" {} "null")}\', \'1 = 0\'), optionalVarPlaceHolderOperationSelector(optionalDateRight![], \'1 = 0\', \'1 = 1\'))})\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); assertSameElements(templateFunctionsList(),$generatedPlan.processingTemplateFunctions); } @@ -418,7 +533,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo { let generatedPlan = executionPlan({optionalLeft: DateTime[0..1], optionalRight :DateTime[0..1]|Address.all()->filter(a|$optionalLeft==$optionalRight)}, simpleRelationalMapping, ^Runtime(connections=^DatabaseConnection(element = relationalDB, type=DatabaseType.H2)), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ ' resultSizeRange = *\n'+ @@ -437,7 +552,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalLeft:DateTime[0..1], optionalRight:DateTime[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("name", VARCHAR(200)), ("street", VARCHAR(100)), ("type", INT), ("comments", VARCHAR(100))]\n'+ + ' sql = select "root".ID as "pk_0", "root".NAME as "name", "root".STREET as "street", "root".TYPE as "type", "root".COMMENTS as "comments" from addressTable as "root" where (${optionalVarPlaceHolderOperationSelector(optionalLeft![], optionalVarPlaceHolderOperationSelector(optionalRight![], \'${varPlaceHolderToString(optionalLeft![] "TIMESTAMP\\\'" "\\\'" {} "null")} = ${varPlaceHolderToString(optionalRight![] "TIMESTAMP\\\'" "\\\'" {} "null")}\', \'1 = 0\'), optionalVarPlaceHolderOperationSelector(optionalRight![], \'1 = 0\', \'1 = 1\'))})\n'+ + ' connection = DatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); assertSameElements(templateFunctionsList(),$generatedPlan.processingTemplateFunctions); } @@ -445,7 +579,7 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo { let generatedPlan = executionPlan({optionalLeft: DateTime[0..1], optionalRight :DateTime[0..1]|Address.all()->filter(a|$optionalLeft==$optionalRight)}, simpleRelationalMapping, ^Runtime(connections=^DatabaseConnection(element = relationalDB, type=DatabaseType.H2, timeZone='US/Arizona')), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expected = 'Sequence\n'+ + let expectedLegacyH2 = 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ ' resultSizeRange = *\n'+ @@ -464,7 +598,26 @@ function <> meta::pure::executionPlan::tests::testFilterEqualsWithTwo ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expected, $result); + let expectedNewH2 = 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalLeft:DateTime[0..1], optionalRight:DateTime[0..1]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::model::simple::Address | simpleRelationalMappingInc.meta_relational_tests_model_simple_Address)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("name", VARCHAR(200)), ("street", VARCHAR(100)), ("type", INT), ("comments", VARCHAR(100))]\n'+ + ' sql = select "root".ID as "pk_0", "root".NAME as "name", "root".STREET as "street", "root".TYPE as "type", "root".COMMENTS as "comments" from addressTable as "root" where (${optionalVarPlaceHolderOperationSelector(optionalLeft![], optionalVarPlaceHolderOperationSelector(optionalRight![], \'${varPlaceHolderToString(GMTtoTZ( "[US/Arizona]" optionalLeft![]) "TIMESTAMP\\\'" "\\\'" {} "null")} = ${varPlaceHolderToString(GMTtoTZ( "[US/Arizona]" optionalRight![]) "TIMESTAMP\\\'" "\\\'" {} "null")}\', \'1 = 0\'), optionalVarPlaceHolderOperationSelector(optionalRight![], \'1 = 0\', \'1 = 1\'))})\n'+ + ' connection = DatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); } function <> meta::pure::executionPlan::tests::testGreaterThanLessThanEqualsWithOptionalParameter_H2():Boolean[1] @@ -766,9 +919,10 @@ function <> meta::pure::executionPlan::tests::datetime::testPlanForDa { let planWithString = executionPlanForQueryWithDateTimeConstantForDatabaseConnectionTimeZone(%2019-4-8T18:00:00, []); let planAsString = $planWithString.second; - let expected = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'2019-04-08 18:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; - assertEquals($expected, $planAsString); - assert($planAsString->indexOf('settlementDateTime = \'2019-04-08 18:00:00\'') != -1); + let expectedLegacyH2 = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'2019-04-08 18:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; + let expectedNewH2 = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = TIMESTAMP\'2019-04-08 18:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $planAsString); + assert($planAsString->indexOf('settlementDateTime = \'2019-04-08 18:00:00\'') != -1 || $planAsString->indexOf('settlementDateTime = TIMESTAMP\'2019-04-08 18:00:00\'') != -1); assertSameElements(templateFunctionsList(),$planWithString.first.processingTemplateFunctions); } @@ -776,9 +930,10 @@ function <> meta::pure::executionPlan::tests::datetime::testPlanForDa { let planWithString = executionPlanForQueryWithDateTimeConstantForDatabaseConnectionTimeZone(%2019-4-8T18:00:00, 'GMT'); let planAsString = $planWithString.second; - let expected = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'2019-04-08 18:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; - assertEquals($expected, $planAsString); - assert($planAsString->indexOf('settlementDateTime = \'2019-04-08 18:00:00\'') != -1); + let expectedLegacyH2 = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'2019-04-08 18:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; + let expectedNewH2 = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = TIMESTAMP\'2019-04-08 18:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $planAsString); + assert($planAsString->indexOf('settlementDateTime = \'2019-04-08 18:00:00\'') != -1 || $planAsString->indexOf('settlementDateTime = TIMESTAMP\'2019-04-08 18:00:00\'') != -1); assertSameElements(templateFunctionsList(),$planWithString.first.processingTemplateFunctions); } @@ -786,9 +941,10 @@ function <> meta::pure::executionPlan::tests::datetime::testPlanForDa { let planWithString = executionPlanForQueryWithDateTimeConstantForDatabaseConnectionTimeZone(%2019-4-8T18:00:00, 'EST'); let planAsString = $planWithString.second; - let expected = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'2019-04-08 13:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; - assertEquals($expected, $planAsString); - assert($planAsString->indexOf('settlementDateTime = \'2019-04-08 13:00:00\'') != -1); + let expectedLegacyH2 = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'2019-04-08 13:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; + let expectedNewH2 = 'Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = TIMESTAMP\'2019-04-08 13:00:00\' connection = TestDatabaseConnection(type = "H2") ) '; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $planAsString); + assert($planAsString->indexOf('settlementDateTime = \'2019-04-08 13:00:00\'') != -1 || $planAsString->indexOf('settlementDateTime = TIMESTAMP\'2019-04-08 13:00:00\'') != -1); assertSameElements(['<#function GMTtoTZ tz paramDate><#if paramDate?is_enumerable && !paramDate?has_content><#return paramDate><#else><#return (tz+" "+paramDate)?date.@alloyDate><#function renderCollectionWithTz collection timeZone separator prefix suffix defaultValue><#assign result = [] /><#list collection as c><#assign result = [prefix + (timeZone+" "+c)?date.@alloyDate + suffix] + result><#return result?reverse?join(separator, defaultValue)>', '<#function collectionSize collection> <#return collection?size?c> ', '<#function equalEnumOperationSelector enumVal inDyna equalDyna><#assign enumList = enumVal?split(",")><#if enumList?size = 1><#return equalDyna><#else><#return inDyna>', @@ -802,9 +958,10 @@ function <> meta::pure::executionPlan::tests::datetime::testPlanForDa { let planWithString = executionPlanForQueryWithDateTimeVariableForDatabaseConnectionTimeZone([]); let planAsString = $planWithString.second; - let expected = 'Sequence ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * ( FunctionParametersValidationNode ( functionParameters = [dt:DateTime[1]] ) Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'${dt}\' connection = TestDatabaseConnection(type = "H2") ) ) ) '; - assertEquals($expected, $planAsString); - assert($planAsString->indexOf('settlementDateTime = \'${dt}\'') != -1); + let expectedLegacyH2 = 'Sequence ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * ( FunctionParametersValidationNode ( functionParameters = [dt:DateTime[1]] ) Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'${dt}\' connection = TestDatabaseConnection(type = "H2") ) ) ) '; + let expectedNewH2 = 'Sequence ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * ( FunctionParametersValidationNode ( functionParameters = [dt:DateTime[1]] ) Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = TIMESTAMP\'${dt}\' connection = TestDatabaseConnection(type = "H2") ) ) ) '; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $planAsString); + assert($planAsString->indexOf('settlementDateTime = \'${dt}\'') != -1|| $planAsString->indexOf('settlementDateTime = TIMESTAMP\'${dt}\'') != -1); assertSameElements(templateFunctionsList(),$planWithString.first.processingTemplateFunctions); } @@ -812,9 +969,10 @@ function <> meta::pure::executionPlan::tests::datetime::testPlanForDa { let planWithString = executionPlanForQueryWithDateTimeVariableForDatabaseConnectionTimeZone('US/Arizona'); let planAsString = $planWithString.second; - let expected = 'Sequence ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * ( FunctionParametersValidationNode ( functionParameters = [dt:DateTime[1]] ) Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'${GMTtoTZ( "[US/Arizona]" dt)}\' connection = TestDatabaseConnection(type = "H2") ) ) ) '; - assertEquals($expected, $planAsString); - assert($planAsString->indexOf('settlementDateTime = \'${GMTtoTZ( "[US/Arizona]" dt)}\'') != -1); + let expectedLegacyH2 = 'Sequence ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * ( FunctionParametersValidationNode ( functionParameters = [dt:DateTime[1]] ) Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = \'${GMTtoTZ( "[US/Arizona]" dt)}\' connection = TestDatabaseConnection(type = "H2") ) ) ) '; + let expectedNewH2 = 'Sequence ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * ( FunctionParametersValidationNode ( functionParameters = [dt:DateTime[1]] ) Relational ( type = Class[impls=(meta::relational::tests::model::simple::Order | simpleRelationalMapping.meta_relational_tests_model_simple_Order)] resultSizeRange = * resultColumns = [("pk_0", INT), ("id", INT), ("quantity", INT), ("date", DATE), ("settlementDateTime", TIMESTAMP), ("pnl", FLOAT), ("zeroPnl", "")] sql = select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID) where "root".settlementDateTime = TIMESTAMP\'${GMTtoTZ( "[US/Arizona]" dt)}\' connection = TestDatabaseConnection(type = "H2") ) ) ) '; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $planAsString); + assert($planAsString->indexOf('settlementDateTime = \'${GMTtoTZ( "[US/Arizona]" dt)}\'') != -1 || 'settlementDateTime = TIMESTAMP\'${GMTtoTZ( "[US/Arizona]" dt)}\'' != -1); assertSameElements(['<#function GMTtoTZ tz paramDate><#if paramDate?is_enumerable && !paramDate?has_content><#return paramDate><#else><#return (tz+" "+paramDate)?date.@alloyDate><#function renderCollectionWithTz collection timeZone separator prefix suffix defaultValue><#assign result = [] /><#list collection as c><#assign result = [prefix + (timeZone+" "+c)?date.@alloyDate + suffix] + result><#return result?reverse?join(separator, defaultValue)>', '<#function collectionSize collection> <#return collection?size?c> ', '<#function equalEnumOperationSelector enumVal inDyna equalDyna><#assign enumList = enumVal?split(",")><#if enumList?size = 1><#return equalDyna><#else><#return inDyna>', @@ -924,7 +1082,38 @@ function <> meta::pure::executionPlan::tests::testClassPropertyOpenVa let reportEndDate = FiscalCalendarDate.all()->filter(d|$d.date == %2005-10-10)->toOne(); SalesCredit.all()->filter(s|$s.tradeDate.date<$reportEndDate.date);}, myMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals( + assertEqualsH2Compatible( + 'Sequence\n(\n' + + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::SalesCredit | myMapping.meta_relational_tests_groupBy_datePeriods_domain_SalesCredit)]\n' + + ' resultSizeRange = *\n'+ + ' (\n' + + ' Allocation\n' + + ' (\n' + + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::FiscalCalendarDate | myMapping.meta_relational_tests_groupBy_datePeriods_domain_FiscalCalendarDate)]\n' + + ' resultSizeRange = 1\n'+ + ' name = reportEndDate\n' + + ' value = \n' + + ' (\n' + + ' Relational\n' + + ' (\n' + + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::FiscalCalendarDate | myMapping.meta_relational_tests_groupBy_datePeriods_domain_FiscalCalendarDate)]\n' + + ' resultSizeRange = 1\n'+ + ' resultColumns = [("pk_0", DATE), ("pk_1", VARCHAR(15)), ("date", DATE), ("weekStart", DATE), ("weekEnd", DATE), ("day", INT), ("week", INT), ("dayOfWeekNumber", INT), ("yearEnd", DATE), ("yearStart", DATE)]\n'+ + ' sql = select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2005-10-10\'\n' + + ' connection = TestDatabaseConnection(type = \"H2\")\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Relational\n' + + ' (\n' + + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::SalesCredit | myMapping.meta_relational_tests_groupBy_datePeriods_domain_SalesCredit)]\n' + + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("grossValue", DOUBLE)]\n'+ + ' sql = select "root".key as "pk_0", "root".credits as "grossValue" from SALES_GCS as "root" left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where "calendar_0"."date" < \'${reportEndDate.date}\'\n' + + ' connection = TestDatabaseConnection(type = \"H2\")\n' + + ' )\n' + + ' )\n' + + ')\n', 'Sequence\n(\n' + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::SalesCredit | myMapping.meta_relational_tests_groupBy_datePeriods_domain_SalesCredit)]\n' + ' resultSizeRange = *\n'+ @@ -941,7 +1130,7 @@ function <> meta::pure::executionPlan::tests::testClassPropertyOpenVa ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::FiscalCalendarDate | myMapping.meta_relational_tests_groupBy_datePeriods_domain_FiscalCalendarDate)]\n' + ' resultSizeRange = 1\n'+ ' resultColumns = [("pk_0", DATE), ("pk_1", VARCHAR(15)), ("date", DATE), ("weekStart", DATE), ("weekEnd", DATE), ("day", INT), ("week", INT), ("dayOfWeekNumber", INT), ("yearEnd", DATE), ("yearStart", DATE)]\n'+ - ' sql = select \"root\".\"date\" as \"pk_0\", \"root\".\"calendar name\" as \"pk_1\", \"root\".\"date\" as \"date\", \"root\".\"fiscal week start\" as \"weekStart\", \"root\".\"fiscal week end\" as \"weekEnd\", \"root\".\"fiscal day\" as \"day\", \"root\".\"fiscal week\" as \"week\", \"root\".\"fiscal day of week\" as \"dayOfWeekNumber\", \"root\".\"fiscal year end\" as \"yearEnd\", \"root\".\"fiscal year start\" as \"yearStart\" from calendar as \"root\" where \"root\".\"date\" = \'2005-10-10\'\n' + + ' sql = select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2005-10-10\'\n' + ' connection = TestDatabaseConnection(type = \"H2\")\n' + ' )\n' + ' )\n' + @@ -951,7 +1140,7 @@ function <> meta::pure::executionPlan::tests::testClassPropertyOpenVa ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::SalesCredit | myMapping.meta_relational_tests_groupBy_datePeriods_domain_SalesCredit)]\n' + ' resultSizeRange = *\n'+ ' resultColumns = [("pk_0", INT), ("grossValue", DOUBLE)]\n'+ - ' sql = select \"root\".key as \"pk_0\", \"root\".credits as \"grossValue\" from SALES_GCS as \"root\" left outer join calendar as \"calendar_0\" on (\"root\".tradeDate = \"calendar_0\".\"date\") where \"calendar_0\".\"date\" < \'${reportEndDate.date}\'\n' + + ' sql = select "root".key as "pk_0", "root".credits as "grossValue" from SALES_GCS as "root" left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where "calendar_0"."date" < TIMESTAMP\'${reportEndDate.date}\'\n' + ' connection = TestDatabaseConnection(type = \"H2\")\n' + ' )\n' + ' )\n' + @@ -973,7 +1162,7 @@ function <> meta::pure::executionPlan::tests::testGroupByWithOpenVari ['Sales Division', 'Income Function']); }, myMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals( + assertEqualsH2Compatible( 'Sequence\n'+ '(\n'+ ' type = TDS[(Sales Division, String, VARCHAR(30), ""), (Income Function, Number, FLOAT, "")]\n'+ @@ -1003,7 +1192,38 @@ function <> meta::pure::executionPlan::tests::testGroupByWithOpenVari ' connection = TestDatabaseConnection(type = "H2")\n'+ ' )\n'+ ' )\n'+ - ')\n',$result->planToString(meta::relational::extension::relationalExtensions()));} + ')\n', + 'Sequence\n'+ + '(\n'+ + ' type = TDS[(Sales Division, String, VARCHAR(30), ""), (Income Function, Number, FLOAT, "")]\n'+ + ' (\n'+ + ' Allocation\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::FiscalCalendarDate | myMapping.meta_relational_tests_groupBy_datePeriods_domain_FiscalCalendarDate)]\n'+ + ' resultSizeRange = 1\n'+ + ' name = reportEndDate\n'+ + ' value = \n'+ + ' (\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::FiscalCalendarDate | myMapping.meta_relational_tests_groupBy_datePeriods_domain_FiscalCalendarDate)]\n'+ + ' resultSizeRange = 1\n'+ + ' resultColumns = [("pk_0", DATE), ("pk_1", VARCHAR(15)), ("date", DATE), ("weekStart", DATE), ("weekEnd", DATE), ("day", INT), ("week", INT), ("dayOfWeekNumber", INT), ("yearEnd", DATE), ("yearStart", DATE)]\n'+ + ' sql = select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2005-10-10\'\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = TDS[(Sales Division, String, VARCHAR(30), ""), (Income Function, Number, FLOAT, "")]\n'+ + ' resultColumns = [("Sales Division", VARCHAR(30)), ("Income Function", "")]\n'+ + ' sql = select "org_chart_entity_0".name as "Sales Division", sum(case when "calendar_0"."fiscal day" <= ${reportEndDate.day} then "root".credits else CAST(0.0 AS FLOAT) end) as "Income Function" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") group by "Sales Division"\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n', + $result->planToString(meta::relational::extension::relationalExtensions()));} function <> meta::pure::executionPlan::tests::testGroupByWithTwoOpenVariablesInAggAndFilter():Boolean[1] @@ -1023,7 +1243,7 @@ function <> meta::pure::executionPlan::tests::testGroupByWithTwoOpenV ['Sales Division', 'Income Function']); }, myMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals( + assertEqualsH2Compatible( 'Sequence\n'+ '(\n'+ ' type = TDS[(Sales Division, String, VARCHAR(30), ""), (Income Function, Number, FLOAT, "")]\n'+ @@ -1068,7 +1288,53 @@ function <> meta::pure::executionPlan::tests::testGroupByWithTwoOpenV ' connection = TestDatabaseConnection(type = "H2")\n'+ ' )\n'+ ' )\n'+ - ')\n',$result->planToString(meta::relational::extension::relationalExtensions())); + ')\n', + 'Sequence\n'+ + '(\n'+ + ' type = TDS[(Sales Division, String, VARCHAR(30), ""), (Income Function, Number, FLOAT, "")]\n'+ + ' (\n'+ + ' Allocation\n'+ + ' (\n'+ + ' type = StrictDate\n'+ + ' resultSizeRange = 1\n'+ + ' name = startDate\n'+ + ' value = \n'+ + ' (\n'+ + ' Constant\n'+ + ' (\n'+ + ' type = StrictDate\n'+ + ' resultSizeRange = 1\n'+ + ' values=[2015-02-25]\n'+ + ' )\n'+ + ' )\n'+ + ' )\n'+ + ' Allocation\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::FiscalCalendarDate | myMapping.meta_relational_tests_groupBy_datePeriods_domain_FiscalCalendarDate)]\n'+ + ' resultSizeRange = 1\n'+ + ' name = reportEndDate\n'+ + ' value = \n'+ + ' (\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::groupBy::datePeriods::domain::FiscalCalendarDate | myMapping.meta_relational_tests_groupBy_datePeriods_domain_FiscalCalendarDate)]\n'+ + ' resultSizeRange = 1\n'+ + ' resultColumns = [("pk_0", DATE), ("pk_1", VARCHAR(15)), ("date", DATE), ("weekStart", DATE), ("weekEnd", DATE), ("day", INT), ("week", INT), ("dayOfWeekNumber", INT), ("yearEnd", DATE), ("yearStart", DATE)]\n'+ + ' sql = select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2005-10-10\'\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = TDS[(Sales Division, String, VARCHAR(30), ""), (Income Function, Number, FLOAT, "")]\n'+ + ' resultColumns = [("Sales Division", VARCHAR(30)), ("Income Function", "")]\n'+ + ' sql = select "org_chart_entity_0".name as "Sales Division", sum(case when "calendar_0"."fiscal day" <= ${reportEndDate.day} then "root".credits else CAST(0.0 AS FLOAT) end) as "Income Function" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'${startDate}\' and "calendar_0"."date" <= TIMESTAMP\'${reportEndDate.date}\') group by "Sales Division"\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n', + $result->planToString(meta::relational::extension::relationalExtensions())); } function <> meta::pure::executionPlan::tests::testMapWithOpenVariable():Boolean[1] @@ -1651,13 +1917,18 @@ function <> meta::pure::executionPlan::tests::testCrossDbPlanGenerati ')\n' , $result->planToString(meta::relational::extension::relationalExtensions())); } + function <> meta::pure::executionPlan::tests::testTemporalDateVariableAtRoot():Boolean[1] { let l = {bd:Date[1]|meta::relational::tests::milestoning::Product.all($bd)->project(col(t|$t.id, 'id'))}; let result = executionPlan($l, meta::relational::tests::milestoning::milestoningmap, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let rlnNode = $result.rootExecutionNode.executionNodes->filter(n|$n->instanceOf(RelationalInstantiationExecutionNode))->at(0).executionNodes->at(0)->cast(@SQLExecutionNode); let rlnNodeSQL = $rlnNode.sqlQuery; - assertEquals('select "root".id as "id" from ProductTable as "root" where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', $rlnNodeSQL); + assertEqualsH2Compatible( + 'select "root".id as "id" from ProductTable as "root" where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', + 'select "root".id as "id" from ProductTable as "root" where "root".from_z <= TIMESTAMP\'${bd}\' and "root".thru_z > TIMESTAMP\'${bd}\'', + $rlnNodeSQL + ); } function <> meta::pure::executionPlan::tests::testTemporalDateVariableInPropertySequence():Boolean[1] @@ -1666,7 +1937,11 @@ function <> meta::pure::executionPlan::tests::testTemporalDateVariabl let result = executionPlan($l, meta::relational::tests::milestoning::milestoningmap, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let rlnNode = $result.rootExecutionNode.executionNodes->filter(n|$n->instanceOf(RelationalInstantiationExecutionNode))->at(0).executionNodes->at(0)->cast(@SQLExecutionNode); let rlnNodeSQL = $rlnNode.sqlQuery; - assertEquals('select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'${bd}\' and "productclassificationtable_0".thru_z > \'${bd}\') where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', $rlnNodeSQL); + assertEqualsH2Compatible( + 'select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'${bd}\' and "productclassificationtable_0".thru_z > \'${bd}\') where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', + 'select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= TIMESTAMP\'${bd}\' and "productclassificationtable_0".thru_z > TIMESTAMP\'${bd}\') where "root".from_z <= TIMESTAMP\'${bd}\' and "root".thru_z > TIMESTAMP\'${bd}\'', + $rlnNodeSQL + ); } function <> meta::pure::executionPlan::tests::testTemporalDateVariableInFunctionExpression():Boolean[1] @@ -1675,7 +1950,11 @@ function <> meta::pure::executionPlan::tests::testTemporalDateVariabl let result = executionPlan($l, meta::relational::tests::milestoning::milestoningmap, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let rlnNode = $result.rootExecutionNode.executionNodes->filter(n|$n->instanceOf(RelationalInstantiationExecutionNode))->at(0).executionNodes->at(0)->cast(@SQLExecutionNode); let rlnNodeSQL = $rlnNode.sqlQuery; - assertEquals('select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'${bd}\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'${bd}\')) where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', $rlnNodeSQL); + assertEqualsH2Compatible( + 'select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'${bd}\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'${bd}\')) where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', + 'select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, TIMESTAMP\'${bd}\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, TIMESTAMP\'${bd}\')) where "root".from_z <= TIMESTAMP\'${bd}\' and "root".thru_z > TIMESTAMP\'${bd}\'', + $rlnNodeSQL + ); } function <> meta::pure::executionPlan::tests::testTemporalDateVariableInFunctionExpressionWithPropagation():Boolean[1] @@ -1684,7 +1963,11 @@ function <> meta::pure::executionPlan::tests::testTemporalDateVariabl let result = executionPlan($l, meta::relational::tests::milestoning::milestoningmap, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let rlnNode = $result.rootExecutionNode.executionNodes->filter(n|$n->instanceOf(RelationalInstantiationExecutionNode))->at(0).executionNodes->at(0)->cast(@SQLExecutionNode); let rlnNodeSQL = $rlnNode.sqlQuery; - assertEquals('select "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'${bd}\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'${bd}\')) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= dateadd(DAY, 1, \'${bd}\') and "productexchangetable_1".thru_z > dateadd(DAY, 1, \'${bd}\')) as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', $rlnNodeSQL); + assertEqualsH2Compatible( + 'select "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'${bd}\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'${bd}\')) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= dateadd(DAY, 1, \'${bd}\') and "productexchangetable_1".thru_z > dateadd(DAY, 1, \'${bd}\')) as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'${bd}\' and "root".thru_z > \'${bd}\'', + 'select "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, TIMESTAMP\'${bd}\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, TIMESTAMP\'${bd}\')) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= dateadd(DAY, 1, TIMESTAMP\'${bd}\') and "productexchangetable_1".thru_z > dateadd(DAY, 1, TIMESTAMP\'${bd}\')) as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= TIMESTAMP\'${bd}\' and "root".thru_z > TIMESTAMP\'${bd}\'', + $rlnNodeSQL + ); } function <> meta::pure::executionPlan::tests::testModelConnectionSimple() : Boolean[1] @@ -1917,7 +2200,7 @@ function <> meta::pure::executionPlan::tests::testPlanGenerationForIn { let generatedPlan = executionPlan({optionalDateTime:DateTime[*] |Trade.all()->filter(t|$t.settlementDateTime->in($optionalDateTime))->project([x | $x.id], ['TradeId'])}, simpleRelationalMapping, ^Runtime(connections=^DatabaseConnection(element = relationalDB, type=DatabaseType.H2, timeZone='US/Arizona')), meta::relational::extension::relationalExtensions()); let result = $generatedPlan->planToString(meta::relational::extension::relationalExtensions()); - let expectedPlan ='Sequence\n'+ + let expectedPlanLegacyH2 ='Sequence\n'+ '(\n'+ ' type = TDS[(TradeId, Integer, INT, "")]\n'+ ' (\n'+ @@ -1934,7 +2217,24 @@ function <> meta::pure::executionPlan::tests::testPlanGenerationForIn ' )\n'+ ' )\n'+ ')\n'; - assertEquals($expectedPlan, $result); + let expectedPlanNewH2 ='Sequence\n'+ + '(\n'+ + ' type = TDS[(TradeId, Integer, INT, "")]\n'+ + ' (\n'+ + ' FunctionParametersValidationNode\n'+ + ' (\n'+ + ' functionParameters = [optionalDateTime:DateTime[*]]\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = TDS[(TradeId, Integer, INT, "")]\n'+ + ' resultColumns = [("TradeId", INT)]\n'+ + ' sql = select "root".ID as "TradeId" from tradeTable as "root" where "root".settlementDateTime in (${renderCollectionWithTz(optionalDateTime![] "[US/Arizona]" "," "TIMESTAMP\'" "\'" "null")})\n'+ + ' connection = DatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n'; + assertEqualsH2Compatible($expectedPlanLegacyH2, $expectedPlanNewH2, $result); } function <> meta::pure::executionPlan::tests::relationalTDSTypeForColumnsAndQuoting():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testAggregation.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testAggregation.pure index 2caeb93ef27..fc088ad27fa 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testAggregation.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testAggregation.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::mapping::*; import meta::relational::tests::*; import meta::relational::tests::model::simple::*; @@ -84,7 +85,11 @@ function <> meta::relational::tests::projection::aggregation::testSub let result = execute(|Firm.all()->project([f|$f.legalName, f|$f.employees->map(e|if($e.lastName == 'Hill',|$e.age->toOne()/2,|1.0))->average()], ['a', 'b']), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values.rows, 4); assertSameElements(['Firm A 1.0', 'Firm B 16.0', 'Firm C 1.0', 'Firm X 2.25'], $result.values.rows->map(r|$r.getString('a')+' '+$r.getFloat('b')->toString())); - assertEquals('select "root".LEGALNAME as "a", "firmtable_1".aggCol as "b" from firmTable as "root" left outer join (select "firmtable_2".ID as ID, avg(1.0 * case when "persontable_0".LASTNAME = \'Hill\' then ((1.0 * "persontable_0".AGE) / 2) else 1.0 end) as aggCol from firmTable as "firmtable_2" left outer join personTable as "persontable_0" on ("firmtable_2".ID = "persontable_0".FIRMID) group by "firmtable_2".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".LEGALNAME as "a", "firmtable_1".aggCol as "b" from firmTable as "root" left outer join (select "firmtable_2".ID as ID, avg(1.0 * case when "persontable_0".LASTNAME = \'Hill\' then ((1.0 * "persontable_0".AGE) / 2) else 1.0 end) as aggCol from firmTable as "firmtable_2" left outer join personTable as "persontable_0" on ("firmtable_2".ID = "persontable_0".FIRMID) group by "firmtable_2".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', + 'select "root".LEGALNAME as "a", "firmtable_1".aggCol as "b" from firmTable as "root" left outer join (select "firmtable_2".ID as ID, avg(1.0 * case when "persontable_0".LASTNAME = \'Hill\' then ((1.0 * "persontable_0".AGE) / 2) else CAST(1.0 AS FLOAT) end) as aggCol from firmTable as "firmtable_2" left outer join personTable as "persontable_0" on ("firmtable_2".ID = "persontable_0".FIRMID) group by "firmtable_2".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::projection::aggregation::testSubAggregationWithJoinStrings():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testDateFilters.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testDateFilters.pure index e0e72a70cf1..54c536b7268 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testDateFilters.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testDateFilters.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::model::simple::*; import meta::relational::mapping::*; import meta::relational::tests::*; @@ -36,7 +37,11 @@ function <> meta::relational::tests::projection::filter::dates::now:: function <> meta::relational::tests::projection::filter::dates::adjust::testAdjust():Boolean[1] { let result = execute(|Trade.all()->filter(d | $d.date == %2014-11-30->adjust(1, DurationUnit.DAYS))->project(x | $x.date, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, 1, \'2014-11-30\')', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, 1, \'2014-11-30\')', + 'select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, 1, DATE\'2014-11-30\')', + $result->sqlRemoveFormatting() + ); assertSize($result.values.rows, 3); assertSameElements([%2014-12-01,%2014-12-01,%2014-12-01], $result.values.rows.values); } @@ -44,7 +49,11 @@ function <> meta::relational::tests::projection::filter::dates::adjus function <> meta::relational::tests::projection::filter::dates::adjust::testAdjustWithMicroseconds():Boolean[1] { let result = execute(|Trade.all()->filter(d | ($d.settlementDateTime > %2014-12-04T15:22:23->adjust(123456, DurationUnit.MICROSECONDS)) && ($d.settlementDateTime < %2014-12-04T15:22:23->adjust(123457, DurationUnit.MICROSECONDS)))->project(x | $x.settlementDateTime, 'settlementDateTime'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".settlementDateTime as "settlementDateTime" from tradeTable as "root" where (("root".settlementDateTime is not null and "root".settlementDateTime > dateadd(MICROSECOND, 123456, \'2014-12-04 15:22:23\')) and ("root".settlementDateTime is not null and "root".settlementDateTime < dateadd(MICROSECOND, 123457, \'2014-12-04 15:22:23\')))', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".settlementDateTime as "settlementDateTime" from tradeTable as "root" where (("root".settlementDateTime is not null and "root".settlementDateTime > dateadd(MICROSECOND, 123456, \'2014-12-04 15:22:23\')) and ("root".settlementDateTime is not null and "root".settlementDateTime < dateadd(MICROSECOND, 123457, \'2014-12-04 15:22:23\')))', + 'select "root".settlementDateTime as "settlementDateTime" from tradeTable as "root" where (("root".settlementDateTime is not null and "root".settlementDateTime > dateadd(MICROSECOND, 123456, TIMESTAMP\'2014-12-04 15:22:23\')) and ("root".settlementDateTime is not null and "root".settlementDateTime < dateadd(MICROSECOND, 123457, TIMESTAMP\'2014-12-04 15:22:23\')))', + $result->sqlRemoveFormatting() + ); assertSize($result.values.rows, 1); assertSameElements([%2014-12-04T15:22:23.123456789], $result.values.rows.values); } @@ -52,7 +61,11 @@ function <> meta::relational::tests::projection::filter::dates::adjus function <> meta::relational::tests::projection::filter::dates::firstDay::testFirstDayOfWeek():Boolean[1] { let result = execute(|Trade.all()->filter(d | $d.date->firstDayOfWeek() == %2017-09-18)->project(x | $x.date, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(mod(dayofweek("root".tradeDate)+5, 7)), "root".tradeDate) = \'2017-09-18\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(mod(dayofweek("root".tradeDate)+5, 7)), "root".tradeDate) = \'2017-09-18\'', + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(mod(dayofweek("root".tradeDate)+5, 7)), "root".tradeDate) = DATE\'2017-09-18\'', + $result->sqlRemoveFormatting() + ); } @@ -65,7 +78,11 @@ function <> meta::relational::tests::projection::filter::dates::first function <> meta::relational::tests::projection::filter::dates::firstDay::testFirstDayOfMonth():Boolean[1] { let result = execute(|Trade.all()->filter(d | $d.date->firstDayOfMonth() == %2017-02-01)->project(x | $x.date, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(dayofmonth("root".tradeDate) - 1), "root".tradeDate) = \'2017-02-01\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(dayofmonth("root".tradeDate) - 1), "root".tradeDate) = \'2017-02-01\'', + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(dayofmonth("root".tradeDate) - 1), "root".tradeDate) = DATE\'2017-02-01\'', + $result->sqlRemoveFormatting() + ); } @@ -78,7 +95,11 @@ function <> meta::relational::tests::projection::filter::dates::first function <> meta::relational::tests::projection::filter::dates::firstDay::testFirstDayOfQuarter():Boolean[1] { let result = execute(|Trade.all()->filter(d | $d.date->firstDayOfQuarter() == %2017-04-01)->project(x | $x.date, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".tradeDate as "date" from tradeTable as "root" where dateadd(MONTH, 3 * quarter("root".tradeDate) - 3, dateadd(DAY, -(dayofyear("root".tradeDate) - 1), "root".tradeDate)) = \'2017-04-01\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(MONTH, 3 * quarter("root".tradeDate) - 3, dateadd(DAY, -(dayofyear("root".tradeDate) - 1), "root".tradeDate)) = \'2017-04-01\'', + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(MONTH, 3 * quarter("root".tradeDate) - 3, dateadd(DAY, -(dayofyear("root".tradeDate) - 1), "root".tradeDate)) = DATE\'2017-04-01\'', + $result->sqlRemoveFormatting() + ); } @@ -91,7 +112,11 @@ function <> meta::relational::tests::projection::filter::dates::first function <> meta::relational::tests::projection::filter::dates::firstDay::testFirstDayOfYear():Boolean[1] { let result = execute(|Trade.all()->filter(d | $d.date->firstDayOfYear() == %2017-01-01)->project(x | $x.date, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(dayofyear("root".tradeDate) - 1), "root".tradeDate) = \'2017-01-01\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(dayofyear("root".tradeDate) - 1), "root".tradeDate) = \'2017-01-01\'', + 'select "root".tradeDate as "date" from tradeTable as "root" where dateadd(DAY, -(dayofyear("root".tradeDate) - 1), "root".tradeDate) = DATE\'2017-01-01\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::projection::filter::dates::recent::testMostRecentDayOfWeek():Boolean[1] @@ -113,7 +138,11 @@ function <> meta::relational::tests::projection::filter::dates::recen let result = execute(|Trade.all()->filter(d | $d.date == mostRecentDayOfWeek(%2014-12-04, DayOfWeek.Monday))->project(x | $x.date, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values.rows, 3); assertSameElements([%2014-12-01,%2014-12-01,%2014-12-01], $result.values.rows.values); - assertEquals('select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, case when 2 - DAY_OF_WEEK(\'2014-12-04\') > 0 then 2 - DAY_OF_WEEK(\'2014-12-04\') - 7 else 2 - DAY_OF_WEEK(\'2014-12-04\') end, \'2014-12-04\')', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, case when 2 - DAY_OF_WEEK(\'2014-12-04\') > 0 then 2 - DAY_OF_WEEK(\'2014-12-04\') - 7 else 2 - DAY_OF_WEEK(\'2014-12-04\') end, \'2014-12-04\')', + 'select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, case when 2 - DAY_OF_WEEK(DATE\'2014-12-04\') > 0 then 2 - DAY_OF_WEEK(DATE\'2014-12-04\') - 7 else 2 - DAY_OF_WEEK(DATE\'2014-12-04\') end, DATE\'2014-12-04\')', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::projection::filter::dates::recent::testPreviousDayOfWeekWithDate():Boolean[1] @@ -121,7 +150,11 @@ function <> meta::relational::tests::projection::filter::dates::recen let result = execute(|Trade.all()->filter(d | $d.date == previousDayOfWeek(%2014-12-08, DayOfWeek.Monday))->project(x | $x.date, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values.rows, 3); assertSameElements([%2014-12-01,%2014-12-01,%2014-12-01], $result.values.rows.values); - assertEquals('select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, case when 2 - DAY_OF_WEEK(\'2014-12-08\') >= 0 then 2 - DAY_OF_WEEK(\'2014-12-08\') - 7 else 2 - DAY_OF_WEEK(\'2014-12-08\') end, \'2014-12-08\')', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, case when 2 - DAY_OF_WEEK(\'2014-12-08\') >= 0 then 2 - DAY_OF_WEEK(\'2014-12-08\') - 7 else 2 - DAY_OF_WEEK(\'2014-12-08\') end, \'2014-12-08\')', + 'select "root".tradeDate as "date" from tradeTable as "root" where "root".tradeDate = dateadd(DAY, case when 2 - DAY_OF_WEEK(DATE\'2014-12-08\') >= 0 then 2 - DAY_OF_WEEK(DATE\'2014-12-08\') - 7 else 2 - DAY_OF_WEEK(DATE\'2014-12-08\') end, DATE\'2014-12-08\')', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::projection::filter::dates::testDateWithSeconds():Boolean[1] @@ -129,5 +162,9 @@ function <> meta::relational::tests::projection::filter::dates::testD let result = execute(|Trade.all()->filter(d | $d.settlementDateTime > %2014-12-04T15:22:24)->project(x | $x.settlementDateTime, 'date'), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values.rows, 3); assertSameElements([%2014-12-04T21:00:00.000000000+0000, %2014-12-05T21:00:00.000000000+0000, %2014-12-05T21:00:00.000000000+0000], $result.values.rows.values); - assertEquals('select "root".settlementDateTime as "date" from tradeTable as "root" where ("root".settlementDateTime is not null and "root".settlementDateTime > \'2014-12-04 15:22:24\')', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".settlementDateTime as "date" from tradeTable as "root" where ("root".settlementDateTime is not null and "root".settlementDateTime > \'2014-12-04 15:22:24\')', + 'select "root".settlementDateTime as "date" from tradeTable as "root" where ("root".settlementDateTime is not null and "root".settlementDateTime > TIMESTAMP\'2014-12-04 15:22:24\')', + $result->sqlRemoveFormatting() + ); } \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testGroupWithWindowSubset.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testGroupWithWindowSubset.pure index a6fa74e9c02..ff31e7706a8 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testGroupWithWindowSubset.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testGroupWithWindowSubset.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::csv::*; import meta::relational::mapping::*; import meta::relational::tests::advanced::contractmoneyscenario::*; @@ -60,7 +61,11 @@ function <> meta::relational::tests::projection::testGroupByWithWindo ) , ContractMoney, testRuntime(), meta::relational::extension::relationalExtensions()); //check for base table attributes are being selected only - assertEquals( 'select "root".price as "Amount", "fx_0".rate as "Rate", sum("root".price) as "Amount-Sum", avg(1.0 * case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end) as "Rate-Average" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1)) group by "Amount","Rate"', $results2->sqlRemoveFormatting() ); + assertEqualsH2Compatible( + 'select "root".price as "Amount", "fx_0".rate as "Rate", sum("root".price) as "Amount-Sum", avg(1.0 * case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end) as "Rate-Average" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1)) group by "Amount","Rate"', + 'select "root".price as "Amount", "fx_0".rate as "Rate", sum("root".price) as "Amount-Sum", avg(1.0 * case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end) as "Rate-Average" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = DATE\'2003-10-10\' and "fx_0".tenor = 1)) group by "Amount","Rate"', + $results2->sqlRemoveFormatting() + ); assertEquals( 'Amount | Rate | Amount-Sum | Rate-Average',$results2.values.columns->map(r|$r.name->makeString(','))->makeString(' | ')->cast(@String) ); @@ -82,7 +87,11 @@ function <> meta::relational::tests::projection::testGroupByWithWindo ) , ContractMoney, testRuntime(), meta::relational::extension::relationalExtensions()); //check for attributes that are in different order than the input parmeters - assertEquals( 'select "fx_0".rate as "Rate", "root".price as "Amount", avg(1.0 * case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end) as "Rate-Average", sum("root".price) as "Amount-Sum" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1)) group by "Rate","Amount"', $results3->sqlRemoveFormatting() ); + assertEqualsH2Compatible( + 'select "fx_0".rate as "Rate", "root".price as "Amount", avg(1.0 * case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end) as "Rate-Average", sum("root".price) as "Amount-Sum" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1)) group by "Rate","Amount"', + 'select "fx_0".rate as "Rate", "root".price as "Amount", avg(1.0 * case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end) as "Rate-Average", sum("root".price) as "Amount-Sum" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = DATE\'2003-10-10\' and "fx_0".tenor = 1)) group by "Rate","Amount"', + $results3->sqlRemoveFormatting() + ); assertEquals( $results.values.rows->filter ( x| $x.getFloat('Amount-Sum') == 10.0 && $x.getFloat('Amount') == 5.0 )->size() , 1 ); assertEquals( $results.values.rows->filter ( x| $x.getFloat('Amount-Sum') == 5.75 && $x.getFloat('Amount')== 5.75 )->size() , 1 ); assertEquals( 'Rate | Amount | Rate-Average | Amount-Sum',$results3.values.columns->map(r|$r.name->makeString(','))->makeString(' | ')->cast(@String) ); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testIn.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testIn.pure index f8b0bd493fb..19c91859b82 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testIn.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/projection/testIn.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::model::simple::*; import meta::relational::mapping::*; import meta::relational::tests::*; @@ -186,7 +187,11 @@ function <> meta::relational::tests::projection::filter::in::testInWi assertSize($result.values.rows, 1); println($result.values.rows.values); assertSameElements([false, '4'], $result.values.rows.values); - assertEquals('select "root".ID as "id", case when "root".active = \'Y\' then \'true\' else \'false\' end as "active" from interactionTable as "root" where (case when "root".active = \'Y\' then \'true\' else \'false\' end in (\'false\', \'something\') and "root".ID = 4)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "id", case when "root".active = \'Y\' then \'true\' else \'false\' end as "active" from interactionTable as "root" where (case when "root".active = \'Y\' then \'true\' else \'false\' end in (\'false\', \'something\') and "root".ID = 4)', + 'select "root".ID as "id", cast(case when "root".active = \'Y\' then \'true\' else \'false\' end as boolean) as "active" from interactionTable as "root" where (case when "root".active = \'Y\' then \'true\' else \'false\' end in (\'false\', \'something\') and "root".ID = 4)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::projection::filter::in::testQualifierWithInThroughJoin():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testCalculatingDistance.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testCalculatingDistance.pure index 45b05d27f7f..91237ca7e9a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testCalculatingDistance.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testCalculatingDistance.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::mapping::*; import meta::pure::runtime::*; import meta::relational::runtime::*; @@ -31,7 +32,11 @@ function <> meta::relational::tests::functions::di let result = execute(| PointOfInterest.all()->filter(f| distance($f.location, $london.location) < 350), testDistanceMapping, testDistanceRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 2); assertSameElements(['Eiffel Tower', 'Royal Observatory Greenwich'], $result.values.name); - assertEquals('select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) < 350', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) < 350', + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (CAST(6371.0 AS FLOAT) * (CAST(2.0 AS FLOAT) * atan2(sqrt((power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))))))) < 350', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -41,7 +46,11 @@ function <> meta::relational::tests::functions::di let result = execute(| PointOfInterest.all()->filter(f| distance($f.location, $london.location) > 15000), testDistanceMapping, testDistanceRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 1); assertSameElements(['Sydney Opera House'], $result.values.name); - assertEquals('select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) > 15000', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) > 15000', + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (CAST(6371.0 AS FLOAT) * (CAST(2.0 AS FLOAT) * atan2(sqrt((power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))))))) > 15000', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -51,7 +60,11 @@ function <> meta::relational::tests::functions::di let result = execute(| PointOfInterest.all()->filter(f| distance($f.location, $london.location) < 9.5), testDistanceMapping, testDistanceRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 1); assertSameElements(['Royal Observatory Greenwich'], $result.values.name); - assertEquals('select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) < 9.5', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) < 9.5', + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (CAST(6371.0 AS FLOAT) * (CAST(2.0 AS FLOAT) * atan2(sqrt((power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))))))) < CAST(9.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -81,7 +94,11 @@ function <> meta::relational::tests::functions::di assertEquals('Royal Observatory Greenwich', $distanceResult->at(5).values->at(0)); assertEqWithinTolerance(9.473395, $distanceResult->at(5).values->at(1)->cast(@Number), 0.000001); - assertEquals('select "root".name as "name", (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) as "distance" from coordinatesTable as "root"', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".name as "name", (6371.0 * (2.0 * atan2(sqrt((power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (51.507356 * 3.141592653589793)) / 180) - ((1.0 * ("root".latitude * 3.141592653589793)) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * power(sin(((1.0 * (((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))) / 2)), 2)))))))) as "distance" from coordinatesTable as "root"', + 'select "root".name as "name", (CAST(6371.0 AS FLOAT) * (CAST(2.0 AS FLOAT) * atan2(sqrt((power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))),sqrt((1 - (power(sin(((1.0 * (((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * power(sin(((1.0 * (((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))) / 2)), 2)))))))) as "distance" from coordinatesTable as "root"', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -91,7 +108,11 @@ function <> meta::relational::tests::functions::di let result = execute(| PointOfInterest.all()->filter(f| distanceSphericalLawOfCosines($f.location, $london.location) < 350), testDistanceMapping, testDistanceRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 2); assertSameElements(['Eiffel Tower', 'Royal Observatory Greenwich'], $result.values.name); - assertEquals('select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) < 350', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) < 350', + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (CAST(6371.0 AS FLOAT) * acos(((sin(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * sin(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180))) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos((((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))))))) < 350', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -101,7 +122,11 @@ function <> meta::relational::tests::functions::di let result = execute(| PointOfInterest.all()->filter(f| distanceSphericalLawOfCosines($f.location, $london.location) > 15000), testDistanceMapping, testDistanceRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 1); assertSameElements(['Sydney Opera House'], $result.values.name); - assertEquals('select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) > 15000', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) > 15000', + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (CAST(6371.0 AS FLOAT) * acos(((sin(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * sin(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180))) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos((((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))))))) > 15000', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -111,7 +136,11 @@ function <> meta::relational::tests::functions::di let result = execute(| PointOfInterest.all()->filter(f| distanceSphericalLawOfCosines($f.location, $london.location) < 9.5), testDistanceMapping, testDistanceRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 1); assertSameElements(['Royal Observatory Greenwich'], $result.values.name); - assertEquals('select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) < 9.5', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) < 9.5', + 'select "root".ID as "pk_0", "root".name as "name" from coordinatesTable as "root" where (CAST(6371.0 AS FLOAT) * acos(((sin(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * sin(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180))) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos((((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))))))) < CAST(9.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -141,8 +170,11 @@ function <> meta::relational::tests::functions::di assertEquals('Royal Observatory Greenwich', $distanceResult->at(5).values->at(0)); assertEqWithinTolerance(9.473395, $distanceResult->at(5).values->at(1)->cast(@Number), 0.000001); - assertEquals('select "root".name as "name", (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) as "distance" from coordinatesTable as "root"', $result->sqlRemoveFormatting()); - + assertEqualsH2Compatible( + 'select "root".name as "name", (6371.0 * acos(((sin(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * sin(((1.0 * (51.507356 * 3.141592653589793)) / 180))) + (cos(((1.0 * ("root".latitude * 3.141592653589793)) / 180)) * cos(((1.0 * (51.507356 * 3.141592653589793)) / 180)) * cos((((1.0 * (-0.127706 * 3.141592653589793)) / 180) - ((1.0 * ("root".longitude * 3.141592653589793)) / 180))))))) as "distance" from coordinatesTable as "root"', + 'select "root".name as "name", (CAST(6371.0 AS FLOAT) * acos(((sin(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * sin(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180))) + (cos(((1.0 * ("root".latitude * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos(((1.0 * (CAST(51.507356 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180)) * cos((((1.0 * (CAST(-0.127706 AS FLOAT) * CAST(3.141592653589793 AS FLOAT))) / 180) - ((1.0 * ("root".longitude * CAST(3.141592653589793 AS FLOAT))) / 180))))))) as "distance" from coordinatesTable as "root"', + $result->sqlRemoveFormatting() + ); } function meta::relational::tests::functions::distance::testDisplayMapFromDB():GeographicCoordinate[*] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testFilters.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testFilters.pure index 602e373d4d8..8782d7b1a16 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testFilters.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testFilters.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::query::filter::equal::*; import meta::relational::mapping::*; import meta::relational::tests::model::simple::*; @@ -142,7 +143,11 @@ function <> meta::relational::tests::query::filter::greaterThan::test let result = execute(|Account.all()->filter(a|$a.createDate > %2013-12-01), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 1); assertSameElements(%2013-12-02, $result.values->at(0).createDate); - assertEquals('select "root".ID as "pk_0", "root".name as "name", "root".createDate as "createDate" from accountTable as "root" where "root".createDate > \'2013-12-01\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".name as "name", "root".createDate as "createDate" from accountTable as "root" where "root".createDate > \'2013-12-01\'', + 'select "root".ID as "pk_0", "root".name as "name", "root".createDate as "createDate" from accountTable as "root" where "root".createDate > DATE\'2013-12-01\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::filter::greaterThanEqual::testGreaterThanEqual():Boolean[1] @@ -174,7 +179,11 @@ function <> meta::relational::tests::query::filter::lessThan::testLes let result = execute(|Trade.all()->filter(t|(((($t.quantity - 5) * -3.0) + 4) / 2) > -45), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 7); assertEquals([25.0, 11.0, 23.0, 32.0, 27.0, 22.0, 5.0], $result.values->map(t|$t.quantity)); - assertEquals('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where ((1.0 * ((("root".quantity - 5) * -3.0) + 4)) / 2) > -45', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where ((1.0 * ((("root".quantity - 5) * -3.0) + 4)) / 2) > -45', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where ((1.0 * ((("root".quantity - 5) * -CAST(3.0 AS FLOAT)) + 4)) / 2) > -45', + $result->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testMap.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testMap.pure index 5f16c9702ac..a3ddba8f1e6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testMap.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testMap.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::mapping::filter::model::domain::*; import meta::relational::mapping::*; import meta::relational::tests::model::simple::*; @@ -279,7 +280,11 @@ function <> meta::relational::tests::map::testSubAggregationUsingIf() let result = execute(|Firm.all()->map(f|$f.employees->map(e|if($e.lastName == 'Hill',|$e.age->toOne()/2,|1.0))->average()), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 4); assertSameElements([1.0, 1.0, 2.25, 16.0], $result.values); - assertEquals('select "firmtable_1".aggCol from firmTable as "root" left outer join (select "firmtable_1".ID as ID, avg(1.0 * case when "persontable_0".LASTNAME = \'Hill\' then ((1.0 * "persontable_0".AGE) / 2) else 1.0 end) as aggCol from firmTable as "firmtable_1" left outer join personTable as "persontable_0" on ("firmtable_1".ID = "persontable_0".FIRMID) group by "firmtable_1".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "firmtable_1".aggCol from firmTable as "root" left outer join (select "firmtable_1".ID as ID, avg(1.0 * case when "persontable_0".LASTNAME = \'Hill\' then ((1.0 * "persontable_0".AGE) / 2) else 1.0 end) as aggCol from firmTable as "firmtable_1" left outer join personTable as "persontable_0" on ("firmtable_1".ID = "persontable_0".FIRMID) group by "firmtable_1".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', + 'select "firmtable_1".aggCol from firmTable as "root" left outer join (select "firmtable_1".ID as ID, avg(1.0 * case when "persontable_0".LASTNAME = \'Hill\' then ((1.0 * "persontable_0".AGE) / 2) else CAST(1.0 AS FLOAT) end) as aggCol from firmTable as "firmtable_1" left outer join personTable as "persontable_0" on ("firmtable_1".ID = "persontable_0".FIRMID) group by "firmtable_1".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::map::testSubAggregationAverageInQualifier():Boolean[1] @@ -287,7 +292,11 @@ function <> meta::relational::tests::map::testSubAggregationAverageIn let result = execute(|Firm.all()->map(f|$f.averageEmployeesAge()), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 4); assertSameElements([39.5, 64.0, 68.0, 70.0], $result.values); - assertEquals('select ("firmtable_1".aggCol * 2.0) from firmTable as "root" left outer join (select "firmtable_1".ID as ID, avg(1.0 * "persontable_0".AGE) as aggCol from firmTable as "firmtable_1" left outer join personTable as "persontable_0" on ("firmtable_1".ID = "persontable_0".FIRMID) group by "firmtable_1".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select ("firmtable_1".aggCol * 2.0) from firmTable as "root" left outer join (select "firmtable_1".ID as ID, avg(1.0 * "persontable_0".AGE) as aggCol from firmTable as "firmtable_1" left outer join personTable as "persontable_0" on ("firmtable_1".ID = "persontable_0".FIRMID) group by "firmtable_1".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', + 'select ("firmtable_1".aggCol * CAST(2.0 AS FLOAT)) from firmTable as "root" left outer join (select "firmtable_1".ID as ID, avg(1.0 * "persontable_0".AGE) as aggCol from firmTable as "firmtable_1" left outer join personTable as "persontable_0" on ("firmtable_1".ID = "persontable_0".FIRMID) group by "firmtable_1".ID) as "firmtable_1" on ("root".ID = "firmtable_1".ID)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::map::testSubAggregationMaxInQualifier():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testModelGroupBy.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testModelGroupBy.pure index 3bc43a75489..076be67d4ab 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testModelGroupBy.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/functions/tests/testModelGroupBy.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::mapping::*; import meta::relational::runtime::*; import meta::relational::functions::asserts::*; @@ -237,7 +238,11 @@ function <> meta::relational::tests::groupBy::testUsingAFunctionInThe assertEquals(['Firm X', 690.0, 'Firm C', 352.0, 'Firm A', 0.0, ^TDSNull(), 0.0], $result.values.rows.values); - assertSameSQL('select "producttable_0".NAME as "prodName", (sum(case when (("producttable_0".NAME is not null and "producttable_0".NAME like \'%X\') or ("producttable_0".NAME is not null and "producttable_0".NAME like \'%C\')) then "root".quantity else 0.0 end) * 2) as "cnt" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', $result); + assertEqualsH2Compatible( + 'select "producttable_0".NAME as "prodName", (sum(case when (("producttable_0".NAME is not null and "producttable_0".NAME like \'%X\') or ("producttable_0".NAME is not null and "producttable_0".NAME like \'%C\')) then "root".quantity else 0.0 end) * 2) as "cnt" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', + 'select "producttable_0".NAME as "prodName", (sum(case when (("producttable_0".NAME is not null and "producttable_0".NAME like \'%X\') or ("producttable_0".NAME is not null and "producttable_0".NAME like \'%C\')) then "root".quantity else CAST(0.0 AS FLOAT) end) * 2) as "cnt" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', + $result->sqlRemoveFormatting() + ); } @@ -264,7 +269,11 @@ function <> meta::relational::tests::groupBy::testUsingAnAssociationI assertEquals(['Firm X', 50.0, 'Firm C', 142.0, 'Firm A', 86.0, ^TDSNull(), 0.0], $result.values.rows.values); - assertSameSQL('select "producttable_0".NAME as "prodName", (sum(case when ("accounttable_0".name is not null and "accounttable_0".name like \'Account 1%\') then "root".quantity else 0.0 end) * 2) as "cnt" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) left outer join accountTable as "accounttable_0" on ("root".accountID = "accounttable_0".ID) group by "prodName" order by "prodName" desc', $result); + assertEqualsH2Compatible( + 'select "producttable_0".NAME as "prodName", (sum(case when ("accounttable_0".name is not null and "accounttable_0".name like \'Account 1%\') then "root".quantity else 0.0 end) * 2) as "cnt" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) left outer join accountTable as "accounttable_0" on ("root".accountID = "accounttable_0".ID) group by "prodName" order by "prodName" desc', + 'select "producttable_0".NAME as "prodName", (sum(case when ("accounttable_0".name is not null and "accounttable_0".name like \'Account 1%\') then "root".quantity else CAST(0.0 AS FLOAT) end) * 2) as "cnt" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) left outer join accountTable as "accounttable_0" on ("root".accountID = "accounttable_0".ID) group by "prodName" order by "prodName" desc', + $result->sqlRemoveFormatting() + ); } @@ -509,7 +518,11 @@ function <> meta::relational::tests::groupBy::testGroupByOnRootLevelP assertSize($result.values, 1); assertEquals([%2014-12-01, 356.0], $result.values.rows.values); - assertSameSQL('select "root".tradeDate as "Date", sum("root".quantity) as "Total Quantity" from tradeTable as "root" where "root".tradeDate = \'2014-12-01\' group by "Date"', $result); + assertEqualsH2Compatible( + 'select "root".tradeDate as "Date", sum("root".quantity) as "Total Quantity" from tradeTable as "root" where "root".tradeDate = \'2014-12-01\' group by "Date"', + 'select "root".tradeDate as "Date", sum("root".quantity) as "Total Quantity" from tradeTable as "root" where "root".tradeDate = DATE\'2014-12-01\' group by "Date"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::groupBy::testSimpleJoinStrings():Boolean[1] @@ -994,11 +1007,11 @@ function <> meta::relational::tests::groupBy::testObjectLevelGroupByW , x|$x.getString('LastName'), y| $y->joinStrings(',')) ) , simpleRelationalMapping, meta::relational::tests::testRuntime() , meta::relational::extension::relationalExtensions()); - - - assertEquals( 'select "persontable_0"."FirstName" as "FirstName", "persontable_0"."Case Column" as "Case Column", group_concat("LastName" separator \',\') as "Joined Last Name" from (select "root".FIRSTNAME as "FirstName", "root".LASTNAME as "LastName", "firmtable_0".LEGALNAME as "FirmName", avg(1.0 * "root".AGE) as "Average Age 1", case when avg(1.0 * "root".AGE) < 10 then 10 else (avg(1.0 * "root".AGE) * 0.9) end as "Case Column" from personTable as "root" left outer join firmTable as "firmtable_0" on ("firmtable_0".ID = "root".FIRMID) group by "FirstName","LastName","FirmName" having "firmtable_0".LEGALNAME = \'Firm X\') as "persontable_0" group by "FirstName","Case Column"', $result->sqlRemoveFormatting() ); - - + assertEqualsH2Compatible( + 'select "persontable_0"."FirstName" as "FirstName", "persontable_0"."Case Column" as "Case Column", group_concat("LastName" separator \',\') as "Joined Last Name" from (select "root".FIRSTNAME as "FirstName", "root".LASTNAME as "LastName", "firmtable_0".LEGALNAME as "FirmName", avg(1.0 * "root".AGE) as "Average Age 1", case when avg(1.0 * "root".AGE) < 10 then 10 else (avg(1.0 * "root".AGE) * 0.9) end as "Case Column" from personTable as "root" left outer join firmTable as "firmtable_0" on ("firmtable_0".ID = "root".FIRMID) group by "FirstName","LastName","FirmName" having "firmtable_0".LEGALNAME = \'Firm X\') as "persontable_0" group by "FirstName","Case Column"', + 'select "persontable_0"."FirstName" as "FirstName", "persontable_0"."Case Column" as "Case Column", group_concat("LastName" separator \',\') as "Joined Last Name" from (select "root".FIRSTNAME as "FirstName", "root".LASTNAME as "LastName", "firmtable_0".LEGALNAME as "FirmName", avg(1.0 * "root".AGE) as "Average Age 1", case when avg(1.0 * "root".AGE) < 10 then 10 else (avg(1.0 * "root".AGE) * CAST(0.9 AS FLOAT)) end as "Case Column" from personTable as "root" left outer join firmTable as "firmtable_0" on ("firmtable_0".ID = "root".FIRMID) group by "FirstName","LastName","FirmName" having "firmtable_0".LEGALNAME = \'Firm X\') as "persontable_0" group by "FirstName","Case Column"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::groupBy::testReprocessGroupByAlias():Boolean[1] @@ -1032,7 +1045,11 @@ function <> meta::relational::tests::groupBy::testUniqueValueOnly1(): assertEquals(['Firm C', 1, 45.0], $result.values.rows.values); - assertSameSQL('select "producttable_0".NAME as "prodName", count(distinct("root".quantity)) as "count", case when count(distinct("root".quantity)) = 1 then max("root".quantity) else null end as "uniqueValue" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) where ("producttable_0".NAME = \'Firm C\' and "root".quantity = 45.0) group by "prodName"', $result); + assertEqualsH2Compatible( + 'select "producttable_0".NAME as "prodName", count(distinct("root".quantity)) as "count", case when count(distinct("root".quantity)) = 1 then max("root".quantity) else null end as "uniqueValue" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) where ("producttable_0".NAME = \'Firm C\' and "root".quantity = 45.0) group by "prodName"', + 'select "producttable_0".NAME as "prodName", count(distinct("root".quantity)) as "count", case when count(distinct("root".quantity)) = 1 then max("root".quantity) else null end as "uniqueValue" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) where ("producttable_0".NAME = \'Firm C\' and "root".quantity = CAST(45.0 AS FLOAT)) group by "prodName"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::groupBy::testUniqueValueOnly2():Boolean[1] @@ -1058,7 +1075,11 @@ function <> meta::relational::tests::groupBy::testUniqueValueOnly2(): assertEquals(['Firm C', 1, 45.0], $result.values.rows.values); - assertSameSQL('select "producttable_0".NAME as "prodName", count(distinct("root".quantity)) as "count", case when count(distinct("root".quantity)) = 1 then max("root".quantity) else -1 end as "uniqueValue" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) where ("producttable_0".NAME = \'Firm C\' and "root".quantity = 45.0) group by "prodName"', $result); + assertEqualsH2Compatible( + 'select "producttable_0".NAME as "prodName", count(distinct("root".quantity)) as "count", case when count(distinct("root".quantity)) = 1 then max("root".quantity) else -1 end as "uniqueValue" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) where ("producttable_0".NAME = \'Firm C\' and "root".quantity = 45.0) group by "prodName"', + 'select "producttable_0".NAME as "prodName", count(distinct("root".quantity)) as "count", case when count(distinct("root".quantity)) = 1 then max("root".quantity) else -1 end as "uniqueValue" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) where ("producttable_0".NAME = \'Firm C\' and "root".quantity = CAST(45.0 AS FLOAT)) group by "prodName"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::groupBy::testUniqueValueOnly3():Boolean[1] @@ -1167,7 +1188,7 @@ function <> meta::relational::tests::groupBy::testGro meta::relational::extension::relationalExtensions()); assertEquals(['Firm X|290.5|320.0|246.25', 'Firm C|44.6|38.0|44.0', 'Firm A|30.2|23.0|27.5', 'TDSNull|5.0|5.0|5.0'], $result.values.rows->map(r|$r.values->makeString('|'))); - assertSameSQL('select "producttable_0".NAME as "prodName", percentile_cont(0.9) within group (order by "root".quantity asc) as "p1", percentile_disc(0.5) within group (order by "root".quantity desc) as "p2", percentile_cont(0.75) within group (order by "root".quantity asc) as "p3" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', $result); + assertSameSQL('select "producttable_0".NAME as "prodName", percentile_cont(CAST(0.9 AS FLOAT)) within group (order by "root".quantity asc) as "p1", percentile_disc(CAST(0.5 AS FLOAT)) within group (order by "root".quantity desc) as "p2", percentile_cont(CAST(0.75 AS FLOAT)) within group (order by "root".quantity asc) as "p3" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', $result); } function <> meta::relational::tests::groupBy::testGroupByIsDistinct():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/tests/testGraphFetchMilestoning.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/tests/testGraphFetchMilestoning.pure index b9b0a1d93a3..80d55159d86 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/tests/testGraphFetchMilestoning.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/graphFetch/tests/testGraphFetchMilestoning.pure @@ -127,7 +127,7 @@ function <> {serverVersion.start='v1_19_0'} meta::rel ' (\n' + ' type = meta::pure::metamodel::type::Any\n' + ' resultColumns = [("parent_key_gen_0", INT), ("pk_0", INT), ("pk_1", VARCHAR(200)), ("name", VARCHAR(200)), ("type", VARCHAR(200)), ("k_businessDate", VARCHAR(10))]\n' + - ' sql = select distinct "temp_table_node_0_0".pk_0 as "parent_key_gen_0", "producttable_0".id as "pk_0", "producttable_0".name as "pk_1", "producttable_0".name as "name", "producttable_0".type as "type", \'2015-10-16\' as "k_businessDate" from (select * from (${temp_table_node_0}) as "root") as "temp_table_node_0_0" inner join OrderTable as "root" on ("temp_table_node_0_0".pk_0 = "root".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') where "producttable_0".name is not null and "producttable_0".id is not null and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\'\n' + + ' sql = select distinct "temp_table_node_0_0".pk_0 as "parent_key_gen_0", "producttable_0".id as "pk_0", "producttable_0".name as "pk_1", "producttable_0".name as "name", "producttable_0".type as "type", \'2015-10-16\' as "k_businessDate" from (select * from (${temp_table_node_0}) as "root") as "temp_table_node_0_0" inner join OrderTable as "root" on ("temp_table_node_0_0".pk_0 = "root".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') where "producttable_0".name is not null and "producttable_0".id is not null and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\'\n' + ' connection = TestDatabaseConnection(type = "H2")\n' + ' )\n' + ' children = [\n' + @@ -140,7 +140,7 @@ function <> {serverVersion.start='v1_19_0'} meta::rel ' (\n' + ' type = meta::pure::metamodel::type::Any\n' + ' resultColumns = [("parent_key_gen_0", INT), ("parent_key_gen_1", VARCHAR(200)), ("node_5_result", VARCHAR(200))]\n' + - ' sql = select distinct "temp_table_node_2_0".pk_0 as "parent_key_gen_0", "temp_table_node_2_0".pk_1 as "parent_key_gen_1", "productclassificationtable_0".type as "node_5_result" from (select * from (${temp_table_node_2}) as "root") as "temp_table_node_2_0" inner join ProductTable as "root" on ("temp_table_node_2_0".pk_1 = "root".name and "temp_table_node_2_0".pk_0 = "root".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) where "productclassificationtable_0".type is not null and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\'\n' + + ' sql = select distinct "temp_table_node_2_0".pk_0 as "parent_key_gen_0", "temp_table_node_2_0".pk_1 as "parent_key_gen_1", "productclassificationtable_0".type as "node_5_result" from (select * from (${temp_table_node_2}) as "root") as "temp_table_node_2_0" inner join ProductTable as "root" on ("temp_table_node_2_0".pk_1 = "root".name and "temp_table_node_2_0".pk_0 = "root".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) where "productclassificationtable_0".type is not null and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\'\n' + ' connection = TestDatabaseConnection(type = "H2")\n' + ' )\n' + ' children = [\n' + diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBiTemporalDateMilestoning.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBiTemporalDateMilestoning.pure index a0037d9abc3..3ee67402503 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBiTemporalDateMilestoning.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBiTemporalDateMilestoning.pure @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::relational::tests::*; import meta::relational::tests::milestoning::*; @@ -28,7 +30,11 @@ function <> meta::relational::tests::milestoning::bitemporal::testBiT assertEquals(1, $products->size()); assertEquals(%2017-6-10, $products->at(0).processingDate); assertEquals(%2017-6-9, $products->at(0).businessDate); - assertSameSQL('select "root".id as "pk_0", "root".id as "id", \'2017-06-10\' as "k_processingDate", \'2017-06-09\' as "k_businessDate" from BiTemporalProductTable as "root" where "root".in_z <= \'2017-06-10\' and "root".out_z > \'2017-06-10\' and "root".from_z <= \'2017-06-09\' and "root".thru_z > \'2017-06-09\'',$result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".id as "id", \'2017-06-10\' as "k_processingDate", \'2017-06-09\' as "k_businessDate" from BiTemporalProductTable as "root" where "root".in_z <= \'2017-06-10\' and "root".out_z > \'2017-06-10\' and "root".from_z <= \'2017-06-09\' and "root".thru_z > \'2017-06-09\'', + 'select "root".id as "pk_0", "root".id as "id", \'2017-06-10\' as "k_processingDate", \'2017-06-09\' as "k_businessDate" from BiTemporalProductTable as "root" where "root".in_z <= DATE\'2017-06-10\' and "root".out_z > DATE\'2017-06-10\' and "root".from_z <= DATE\'2017-06-09\' and "root".thru_z > DATE\'2017-06-09\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testBiTemporalPropertyUsageInProject():Boolean[1] @@ -36,7 +42,11 @@ function <> meta::relational::tests::milestoning::bitemporal::testBiT let result = execute(|Order.all()->project(o|$o.biTemporalProduct(%2017-6-10, %2017-6-9).id, 'prodId'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals( ['1', 'TDSNull'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "bitemporalproducttable_0".id as "prodId" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= \'2017-06-09\' and "bitemporalproducttable_0".thru_z > \'2017-06-09\'))', $result); + assertEqualsH2Compatible( + 'select "bitemporalproducttable_0".id as "prodId" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= \'2017-06-09\' and "bitemporalproducttable_0".thru_z > \'2017-06-09\'))', + 'select "bitemporalproducttable_0".id as "prodId" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= DATE\'2017-06-10\' and "bitemporalproducttable_0".out_z > DATE\'2017-06-10\' and "bitemporalproducttable_0".from_z <= DATE\'2017-06-09\' and "bitemporalproducttable_0".thru_z > DATE\'2017-06-09\'))', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testBiTemporalPropertyUsageInProjectPath():Boolean[1] @@ -44,7 +54,11 @@ function <> meta::relational::tests::milestoning::bitemporal::testBiT let result = execute(|Order.all()->project(#/Order/biTemporalProduct(%2017-6-10, %2017-6-9)/id#), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals( ['1', 'TDSNull'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "bitemporalproducttable_0".id as "id" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= \'2017-06-09\' and "bitemporalproducttable_0".thru_z > \'2017-06-09\'))', $result); + assertEqualsH2Compatible( + 'select "bitemporalproducttable_0".id as "id" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= \'2017-06-09\' and "bitemporalproducttable_0".thru_z > \'2017-06-09\'))', + 'select "bitemporalproducttable_0".id as "id" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= DATE\'2017-06-10\' and "bitemporalproducttable_0".out_z > DATE\'2017-06-10\' and "bitemporalproducttable_0".from_z <= DATE\'2017-06-09\' and "bitemporalproducttable_0".thru_z > DATE\'2017-06-09\'))', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testMultipleBiTemporalPropertyUsageInProject():Boolean[1] @@ -52,7 +66,11 @@ function <> meta::relational::tests::milestoning::bitemporal::testMul let result = execute(|Order.all()->project(o|$o.biTemporalProduct(%2017-6-10, %2017-6-9).biTemporalClassification(%2017-6-11, %2017-6-10).type, 'type'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['STOCK', 'TDSNull'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= \'2017-06-09\' and "bitemporalproducttable_0".thru_z > \'2017-06-09\')) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_1".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_1".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_1".thru_z > \'2017-06-10\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= \'2017-06-09\' and "bitemporalproducttable_0".thru_z > \'2017-06-09\')) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_1".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_1".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_1".thru_z > \'2017-06-10\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= DATE\'2017-06-10\' and "bitemporalproducttable_0".out_z > DATE\'2017-06-10\' and "bitemporalproducttable_0".from_z <= DATE\'2017-06-09\' and "bitemporalproducttable_0".thru_z > DATE\'2017-06-09\')) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= DATE\'2017-06-11\' and "bitemporalproductclassificationtable_1".out_z > DATE\'2017-06-11\' and "bitemporalproductclassificationtable_1".from_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtable_1".thru_z > DATE\'2017-06-10\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testMultipleBiTemporalPropertyUsageInProjectWithMilestoningInfinityNotSpecifiedInDB():Boolean[1] @@ -66,19 +84,31 @@ function <> meta::relational::tests::milestoning::bitemporal::testMul function <> meta::relational::tests::milestoning::bitemporal::testMultipleBiTemporalPropertyUsageInProjectWithMilestoningInfinitySpecifiedInDB():Boolean[1] { let result = execute(|Order.all()->project(o|$o.biTemporalProduct(%latest, %latest).biTemporalClassification(%latest, %latest).type, 'type'), latestbitemporalmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = DATE\'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testMultipleBiTemporalPropertyUsageInProjectPathWithMilestoningInfinitySpecifiedInDBPlusLatestPropagation():Boolean[1] { let result = execute(|Order.all()->project(#/Order/biTemporalProduct(%latest, %latest)/biTemporalClassification(%latest, %latest)/type#), latestbitemporalmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = DATE\'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testMultipleBiTemporalPropertyUsageInProjectWithMilestoningInfinitySpecifiedInDBPlusLatestPropagation():Boolean[1] { let result = execute(|Order.all()->project(o|$o.biTemporalProduct(%latest, %latest).biTemporalClassification.type, 'type'), latestbitemporalmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = DATE\'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testPopulationOfMilestonedThisBiTemporalDatesInProject():Boolean[1] @@ -86,10 +116,18 @@ function <> meta::relational::tests::milestoning::bitemporal::testPop let processingDate = %9999-12-31; let businessDate = %2015-10-16; let result = execute(|BiTemporalProduct.all($processingDate, $businessDate)->project([p|$p.id, p|$p.biTemporalClassificationType],['id','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "id", "bitemporalproductclassificationtable_0".type as "classificationType" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'9999-12-31\' and "bitemporalproductclassificationtable_0".out_z > \'9999-12-31\' and "bitemporalproductclassificationtable_0".from_z <= \'2015-10-16\' and "bitemporalproductclassificationtable_0".thru_z > \'2015-10-16\')) where "root".in_z <= \'9999-12-31\' and "root".out_z > \'9999-12-31\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "id", "bitemporalproductclassificationtable_0".type as "classificationType" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'9999-12-31\' and "bitemporalproductclassificationtable_0".out_z > \'9999-12-31\' and "bitemporalproductclassificationtable_0".from_z <= \'2015-10-16\' and "bitemporalproductclassificationtable_0".thru_z > \'2015-10-16\')) where "root".in_z <= \'9999-12-31\' and "root".out_z > \'9999-12-31\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "id", "bitemporalproductclassificationtable_0".type as "classificationType" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= DATE\'9999-12-31\' and "bitemporalproductclassificationtable_0".out_z > DATE\'9999-12-31\' and "bitemporalproductclassificationtable_0".from_z <= DATE\'2015-10-16\' and "bitemporalproductclassificationtable_0".thru_z > DATE\'2015-10-16\')) where "root".in_z <= DATE\'9999-12-31\' and "root".out_z > DATE\'9999-12-31\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); let result2 = execute(|BiTemporalProduct.all($processingDate, $businessDate)->project([p|$p.id, p|$p.biTemporalClassificationTypeWithIndirect],['id','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "id", "bitemporalproductclassificationtable_0".type as "classificationType" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'9999-12-31\' and "bitemporalproductclassificationtable_0".out_z > \'9999-12-31\' and "bitemporalproductclassificationtable_0".from_z <= \'2015-10-16\' and "bitemporalproductclassificationtable_0".thru_z > \'2015-10-16\')) where "root".in_z <= \'9999-12-31\' and "root".out_z > \'9999-12-31\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'',$result2); + assertEqualsH2Compatible( + 'select "root".id as "id", "bitemporalproductclassificationtable_0".type as "classificationType" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'9999-12-31\' and "bitemporalproductclassificationtable_0".out_z > \'9999-12-31\' and "bitemporalproductclassificationtable_0".from_z <= \'2015-10-16\' and "bitemporalproductclassificationtable_0".thru_z > \'2015-10-16\')) where "root".in_z <= \'9999-12-31\' and "root".out_z > \'9999-12-31\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "id", "bitemporalproductclassificationtable_0".type as "classificationType" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= DATE\'9999-12-31\' and "bitemporalproductclassificationtable_0".out_z > DATE\'9999-12-31\' and "bitemporalproductclassificationtable_0".from_z <= DATE\'2015-10-16\' and "bitemporalproductclassificationtable_0".thru_z > DATE\'2015-10-16\')) where "root".in_z <= DATE\'9999-12-31\' and "root".out_z > DATE\'9999-12-31\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result2->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testPopulationOfMilestonedThisBiTemporalDatesInProjectAgainstNonMilestonedStore():Boolean[1] @@ -106,7 +144,11 @@ function <> meta::relational::tests::milestoning::bitemporal::propaga let result = execute(|BiTemporalProduct.all(%2017-6-11, %2017-6-10)->project([p|$p.name, p|$p.biTemporalClassification.type], ['productName', 'classificationType']), singleTemporalMappingForBiTemporalTypes, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['ProductName2,STOCK', 'ProductName3,TDSNull'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "productName", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and ("productclassificationtable_0".from_z <= \'2017-06-10\' and "productclassificationtable_0".thru_z > \'2017-06-10\')) where "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "productName", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and ("productclassificationtable_0".from_z <= \'2017-06-10\' and "productclassificationtable_0".thru_z > \'2017-06-10\')) where "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', + 'select "root".name as "productName", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and ("productclassificationtable_0".from_z <= DATE\'2017-06-10\' and "productclassificationtable_0".thru_z > DATE\'2017-06-10\')) where "root".from_z <= DATE\'2017-06-10\' and "root".thru_z > DATE\'2017-06-10\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::propagation::testBiTemporalToBiTemporalDatePropagation():Boolean[1] @@ -114,7 +156,11 @@ function <> meta::relational::tests::milestoning::bitemporal::propaga let result = execute(|Order.all()->project(o|$o.biTemporalProduct(%2017-6-11, %2017-6-10).biTemporalClassification.type, 'type'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['STOCK', 'TDSNull'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-11\' and "bitemporalproducttable_0".out_z > \'2017-06-11\' and "bitemporalproducttable_0".from_z <= \'2017-06-10\' and "bitemporalproducttable_0".thru_z > \'2017-06-10\')) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_1".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_1".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_1".thru_z > \'2017-06-10\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-11\' and "bitemporalproducttable_0".out_z > \'2017-06-11\' and "bitemporalproducttable_0".from_z <= \'2017-06-10\' and "bitemporalproducttable_0".thru_z > \'2017-06-10\')) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_1".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_1".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_1".thru_z > \'2017-06-10\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= DATE\'2017-06-11\' and "bitemporalproducttable_0".out_z > DATE\'2017-06-11\' and "bitemporalproducttable_0".from_z <= DATE\'2017-06-10\' and "bitemporalproducttable_0".thru_z > DATE\'2017-06-10\')) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= DATE\'2017-06-11\' and "bitemporalproductclassificationtable_1".out_z > DATE\'2017-06-11\' and "bitemporalproductclassificationtable_1".from_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtable_1".thru_z > DATE\'2017-06-10\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::propagation::testBiTemporalToBiTemporalDatePropagationForAll():Boolean[1] @@ -122,7 +168,11 @@ function <> meta::relational::tests::milestoning::bitemporal::propaga let result = execute(|BiTemporalProduct.all(%2017-6-11, %2017-6-10)->project(o|$o.biTemporalClassification.type, 'type'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['STOCK'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_0".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-10\')) where "root".in_z <= \'2017-06-11\' and "root".out_z > \'2017-06-11\' and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_0".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-10\')) where "root".in_z <= \'2017-06-11\' and "root".out_z > \'2017-06-11\' and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', + 'select "bitemporalproductclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= DATE\'2017-06-11\' and "bitemporalproductclassificationtable_0".out_z > DATE\'2017-06-11\' and "bitemporalproductclassificationtable_0".from_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > DATE\'2017-06-10\')) where "root".in_z <= DATE\'2017-06-11\' and "root".out_z > DATE\'2017-06-11\' and "root".from_z <= DATE\'2017-06-10\' and "root".thru_z > DATE\'2017-06-10\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::propagation::testBiTemporalToBiTemporalSingleDatePropagationForAll():Boolean[1] @@ -130,7 +180,11 @@ function <> meta::relational::tests::milestoning::bitemporal::propaga let result = execute(|BiTemporalProduct.all(%2017-6-11, %2017-6-10)->project(o|$o.biTemporalClassification(%2017-6-12).type, 'type'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['STOCK'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_0".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-12\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-12\')) where "root".in_z <= \'2017-06-11\' and "root".out_z > \'2017-06-11\' and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_0".out_z > \'2017-06-11\' and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-12\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-12\')) where "root".in_z <= \'2017-06-11\' and "root".out_z > \'2017-06-11\' and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', + 'select "bitemporalproductclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= DATE\'2017-06-11\' and "bitemporalproductclassificationtable_0".out_z > DATE\'2017-06-11\' and "bitemporalproductclassificationtable_0".from_z <= DATE\'2017-06-12\' and "bitemporalproductclassificationtable_0".thru_z > DATE\'2017-06-12\')) where "root".in_z <= DATE\'2017-06-11\' and "root".out_z > DATE\'2017-06-11\' and "root".from_z <= DATE\'2017-06-10\' and "root".thru_z > DATE\'2017-06-10\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::propagation::testBiTemporalToSingleSingleTemporalDatePropagation():Boolean[1] @@ -138,7 +192,11 @@ function <> meta::relational::tests::milestoning::bitemporal::propaga let result = execute(|BiTemporalProduct.all(%2017-6-11, %2017-6-10)->project(p|$p.classification.type, 'type'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['STOCK'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "productclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2017-06-10\' and "productclassificationtable_0".thru_z > \'2017-06-10\') where "root".in_z <= \'2017-06-11\' and "root".out_z > \'2017-06-11\' and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', $result); + assertEqualsH2Compatible( + 'select "productclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2017-06-10\' and "productclassificationtable_0".thru_z > \'2017-06-10\') where "root".in_z <= \'2017-06-11\' and "root".out_z > \'2017-06-11\' and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', + 'select "productclassificationtable_0".type as "type" from BiTemporalProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2017-06-10\' and "productclassificationtable_0".thru_z > DATE\'2017-06-10\') where "root".in_z <= DATE\'2017-06-11\' and "root".out_z > DATE\'2017-06-11\' and "root".from_z <= DATE\'2017-06-10\' and "root".thru_z > DATE\'2017-06-10\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::propagation::testBusinessToBiTemporalDatePropagation():Boolean[1] @@ -146,7 +204,11 @@ function <> meta::relational::tests::milestoning::bitemporal::propaga let result = execute(|Product.all(%9999-12-29)->project([p|$p.name, p|$p.biTemporalClassification(%9999-12-30).type], ['name', 'type']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['ProductName2,STOCK', 'ProductName3,TDSNull'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "bitemporalproductclassificationtable_0".type as "type" from ProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'9999-12-30\' and "bitemporalproductclassificationtable_0".out_z > \'9999-12-30\' and "bitemporalproductclassificationtable_0".from_z <= \'9999-12-29\' and "bitemporalproductclassificationtable_0".thru_z > \'9999-12-29\')) where "root".from_z <= \'9999-12-29\' and "root".thru_z > \'9999-12-29\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "bitemporalproductclassificationtable_0".type as "type" from ProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= \'9999-12-30\' and "bitemporalproductclassificationtable_0".out_z > \'9999-12-30\' and "bitemporalproductclassificationtable_0".from_z <= \'9999-12-29\' and "bitemporalproductclassificationtable_0".thru_z > \'9999-12-29\')) where "root".from_z <= \'9999-12-29\' and "root".thru_z > \'9999-12-29\'', + 'select "root".name as "name", "bitemporalproductclassificationtable_0".type as "type" from ProductTable as "root" left outer join BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_0" on ("root".type = "bitemporalproductclassificationtable_0".type and ("bitemporalproductclassificationtable_0".in_z <= DATE\'9999-12-30\' and "bitemporalproductclassificationtable_0".out_z > DATE\'9999-12-30\' and "bitemporalproductclassificationtable_0".from_z <= DATE\'9999-12-29\' and "bitemporalproductclassificationtable_0".thru_z > DATE\'9999-12-29\')) where "root".from_z <= DATE\'9999-12-29\' and "root".thru_z > DATE\'9999-12-29\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::propagation::testProcessingToBiTemporalDatePropagation():Boolean[1] @@ -154,19 +216,31 @@ function <> meta::relational::tests::milestoning::bitemporal::propaga let result = execute(|Trader.all(%2015-10-16)->project([t|$t.kerberos, t|$t.location(%9999-12-28).place], ['traderName', 'traderLocation']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['ggekko,miami', 'bfox,TDSNull'], $tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".kerberos as "traderName", "bitemporallocationtable_0".PLACE as "traderLocation" from TraderTable as "root" left outer join BiTemporalLocationTable as "bitemporallocationtable_0" on ("root".kerberos = "bitemporallocationtable_0".kerberos and ("bitemporallocationtable_0".in_z <= \'2015-10-16\' and "bitemporallocationtable_0".out_z > \'2015-10-16\' and "bitemporallocationtable_0".from_z <= \'9999-12-28\' and "bitemporallocationtable_0".thru_z > \'9999-12-28\')) where "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".kerberos as "traderName", "bitemporallocationtable_0".PLACE as "traderLocation" from TraderTable as "root" left outer join BiTemporalLocationTable as "bitemporallocationtable_0" on ("root".kerberos = "bitemporallocationtable_0".kerberos and ("bitemporallocationtable_0".in_z <= \'2015-10-16\' and "bitemporallocationtable_0".out_z > \'2015-10-16\' and "bitemporallocationtable_0".from_z <= \'9999-12-28\' and "bitemporallocationtable_0".thru_z > \'9999-12-28\')) where "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'', + 'select "root".kerberos as "traderName", "bitemporallocationtable_0".PLACE as "traderLocation" from TraderTable as "root" left outer join BiTemporalLocationTable as "bitemporallocationtable_0" on ("root".kerberos = "bitemporallocationtable_0".kerberos and ("bitemporallocationtable_0".in_z <= DATE\'2015-10-16\' and "bitemporallocationtable_0".out_z > DATE\'2015-10-16\' and "bitemporallocationtable_0".from_z <= DATE\'9999-12-28\' and "bitemporallocationtable_0".thru_z > DATE\'9999-12-28\')) where "root".in_z <= DATE\'2015-10-16\' and "root".out_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testBiTemporalToBiTemporalProjectWithMilestoningInfinitySpecifiedInDB():Boolean[1] { let result = execute(|Order.all()->project(o|$o.biTemporalProduct(%latest, %latest).biTemporalClassification.type, 'type'), latestbitemporalmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = \'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = DATE\'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testBiTemporalToBiTemporalProcessingDateProjectWithMilestoningInfinitySpecifiedInDB():Boolean[1] { let result = execute(|Order.all()->project(o|$o.biTemporalProduct(%latest, %latest).biTemporalClassification(%2017-6-10).type, 'type'), latestbitemporalmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtablewithlatest_1".thru_z > \'2017-06-10\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', $result); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = \'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = \'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtablewithlatest_1".thru_z > \'2017-06-10\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + 'select "bitemporalproductclassificationtablewithlatest_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTableWithLatest as "bitemporalproducttablewithlatest_0" on ("root".prodFk = "bitemporalproducttablewithlatest_0".id and ("bitemporalproducttablewithlatest_0".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproducttablewithlatest_0".thru_z = DATE\'9999-12-31\')) left outer join (select "bitemporalproductclassificationtablewithlatest_1".type as type from BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_1" where ("bitemporalproductclassificationtablewithlatest_1".out_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "bitemporalproductclassificationtablewithlatest_1".from_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtablewithlatest_1".thru_z > DATE\'2017-06-10\')) as "bitemporalproductclassificationtablewithlatest_0" on ("bitemporalproducttablewithlatest_0".type = "bitemporalproductclassificationtablewithlatest_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testBiTemporalPropertyUsageAfterExecute():Boolean[1] @@ -186,7 +260,11 @@ function <> {meta::pure::executionPlan::profiles::serverVersion.start ['type','count']), meta::relational::tests::milestoning::latestbitemporalmap, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); // let tds = $result.values->toOne(); - assertSameSQL('select "root".id as "type", count("bitemporalproductclassificationtablewithlatest_0".type) as "count" from BiTemporalProductTableWithLatest as "root" left outer join BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_0" on ("root".type = "bitemporalproductclassificationtablewithlatest_0".type and ("bitemporalproductclassificationtablewithlatest_0".in_z <= \'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".out_z > \'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".from_z <= \'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".thru_z > \'2020-06-03 20:40:14.761\')) where "root".in_z <= \'2020-08-08\' and "root".out_z > \'2020-08-08\' and "root".from_z <= \'2020-08-08\' and "root".thru_z > \'2020-08-08\' group by "type"', $result); + assertEqualsH2Compatible( + 'select "root".id as "type", count("bitemporalproductclassificationtablewithlatest_0".type) as "count" from BiTemporalProductTableWithLatest as "root" left outer join BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_0" on ("root".type = "bitemporalproductclassificationtablewithlatest_0".type and ("bitemporalproductclassificationtablewithlatest_0".in_z <= \'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".out_z > \'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".from_z <= \'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".thru_z > \'2020-06-03 20:40:14.761\')) where "root".in_z <= \'2020-08-08\' and "root".out_z > \'2020-08-08\' and "root".from_z <= \'2020-08-08\' and "root".thru_z > \'2020-08-08\' group by "type"', + 'select "root".id as "type", count("bitemporalproductclassificationtablewithlatest_0".type) as "count" from BiTemporalProductTableWithLatest as "root" left outer join BiTemporalProductClassificationTableWithLatest as "bitemporalproductclassificationtablewithlatest_0" on ("root".type = "bitemporalproductclassificationtablewithlatest_0".type and ("bitemporalproductclassificationtablewithlatest_0".in_z <= TIMESTAMP\'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".out_z > TIMESTAMP\'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".from_z <= TIMESTAMP\'2020-06-03 20:40:14.761\' and "bitemporalproductclassificationtablewithlatest_0".thru_z > TIMESTAMP\'2020-06-03 20:40:14.761\')) where "root".in_z <= DATE\'2020-08-08\' and "root".out_z > DATE\'2020-08-08\' and "root".from_z <= DATE\'2020-08-08\' and "root".thru_z > DATE\'2020-08-08\' group by "type"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::bitemporal::testBiTemporalDateInjectionFromVarReference():Boolean[1] @@ -198,8 +276,24 @@ function <> meta::relational::tests::milestoning::bitemporal::testBiT let result5 = execute(|Order.all()->project(o|$o.biTemporalProduct($o.orderDate->toOne(), %2017-6-10).biTemporalClassification.type, 'type'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= "root".orderDate and "bitemporalproductclassificationtable_0".out_z > "root".orderDate and "bitemporalproductclassificationtable_0".from_z <= "root".orderDate and "bitemporalproductclassificationtable_0".thru_z > "root".orderDate) and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)',$result1); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= "root".orderDate and "bitemporalproductclassificationtable_0".out_z > "root".orderDate and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-10\') and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)',$result2); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_1".out_z > \'2017-06-10\' and "bitemporalproductclassificationtable_1".from_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_1".thru_z > \'2017-06-11\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)',$result3); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".out_z > \'2017-06-10\' and "bitemporalproductclassificationtable_0".from_z <= "root".orderDate and "bitemporalproductclassificationtable_0".thru_z > "root".orderDate) and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)',$result4); - assertSameSQL('select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= \'2017-06-10\' and "bitemporalproducttable_0".thru_z > \'2017-06-10\')) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= "root".orderDate and "bitemporalproductclassificationtable_0".out_z > "root".orderDate and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-10\') and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)',$result5); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= "root".orderDate and "bitemporalproductclassificationtable_0".out_z > "root".orderDate and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-10\') and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= "root".orderDate and "bitemporalproductclassificationtable_0".out_z > "root".orderDate and "bitemporalproductclassificationtable_0".from_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > DATE\'2017-06-10\') and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + $result2->sqlRemoveFormatting() + ); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_1".out_z > \'2017-06-10\' and "bitemporalproductclassificationtable_1".from_z <= \'2017-06-11\' and "bitemporalproductclassificationtable_1".thru_z > \'2017-06-11\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1" where ("bitemporalproductclassificationtable_1".in_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtable_1".out_z > DATE\'2017-06-10\' and "bitemporalproductclassificationtable_1".from_z <= DATE\'2017-06-11\' and "bitemporalproductclassificationtable_1".thru_z > DATE\'2017-06-11\')) as "bitemporalproductclassificationtable_0" on ("bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + $result3->sqlRemoveFormatting() + ); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= \'2017-06-10\' and "bitemporalproducttable_0".out_z > \'2017-06-10\' and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".out_z > \'2017-06-10\' and "bitemporalproductclassificationtable_0".from_z <= "root".orderDate and "bitemporalproductclassificationtable_0".thru_z > "root".orderDate) and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= DATE\'2017-06-10\' and "bitemporalproducttable_0".out_z > DATE\'2017-06-10\' and "bitemporalproducttable_0".from_z <= "root".orderDate and "bitemporalproducttable_0".thru_z > "root".orderDate)) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtable_0".out_z > DATE\'2017-06-10\' and "bitemporalproductclassificationtable_0".from_z <= "root".orderDate and "bitemporalproductclassificationtable_0".thru_z > "root".orderDate) and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + $result4->sqlRemoveFormatting() + ); + assertEqualsH2Compatible( + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= \'2017-06-10\' and "bitemporalproducttable_0".thru_z > \'2017-06-10\')) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= "root".orderDate and "bitemporalproductclassificationtable_0".out_z > "root".orderDate and "bitemporalproductclassificationtable_0".from_z <= \'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > \'2017-06-10\') and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + 'select "bitemporalproductclassificationtable_0".type as "type" from OrderTable as "root" left outer join BiTemporalProductTable as "bitemporalproducttable_0" on ("root".prodFk = "bitemporalproducttable_0".id and ("bitemporalproducttable_0".in_z <= "root".orderDate and "bitemporalproducttable_0".out_z > "root".orderDate and "bitemporalproducttable_0".from_z <= DATE\'2017-06-10\' and "bitemporalproducttable_0".thru_z > DATE\'2017-06-10\')) left outer join (select "bitemporalproductclassificationtable_1".type as type, "bitemporalproductclassificationtable_1".in_z as in_z, "bitemporalproductclassificationtable_1".out_z as out_z, "bitemporalproductclassificationtable_1".from_z as from_z, "bitemporalproductclassificationtable_1".thru_z as thru_z from BiTemporalProductClassificationTable as "bitemporalproductclassificationtable_1") as "bitemporalproductclassificationtable_0" on (("bitemporalproductclassificationtable_0".in_z <= "root".orderDate and "bitemporalproductclassificationtable_0".out_z > "root".orderDate and "bitemporalproductclassificationtable_0".from_z <= DATE\'2017-06-10\' and "bitemporalproductclassificationtable_0".thru_z > DATE\'2017-06-10\') and "bitemporalproducttable_0".type = "bitemporalproductclassificationtable_0".type)', + $result5->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessDateMilestoning.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessDateMilestoning.pure index 092a722f989..b8b6fd3aa06 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessDateMilestoning.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessDateMilestoning.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::executionPlan::*; import meta::relational::validation::*; import meta::pure::executionPlan::toString::*; @@ -37,28 +38,44 @@ function <> meta::relational::tests::milestoning::businessdate::testC { let busDate = %2015-10-16; let result = validate(|ProductWithConstraint1.all($busDate),meta::relational::tests::milestoning::milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure property: systemDescription is processed with the correct milestoning date, note that there are no milestoning properties on its left through which a date could be propagated\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= \'2015-10-16\' and "systemdescriptiontable_0".thru_z > \'2015-10-16\') where not char_length("systemdescriptiontable_0".description) < 10 and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure property: systemDescription is processed with the correct milestoning date, note that there are no milestoning properties on its left through which a date could be propagated\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= \'2015-10-16\' and "systemdescriptiontable_0".thru_z > \'2015-10-16\') where not char_length("systemdescriptiontable_0".description) < 10 and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure property: systemDescription is processed with the correct milestoning date, note that there are no milestoning properties on its left through which a date could be propagated\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= DATE\'2015-10-16\' and "systemdescriptiontable_0".thru_z > DATE\'2015-10-16\') where not char_length("systemdescriptiontable_0".description) < 10 and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testConstraintUsageOfThisMilestoningContext1b():Boolean[1] { let busDate = %2015-10-16;//parent milestoning context not propagated through map let result = validate(|ProductWithConstraint1b.all($busDate),meta::relational::tests::milestoning::milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure Ensure parent (this) milestoning context propagated through (auto) map\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= \'2015-10-16\' and "systemdescriptiontable_0".thru_z > \'2015-10-16\') where not char_length("systemdescriptiontable_0".description) < 10 and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure Ensure parent (this) milestoning context propagated through (auto) map\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= \'2015-10-16\' and "systemdescriptiontable_0".thru_z > \'2015-10-16\') where not char_length("systemdescriptiontable_0".description) < 10 and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure Ensure parent (this) milestoning context propagated through (auto) map\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= DATE\'2015-10-16\' and "systemdescriptiontable_0".thru_z > DATE\'2015-10-16\') where not char_length("systemdescriptiontable_0".description) < 10 and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testConstraintUsageOfThisMilestoningContext1c():Boolean[1] { let busDate = %2015-10-16; let result = validate(|ProductWithConstraint1c.all($busDate),meta::relational::tests::milestoning::milestoningmapwithconstraints, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure parent (this) milestoning context propagated through project\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" where not (not (not exists(select 1 from SystemTable as "systemtable_0" left outer join (select "systemdescriptiontable_1".systemName as systemName, "systemdescriptiontable_1".description as description from SystemDescriptionTable as "systemdescriptiontable_1" where "systemdescriptiontable_1".from_z <= \'2015-10-16\' and "systemdescriptiontable_1".thru_z > \'2015-10-16\') as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".referenceSystemName = "systemtable_0".name))) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure parent (this) milestoning context propagated through project\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" where not (not (not exists(select 1 from SystemTable as "systemtable_0" left outer join (select "systemdescriptiontable_1".systemName as systemName, "systemdescriptiontable_1".description as description from SystemDescriptionTable as "systemdescriptiontable_1" where "systemdescriptiontable_1".from_z <= \'2015-10-16\' and "systemdescriptiontable_1".thru_z > \'2015-10-16\') as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".referenceSystemName = "systemtable_0".name))) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure parent (this) milestoning context propagated through project\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" where not (not (not exists(select 1 from SystemTable as "systemtable_0" left outer join (select "systemdescriptiontable_1".systemName as systemName, "systemdescriptiontable_1".description as description from SystemDescriptionTable as "systemdescriptiontable_1" where "systemdescriptiontable_1".from_z <= DATE\'2015-10-16\' and "systemdescriptiontable_1".thru_z > DATE\'2015-10-16\') as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".referenceSystemName = "systemtable_0".name))) and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testConstraintUsageOfThisMilestoningContext2():Boolean[1] { let busDate = %2015-10-16; let result = validate(|ProductWithConstraint2.all($busDate),meta::relational::tests::milestoning::milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure property: exchange is processed with the correct milestoning date, and that the milestoning property on the left (classification) is not propagagted\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2019-01-01\' and "productclassificationtable_0".thru_z > \'2019-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where not char_length("productexchangetable_0".name) is null and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure property: exchange is processed with the correct milestoning date, and that the milestoning property on the left (classification) is not propagagted\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2019-01-01\' and "productclassificationtable_0".thru_z > \'2019-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where not char_length("productexchangetable_0".name) is null and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure property: exchange is processed with the correct milestoning date, and that the milestoning property on the left (classification) is not propagagted\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2019-01-01\' and "productclassificationtable_0".thru_z > DATE\'2019-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where not char_length("productexchangetable_0".name) is null and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testConstraintUsageOfThisMilestoningContext2WithNonTemporalStore():Boolean[1] @@ -72,7 +89,11 @@ function <> meta::relational::tests::milestoning::businessdate::testC { let busDate = %2015-10-16; let result = validate(|ProductWithConstraint3.all($busDate),meta::relational::tests::milestoning::milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure that milestoning qualified properties passed function arguments which reference $this.temporalDate are processed correctly\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'2015-10-16\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'2015-10-16\')) left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where ("productexchangetable_0".name <> \'exchangeName\' OR "productexchangetable_0".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure that milestoning qualified properties passed function arguments which reference $this.temporalDate are processed correctly\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'2015-10-16\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'2015-10-16\')) left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where ("productexchangetable_0".name <> \'exchangeName\' OR "productexchangetable_0".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Ensure that milestoning qualified properties passed function arguments which reference $this.temporalDate are processed correctly\' as "MESSAGE", "root".id as "id", "root".name as "name" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, DATE\'2015-10-16\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, DATE\'2015-10-16\')) left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where ("productexchangetable_0".name <> \'exchangeName\' OR "productexchangetable_0".name is null) and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testConstraintUsageOfVarReferenceWithThisMilestoningContext():Boolean[1] @@ -88,12 +109,20 @@ function <> meta::relational::tests::milestoning::businessdate::testP let result = execute(|Product.all($busDate)->project([p|$p.name, p|$p.classificationTypeStr],['name','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); let result2 = execute(|Order.all()->project([o|$o.id, o|$o.product($busDate).name, o|$o.product($busDate).classificationType],['orderId','productName','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds2 = $result2.values->at(0); assertEquals(['1,TDSNull,TDSNull', '2,ProductName2,STOCK'],$tds2.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "producttable_0".name as "productName", "productclassificationtable_0".type as "classificationType" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "productclassificationtable_1".type as type from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)',$result2); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "producttable_0".name as "productName", "productclassificationtable_0".type as "classificationType" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "productclassificationtable_1".type as type from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', + 'select "root".id as "orderId", "producttable_0".name as "productName", "productclassificationtable_0".type as "classificationType" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') left outer join (select "productclassificationtable_1".type as type from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', + $result2->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestonedThisBusinessDateInPosition1InQualfiedPropertySequence():Boolean[1] @@ -101,7 +130,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let busDate = %2015-10-16; let result = execute(|Product.all($busDate)->project([p|$p.name, p|$p.classificationExchangeName1],['name','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); - assertSameSQL('select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2019-01-01\' and "productexchangetable_1".thru_z > \'2019-01-01\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2019-01-01\' and "productexchangetable_1".thru_z > \'2019-01-01\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= DATE\'2019-01-01\' and "productexchangetable_1".thru_z > DATE\'2019-01-01\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestonedThisBusinessDateInPosition2InQualfiedPropertySequence():Boolean[1] @@ -109,7 +142,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let busDate = %2015-10-16; let result = execute(|Product.all($busDate)->project([p|$p.name, p|$p.classificationExchangeName2],['name','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); - assertSameSQL('select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2019-01-01\' and "productclassificationtable_0".thru_z > \'2019-01-01\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2015-10-16\' and "productexchangetable_1".thru_z > \'2015-10-16\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2019-01-01\' and "productclassificationtable_0".thru_z > \'2019-01-01\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2015-10-16\' and "productexchangetable_1".thru_z > \'2015-10-16\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2019-01-01\' and "productclassificationtable_0".thru_z > DATE\'2019-01-01\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= DATE\'2015-10-16\' and "productexchangetable_1".thru_z > DATE\'2015-10-16\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestonedThisBusinessDateUsedAsParameterToFunctionParametersOfMilestonedQualifiedProperty():Boolean[1] @@ -117,7 +154,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let busDate = %2015-10-16; let result = execute(|Product.all($busDate)->project([p|$p.name, p|$p.classificationExchangeName3],['name','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); - assertSameSQL('select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'2015-10-16\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'2015-10-16\')) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= dateadd(DAY, 1, \'2015-10-16\') and "productexchangetable_1".thru_z > dateadd(DAY, 1, \'2015-10-16\')) as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, \'2015-10-16\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, \'2015-10-16\')) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= dateadd(DAY, 1, \'2015-10-16\') and "productexchangetable_1".thru_z > dateadd(DAY, 1, \'2015-10-16\')) as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productexchangetable_0".name as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= dateadd(DAY, 1, DATE\'2015-10-16\') and "productclassificationtable_0".thru_z > dateadd(DAY, 1, DATE\'2015-10-16\')) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= dateadd(DAY, 1, DATE\'2015-10-16\') and "productexchangetable_1".thru_z > dateadd(DAY, 1, DATE\'2015-10-16\')) as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestonedThisBusinessDateUsedAsParameterToFunctionInMilestoningQualifiedPropertyMappedToView():Boolean[1] @@ -125,7 +166,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let connection = testRuntime().connections->filter(c|$c->instanceOf(DatabaseConnection))->first()->toOne()->cast(@TestDatabaseConnection); let busDate = %2015-10-16; let result = validate(|OrderPnlWithConstraint.all($busDate),meta::relational::tests::milestoning::ViewChainMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Constraint to ensure that $this.businessDate milestoning property is processed correctly when mapped to a View\' as "MESSAGE", "root".ID as "ID" from orderPNL as "root" left outer join (select "intermediate_1".joinId as joinId, "producttableview_0".link as link from intermediate as "intermediate_1" inner join (select "root".joinId as j, "root".linkToProduct as l, "root".type as n, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from intermediateTwo as "root") as "intertwoview_0" on ("intermediate_1".joinId = "intertwoview_0".j) left outer join (select "root".name as name, "root".type as type, "root".ID as link, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from ProductTable as "root") as "producttableview_0" on ("intertwoview_0".l = "producttableview_0".link)) as "intermediate_0" on ("root".ID = "intermediate_0".joinId) left outer join (select "intermediate_3".joinId as joinId, "intertwoview_1".l as l from intermediate as "intermediate_3" inner join (select "root".joinId as j, "root".linkToProduct as l, "root".type as n, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from intermediateTwo as "root") as "intertwoview_1" on ("intermediate_3".joinId = "intertwoview_1".j)) as "intermediate_2" on ("root".ID = "intermediate_2".joinId) left outer join (select "root".name as name, "root".type as type, "root".ID as link, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from ProductTable as "root") as "producttableview_1" on ("intermediate_2".l = "producttableview_1".link) where not ("intermediate_0".link is not null and "producttableview_1".link > 0)',$result); + assertEqualsH2Compatible( + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Constraint to ensure that $this.businessDate milestoning property is processed correctly when mapped to a View\' as "MESSAGE", "root".ID as "ID" from orderPNL as "root" left outer join (select "intermediate_1".joinId as joinId, "producttableview_0".link as link from intermediate as "intermediate_1" inner join (select "root".joinId as j, "root".linkToProduct as l, "root".type as n, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from intermediateTwo as "root") as "intertwoview_0" on ("intermediate_1".joinId = "intertwoview_0".j) left outer join (select "root".name as name, "root".type as type, "root".ID as link, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from ProductTable as "root") as "producttableview_0" on ("intertwoview_0".l = "producttableview_0".link)) as "intermediate_0" on ("root".ID = "intermediate_0".joinId) left outer join (select "intermediate_3".joinId as joinId, "intertwoview_1".l as l from intermediate as "intermediate_3" inner join (select "root".joinId as j, "root".linkToProduct as l, "root".type as n, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from intermediateTwo as "root") as "intertwoview_1" on ("intermediate_3".joinId = "intertwoview_1".j)) as "intermediate_2" on ("root".ID = "intermediate_2".joinId) left outer join (select "root".name as name, "root".type as type, "root".ID as link, dateadd(DAY, -1, \'2015-10-16\') as "k_businessDate" from ProductTable as "root") as "producttableview_1" on ("intermediate_2".l = "producttableview_1".link) where not ("intermediate_0".link is not null and "producttableview_1".link > 0)', + 'select \'CST\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'Constraint to ensure that $this.businessDate milestoning property is processed correctly when mapped to a View\' as "MESSAGE", "root".ID as "ID" from orderPNL as "root" left outer join (select "intermediate_1".joinId as joinId, "producttableview_0".link as link from intermediate as "intermediate_1" inner join (select "root".joinId as j, "root".linkToProduct as l, "root".type as n, dateadd(DAY, -1, DATE\'2015-10-16\') as "k_businessDate" from intermediateTwo as "root") as "intertwoview_0" on ("intermediate_1".joinId = "intertwoview_0".j) left outer join (select "root".name as name, "root".type as type, "root".ID as link, dateadd(DAY, -1, DATE\'2015-10-16\') as "k_businessDate" from ProductTable as "root") as "producttableview_0" on ("intertwoview_0".l = "producttableview_0".link)) as "intermediate_0" on ("root".ID = "intermediate_0".joinId) left outer join (select "intermediate_3".joinId as joinId, "intertwoview_1".l as l from intermediate as "intermediate_3" inner join (select "root".joinId as j, "root".linkToProduct as l, "root".type as n, dateadd(DAY, -1, DATE\'2015-10-16\') as "k_businessDate" from intermediateTwo as "root") as "intertwoview_1" on ("intermediate_3".joinId = "intertwoview_1".j)) as "intermediate_2" on ("root".ID = "intermediate_2".joinId) left outer join (select "root".name as name, "root".type as type, "root".ID as link, dateadd(DAY, -1, DATE\'2015-10-16\') as "k_businessDate" from ProductTable as "root") as "producttableview_1" on ("intermediate_2".l = "producttableview_1".link) where not ("intermediate_0".link is not null and "producttableview_1".link > 0)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestonedQualifiedPropertyWithDateProvidedByFunction():Boolean[1] @@ -133,7 +178,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let busDate = %2015-10-16; let result = execute(|Product.all($busDate)->project([p|$p.name, p|$p.classification(constantDate()).type],['name','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-01-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-01-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-01-01\' and "productclassificationtable_0".thru_z > DATE\'2015-01-01\') where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testViewChainsWithBusinessDate():Boolean[1] @@ -159,7 +208,11 @@ function <> meta::relational::tests::milestoning::latestDate::testPop let products = $result.values; assertEquals([2,3], $products.id); assertEquals([%9999-12-31T00:00:00.0000+0000, %9999-12-31T00:00:00.0000+0000], $products.businessDate); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') where "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') where "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') where "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testPopulationOfMilestonedBusinessDateWithTimeComponentInQuery():Boolean[1] @@ -184,13 +237,21 @@ function <> meta::relational::tests::milestoning::businessdate::testQ let products = $result.values; assertEquals(1, $products->size()); assertEquals([2], $products->map(p|$p.id)); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" where "root".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'',$result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" where "root".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" where "root".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::latestDate::testQueryOfMilestonedTypeUsingLatestWithFilterInMapping():Boolean[1] { let result = execute(|StockProduct.all(%latest), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" where "root".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'',$result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" where "root".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" where "root".type = \'STOCK\' and "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningQueryWithMilestoneFilterANdDifferentDatesOnTypeAndProperty():Boolean[1] @@ -200,14 +261,22 @@ function <> meta::relational::tests::milestoning::businessdate::testM let products = $result.values; assertEquals(1, $products->size()); assertEquals('ProductName2', $products->at(0).name); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-17\' and "productexchangetable_0".thru_z > DATE\'2015-10-17\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::latestDate::testMilestoningQueryWithMilestoneFilterAndDifferentDatesOnTypeWithLatestDateOnProperty():Boolean[1] { let date = %2015-10-15; let result = execute(|Product.all($date)->filter(p|$p.classification(%2015-10-16).type=='STOCK' && $p.exchange(%latest).name=='LNSE'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-15\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-15\' and "stockproducttable_0".thru_z > \'2015-10-15\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-15\' and "productclassificationtable_0".thru_z > \'2015-10-15\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".thru_z = \'9999-12-31 00:00:00.0000\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-15\' and "root".thru_z > \'2015-10-15\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-15\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-15\' and "stockproducttable_0".thru_z > \'2015-10-15\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-15\' and "productclassificationtable_0".thru_z > \'2015-10-15\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".thru_z = \'9999-12-31 00:00:00.0000\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-15\' and "root".thru_z > \'2015-10-15\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-15\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-15\' and "stockproducttable_0".thru_z > DATE\'2015-10-15\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-15\' and "productclassificationtable_0".thru_z > DATE\'2015-10-15\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-15\' and "root".thru_z > DATE\'2015-10-15\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningQueryWithMultipleChildrenFromParentAsSourceForMilestoningFilter():Boolean[1] @@ -226,7 +295,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let products = $result.values; assertEquals(1, $products->size()); assertEquals('ProductName', $products->at(0).name); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-08-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-08-16\' and "stockproducttable_0".thru_z > \'2015-08-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-08-16\' and "productclassificationtable_0".thru_z > \'2015-08-16\') left outer join (select distinct "ordertable_1".prodFk from OrderTable as "ordertable_1" where "ordertable_1".id = 1) as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk is not null and "root".from_z <= \'2015-08-16\' and "root".thru_z > \'2015-08-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-08-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-08-16\' and "stockproducttable_0".thru_z > \'2015-08-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-08-16\' and "productclassificationtable_0".thru_z > \'2015-08-16\') left outer join (select distinct "ordertable_1".prodFk from OrderTable as "ordertable_1" where "ordertable_1".id = 1) as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk is not null and "root".from_z <= \'2015-08-16\' and "root".thru_z > \'2015-08-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-08-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-08-16\' and "stockproducttable_0".thru_z > DATE\'2015-08-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-08-16\' and "productclassificationtable_0".thru_z > DATE\'2015-08-16\') left outer join (select distinct "ordertable_1".prodFk from OrderTable as "ordertable_1" where "ordertable_1".id = 1) as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk is not null and "root".from_z <= DATE\'2015-08-16\' and "root".thru_z > DATE\'2015-08-16\'', + $result->sqlRemoveFormatting() + ); } @@ -246,13 +319,21 @@ function <> meta::relational::tests::milestoning::businessdate::testN let orders = $result.values; assertEquals(1,$orders->size()); assertEquals(2, $orders->at(0).id); - assertSameSQL('select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-10-15\' and "producttable_1".thru_z > DATE\'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::latestDate::testNonMilestoningQueryWithLatestMilestoneFilterSimple():Boolean[1] { let result = execute(|Order.all()->filter(o|$o.product(%latest)->exists(p|$p.id==2)), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".thru_z = \'9999-12-31 00:00:00.0000\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".thru_z = \'9999-12-31 00:00:00.0000\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testNonMilestoningQueryWithMilestoneFilterOnAssociation():Boolean[1] @@ -261,7 +342,11 @@ function <> meta::relational::tests::milestoning::businessdate::testN let orders = $result.values; assertEquals(1,$orders->size()); assertEquals(2, $orders->at(0).id); - assertSameSQL('select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-15\' and "producttable_0".thru_z > \'2015-10-15\') where "producttable_0".id = 2', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-15\' and "producttable_0".thru_z > \'2015-10-15\') where "producttable_0".id = 2', + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-15\' and "producttable_0".thru_z > DATE\'2015-10-15\') where "producttable_0".id = 2', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testNonMilestoningQueryWithMilestoneFilterNoResults():Boolean[1] @@ -269,7 +354,11 @@ function <> meta::relational::tests::milestoning::businessdate::testN let result = execute(|Order.all()->filter(o|$o.product(%2015-8-25)->exists(p|$p.id==2)), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let orders = $result.values; assertEquals(0,$orders->size()); - assertSameSQL('select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-08-25\' and "producttable_1".thru_z > \'2015-08-25\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-08-25\' and "producttable_1".thru_z > \'2015-08-25\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-08-25\' and "producttable_1".thru_z > DATE\'2015-08-25\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testNonMilestoningQueryWithMilestoneFilterProject():Boolean[1] @@ -278,7 +367,11 @@ function <> meta::relational::tests::milestoning::businessdate::testN ->project([o|$o.id,o|$o.product(%2015-10-15).name],['orderId','productName']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['2,ProductName1'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= \'2015-10-15\' and "producttable_2".thru_z > \'2015-10-15\') where "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= \'2015-10-15\' and "producttable_2".thru_z > \'2015-10-15\') where "producttable_0".id is not null', + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-10-15\' and "producttable_1".thru_z > DATE\'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= DATE\'2015-10-15\' and "producttable_2".thru_z > DATE\'2015-10-15\') where "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testNonMilestoningQueryWithMilestoneFilterProjectUsingSamePropertyWithDifferentDates():Boolean[1] @@ -287,7 +380,11 @@ function <> meta::relational::tests::milestoning::businessdate::testN ->project([o|$o.id,o|$o.product(%2015-10-16).name],['orderId','productName']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['2,ProductName2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= \'2015-10-16\' and "producttable_2".thru_z > \'2015-10-16\') where "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= \'2015-10-16\' and "producttable_2".thru_z > \'2015-10-16\') where "producttable_0".id is not null', + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-10-15\' and "producttable_1".thru_z > DATE\'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= DATE\'2015-10-16\' and "producttable_2".thru_z > DATE\'2015-10-16\') where "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningQueryWithSimpleProjectWithMilestoneFilter():Boolean[1] @@ -296,7 +393,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM ->project([p|$p.name, p|$p.classification(%2015-10-16).description],['name','classificationDescription']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK DESC-V3'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-17\' and "productexchangetable_0".thru_z > DATE\'2015-10-17\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningQueryWithAggProjectWithMilestoneFilter():Boolean[1] @@ -314,7 +415,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let tds = $result.values->at(0); assertEquals(['ProductName2,GS-Mod-S1*GS-Mod-S2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "prodName", "producttable_1".aggCol as "synonyms" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') left outer join (select "producttable_2".name as name, "producttable_2".id as id, group_concat("productsynonymtable_0".synonym separator \'*\' ) as aggCol from ProductTable as "producttable_2" left outer join ProductSynonymTable as "productsynonymtable_0" on ("producttable_2".name = "productsynonymtable_0".name and "productsynonymtable_0".from_z <= \'2015-10-16\' and "productsynonymtable_0".thru_z > \'2015-10-16\') group by "producttable_2".id,"producttable_2".name) as "producttable_1" on ("root".name = "producttable_1".name and "root".id = "producttable_1".id) where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "prodName", "producttable_1".aggCol as "synonyms" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') left outer join (select "producttable_2".name as name, "producttable_2".id as id, group_concat("productsynonymtable_0".synonym separator \'*\' ) as aggCol from ProductTable as "producttable_2" left outer join ProductSynonymTable as "productsynonymtable_0" on ("producttable_2".name = "productsynonymtable_0".name and "productsynonymtable_0".from_z <= \'2015-10-16\' and "productsynonymtable_0".thru_z > \'2015-10-16\') group by "producttable_2".id,"producttable_2".name) as "producttable_1" on ("root".name = "producttable_1".name and "root".id = "producttable_1".id) where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "prodName", "producttable_1".aggCol as "synonyms" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-17\' and "productexchangetable_0".thru_z > DATE\'2015-10-17\') left outer join (select "producttable_2".name as name, "producttable_2".id as id, group_concat("productsynonymtable_0".synonym separator \'*\' ) as aggCol from ProductTable as "producttable_2" left outer join ProductSynonymTable as "productsynonymtable_0" on ("producttable_2".name = "productsynonymtable_0".name and "productsynonymtable_0".from_z <= DATE\'2015-10-16\' and "productsynonymtable_0".thru_z > DATE\'2015-10-16\') group by "producttable_2".id,"producttable_2".name) as "producttable_1" on ("root".name = "producttable_1".name and "root".id = "producttable_1".id) where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningQueryWithGroupByFilterWithMilestoning():Boolean[1] @@ -333,7 +438,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let tds = $result.values->at(0); assertEquals(['ProductName2,GS-Mod-S1*GS-Mod-S2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "prodName", group_concat("productsynonymtable_0".synonym separator \'*\') as "synonyms" from ProductTable as "root" left outer join ProductSynonymTable as "productsynonymtable_0" on ("root".name = "productsynonymtable_0".name and "productsynonymtable_0".from_z <= \'2015-10-16\' and "productsynonymtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' group by "prodName"', $result); + assertEqualsH2Compatible( + 'select "root".name as "prodName", group_concat("productsynonymtable_0".synonym separator \'*\') as "synonyms" from ProductTable as "root" left outer join ProductSynonymTable as "productsynonymtable_0" on ("root".name = "productsynonymtable_0".name and "productsynonymtable_0".from_z <= \'2015-10-16\' and "productsynonymtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' group by "prodName"', + 'select "root".name as "prodName", group_concat("productsynonymtable_0".synonym separator \'*\') as "synonyms" from ProductTable as "root" left outer join ProductSynonymTable as "productsynonymtable_0" on ("root".name = "productsynonymtable_0".name and "productsynonymtable_0".from_z <= DATE\'2015-10-16\' and "productsynonymtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-17\' and "productexchangetable_0".thru_z > DATE\'2015-10-17\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\' group by "prodName"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testSimpleQueryWithParallelPathsDifferedByBusinessDate():Boolean[1] @@ -386,14 +495,18 @@ function <> meta::relational::tests::milestoning::businessdate::testB let result = execute(|Order.all()->project([col([o|$o.description.description],'orderDesc'),col([o|$o.product($productBusDate).name],'prodName')]), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['order description 1,TDSNull', 'order description 2,ProductName2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2016-01-01\' and "producttable_0".thru_z > \'2016-01-01\')', $result); + assertEqualsH2Compatible( + 'select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2016-01-01\' and "producttable_0".thru_z > \'2016-01-01\')', + 'select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2016-01-01\' and "producttable_0".thru_z > DATE\'2016-01-01\')', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testBusinessDatePropagationInColFunction_asQueryParam():Boolean[1] { let f= {productBusDate:Date[1] | Order.all()->project([col([o|$o.description.description],'orderDesc'),col([o|$o.product($productBusDate).name],'prodName')])}->cast(@FunctionDefinition); // queryParam is not resolved inside col lambda ( as its just a placeholder here) let plan = executionPlan($f, milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); //cant test via execute as params are not supplied - assertEquals( + assertEqualsH2Compatible( 'Sequence\n' + '(\n' + ' type = TDS[(orderDesc, String, VARCHAR(200), \"\"), (prodName, String, VARCHAR(200), \"\")]\n' + @@ -406,7 +519,24 @@ function <> meta::relational::tests::milestoning::businessdate::testB ' (\n' + ' type = TDS[(orderDesc, String, VARCHAR(200), \"\"), (prodName, String, VARCHAR(200), \"\")]\n' + ' resultColumns = [(\"orderDesc\", VARCHAR(200)), (\"prodName\", VARCHAR(200))]\n' + - ' sql = select \"orderdescriptiontable_0\".description as \"orderDesc\", \"producttable_0\".name as \"prodName\" from OrderTable as \"root\" left outer join OrderDescriptionTable as \"orderdescriptiontable_0\" on (\"root\".id = \"orderdescriptiontable_0\".id) left outer join ProductTable as \"producttable_0\" on (\"root\".prodFk = \"producttable_0\".id and \"producttable_0\".from_z <= \'${productBusDate}\' and \"producttable_0\".thru_z > \'${productBusDate}\')\n' + + ' sql = select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'${productBusDate}\' and "producttable_0".thru_z > \'${productBusDate}\')\n' + + ' connection = TestDatabaseConnection(type = \"H2\")\n' + + ' )\n' + + ' )\n' + + ')\n', + 'Sequence\n' + + '(\n' + + ' type = TDS[(orderDesc, String, VARCHAR(200), \"\"), (prodName, String, VARCHAR(200), \"\")]\n' + + ' (\n' + + ' FunctionParametersValidationNode\n' + + ' (\n' + + ' functionParameters = [productBusDate:Date[1]]\n' + + ' )\n' + + ' Relational\n' + + ' (\n' + + ' type = TDS[(orderDesc, String, VARCHAR(200), \"\"), (prodName, String, VARCHAR(200), \"\")]\n' + + ' resultColumns = [(\"orderDesc\", VARCHAR(200)), (\"prodName\", VARCHAR(200))]\n' + + ' sql = select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= TIMESTAMP\'${productBusDate}\' and "producttable_0".thru_z > TIMESTAMP\'${productBusDate}\')\n' + ' connection = TestDatabaseConnection(type = \"H2\")\n' + ' )\n' + ' )\n' + @@ -420,7 +550,11 @@ function <> meta::relational::tests::milestoning::businessdate::testB let result = execute(|Order.all()->project([col([o|$o.description.description],'orderDesc','Spec1'),col([o|$o.product($productBusDate).name],'prodName','Spec2')]), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['order description 1,TDSNull', 'order description 2,ProductName2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2016-01-01\' and "producttable_0".thru_z > \'2016-01-01\')', $result); + assertEqualsH2Compatible( + 'select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2016-01-01\' and "producttable_0".thru_z > \'2016-01-01\')', + 'select "orderdescriptiontable_0".description as "orderDesc", "producttable_0".name as "prodName" from OrderTable as "root" left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("root".id = "orderdescriptiontable_0".id) left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2016-01-01\' and "producttable_0".thru_z > DATE\'2016-01-01\')', + $result->sqlRemoveFormatting() + ); } function meta::relational::tests::milestoning::businessdate::productType(order :Order[1], productBusDate:Date[1]):String[0..1] @@ -433,7 +567,8 @@ function meta::relational::tests::milestoning::businessdate::filterOrders(order $order->filter(o|$o.product($o.orderDate->toOne()).type=='STOCK')->map(x|$x.id); } -function <> meta::relational::tests::milestoning::businessdate::testQueryWithVariableRundateWithinLambda():Boolean[1] +// Duplicated tests: Inflow execution does not add DATE specification to the return value of select but plan generation does +function <> meta::relational::tests::milestoning::businessdate::testInFlowQueryWithVariableRundateWithinLambda():Boolean[1] { let result = execute({| let date = %2015-10-16; @@ -442,9 +577,28 @@ function <> meta::relational::tests::milestoning::businessdate::testQ let products = $result.values; assertEquals(1, $products->size()); assertEquals('ProductName2', $products->at(0).name); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } +function <> meta::relational::tests::milestoning::businessdate::testPlanQueryWithVariableRundateWithinLambda():Boolean[1] +{ + let result = execute({| + let date = %2015-10-16; + Product.all($date)->filter(p|$p.classification($date).type=='STOCK' && $p.exchange($date).name=='LNSE'); + }, milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); + let products = $result.values; + assertEquals(1, $products->size()); + assertEquals('ProductName2', $products->at(0).name); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", DATE\'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); +} function <> meta::relational::tests::milestoning::businessdate::testExecutionPlanForQueryWithVariableRundateWithinLambda():Boolean[1] { @@ -452,7 +606,7 @@ function <> meta::relational::tests::milestoning::businessdate::testE let date = %2015-10-16; Product.all($date)->filter(p|$p.classification($date).type=='STOCK' && $p.exchange($date).name=='LNSE'); }, milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals( + assertEqualsH2Compatible( 'Sequence\n'+ '(\n'+ ' type = Class[impls=(meta::relational::tests::milestoning::Product | milestoningmap.meta_relational_tests_milestoning_Product)]\n'+ @@ -478,11 +632,43 @@ function <> meta::relational::tests::milestoning::businessdate::testE ' type = Class[impls=(meta::relational::tests::milestoning::Product | milestoningmap.meta_relational_tests_milestoning_Product)]\n'+ ' resultSizeRange = *\n'+ ' resultColumns = [("pk_0", INT), ("pk_1", VARCHAR(200)), ("id", INT), ("name", VARCHAR(200)), ("type", VARCHAR(200)), ("stockProductName", VARCHAR(200)), ("classificationType", VARCHAR(200)), ("k_businessDate", "")]\n'+ - ' sql = select \"root\".id as \"pk_0\", \"root\".name as \"pk_1\", \"root\".id as \"id\", \"root\".name as \"name\", \"root\".type as \"type\", \"productdescriptiontable_0\".description as \"stockProductName\", \"productclassificationtable_0\".type as \"classificationType\", \'${date}\' as \"k_businessDate\" from ProductTable as \"root\" left outer join StockProductTable as \"stockproducttable_0\" on (\"root\".id = \"stockproducttable_0\".id and \"stockproducttable_0\".from_z <= \'${date}\' and \"stockproducttable_0\".thru_z > \'${date}\') left outer join ProductDescriptionTable as \"productdescriptiontable_0\" on (\"stockproducttable_0\".id = \"productdescriptiontable_0\".id) left outer join ProductClassificationTable as \"productclassificationtable_0\" on (\"root\".type = \"productclassificationtable_0\".type and \"productclassificationtable_0\".from_z <= \'${date}\' and \"productclassificationtable_0\".thru_z > \'${date}\') left outer join ProductClassificationTable as \"productclassificationtable_1\" on (\"root\".type = \"productclassificationtable_1\".type and \"productclassificationtable_1\".from_z <= \'${date}\' and \"productclassificationtable_1\".thru_z > \'${date}\') left outer join ProductExchangeTable as \"productexchangetable_0\" on (\"root\".exchange = \"productexchangetable_0\".name and \"productexchangetable_0\".from_z <= \'${date}\' and \"productexchangetable_0\".thru_z > \'${date}\') where (\"productclassificationtable_1\".type = \'STOCK\' and \"productexchangetable_0\".name = \'LNSE\') and \"root\".from_z <= \'${date}\' and \"root\".thru_z > \'${date}\'\n'+ + ' sql = select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'${date}\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'${date}\' and "stockproducttable_0".thru_z > \'${date}\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'${date}\' and "productclassificationtable_0".thru_z > \'${date}\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'${date}\' and "productclassificationtable_1".thru_z > \'${date}\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'${date}\' and "productexchangetable_0".thru_z > \'${date}\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'${date}\' and "root".thru_z > \'${date}\'\n'+ ' connection = TestDatabaseConnection(type = "H2")\n'+ ' )\n'+ ' )\n'+ - ')\n',$result->planToString(meta::relational::extension::relationalExtensions())); + ')\n', + 'Sequence\n'+ + '(\n'+ + ' type = Class[impls=(meta::relational::tests::milestoning::Product | milestoningmap.meta_relational_tests_milestoning_Product)]\n'+ + ' resultSizeRange = *\n'+ + ' (\n'+ + ' Allocation\n'+ + ' (\n'+ + ' type = StrictDate\n'+ + ' resultSizeRange = 1\n'+ + ' name = date\n'+ + ' value = \n'+ + ' (\n'+ + ' Constant\n'+ + ' (\n'+ + ' type = StrictDate\n'+ + ' resultSizeRange = 1\n'+ + ' values=[2015-10-16]\n'+ + ' )\n'+ + ' )\n'+ + ' )\n'+ + ' Relational\n'+ + ' (\n'+ + ' type = Class[impls=(meta::relational::tests::milestoning::Product | milestoningmap.meta_relational_tests_milestoning_Product)]\n'+ + ' resultSizeRange = *\n'+ + ' resultColumns = [("pk_0", INT), ("pk_1", VARCHAR(200)), ("id", INT), ("name", VARCHAR(200)), ("type", VARCHAR(200)), ("stockProductName", VARCHAR(200)), ("classificationType", VARCHAR(200)), ("k_businessDate", "")]\n'+ + ' sql = select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", DATE\'${date}\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'${date}\' and "stockproducttable_0".thru_z > DATE\'${date}\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'${date}\' and "productclassificationtable_0".thru_z > DATE\'${date}\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'${date}\' and "productclassificationtable_1".thru_z > DATE\'${date}\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'${date}\' and "productexchangetable_0".thru_z > DATE\'${date}\') where ("productclassificationtable_1".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'${date}\' and "root".thru_z > DATE\'${date}\'\n'+ + ' connection = TestDatabaseConnection(type = "H2")\n'+ + ' )\n'+ + ' )\n'+ + ')\n', + $result->planToString(meta::relational::extension::relationalExtensions()) + ); } function <> meta::relational::tests::milestoning::businessdate::testNonMilestoningQueryWithMilestoneFilterVariableRundateWithinLambda():Boolean[1] @@ -493,7 +679,11 @@ function <> meta::relational::tests::milestoning::businessdate::testN let orders = $result.values; assertEquals(1,$orders->size()); assertEquals(2, $orders->at(0).id); - assertSameSQL('select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join (select distinct "producttable_1".id from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-10-15\' and "producttable_1".thru_z > DATE\'2015-10-15\' and "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) where "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningCriteriaAppliedToSimplePropertyJoinFromTemporalClass():Boolean[1] @@ -505,7 +695,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let tds = $result.values->at(0); assertEquals(['1,TDSNull', '2,ProductName2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "id", "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-10-16\' and "stockproducttable_1".thru_z > \'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', $result); + assertEqualsH2Compatible( + 'select "root".id as "id", "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-10-16\' and "stockproducttable_1".thru_z > \'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', + 'select "root".id as "id", "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= DATE\'2015-10-16\' and "stockproducttable_1".thru_z > DATE\'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', + $result->sqlRemoveFormatting() + ); assertSameSQL('select "root".id as "id", "productclassificationtable_0".type as "productClassificationType" from OrderTable as "root" left outer join (select "ordertable_2".id as id, "orderdetailstable_0".settlementDate as settlementDate, "producttable_0".type as type from OrderTable as "ordertable_2" left outer join ProductTable as "producttable_0" on ("ordertable_2".prodFk = "producttable_0".id) left outer join OrderDetailsTable as "orderdetailstable_0" on ("ordertable_2".id = "orderdetailstable_0".id) where "producttable_0".from_z <= "orderdetailstable_0".settlementDate and "producttable_0".thru_z > "orderdetailstable_0".settlementDate) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".from_z as from_z, "productclassificationtable_1".thru_z as thru_z from ProductClassificationTable as "productclassificationtable_1") as "productclassificationtable_0" on ("productclassificationtable_0".from_z <= "ordertable_1".settlementDate and "productclassificationtable_0".thru_z > "ordertable_1".settlementDate and "ordertable_1".type = "productclassificationtable_0".type)', $result2); assertSameSQL('select "root".id as "id", "productclassificationtable_0".type as "productClassificationType" from OrderTable as "root" left outer join (select "ordertable_2".id as id, "orderdetailstable_0".settlementDate as settlementDate, "producttable_0".type as type from OrderTable as "ordertable_2" left outer join OrderDetailsTable as "orderdetailstable_0" on ("ordertable_2".id = "orderdetailstable_0".id) left outer join ProductTable as "producttable_0" on ("ordertable_2".prodFk = "producttable_0".id) where "producttable_0".from_z <= dateadd(DAY, -1, "orderdetailstable_0".settlementDate) and "producttable_0".thru_z > dateadd(DAY, -1, "orderdetailstable_0".settlementDate)) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".from_z as from_z, "productclassificationtable_1".thru_z as thru_z from ProductClassificationTable as "productclassificationtable_1") as "productclassificationtable_0" on ("productclassificationtable_0".from_z <= dateadd(DAY, -1, "ordertable_1".settlementDate) and "productclassificationtable_0".thru_z > dateadd(DAY, -1, "ordertable_1".settlementDate) and "ordertable_1".type = "productclassificationtable_0".type)', $result3); } @@ -516,14 +710,22 @@ function <> meta::relational::tests::milestoning::businessdate::testM let result = execute(|Order.all()->project([o|$o.id, o|$o.productQp($businessDate).stockProductName],['id','stockProductName']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['1,TDSNull', '2,ProductName2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "id", "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-10-16\' and "stockproducttable_1".thru_z > \'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', $result); + assertEqualsH2Compatible( + 'select "root".id as "id", "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-10-16\' and "stockproducttable_1".thru_z > \'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', + 'select "root".id as "id", "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= DATE\'2015-10-16\' and "stockproducttable_1".thru_z > DATE\'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningCriteriaOriginatingFromQualifiedPropertyAppliedToSimplePropertyJoinFromTemporalClass():Boolean[1] { let businessDate = %2015-10-16; let result = execute(|Order.all()->project([o|$o.id, o|$o.product($businessDate).classificationWithDateConstant().exchangeName],['id','productExchangeNameUsingDateConstantPropagatedFromQP']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "id", "productexchangetable_0".name as "productExchangeNameUsingDateConstantPropagatedFromQP" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".exchange from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'9999-12-31\' and "productclassificationtable_1".thru_z > \'9999-12-31\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'9999-12-31\' and "productexchangetable_1".thru_z > \'9999-12-31\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name)', $result); + assertEqualsH2Compatible( + 'select "root".id as "id", "productexchangetable_0".name as "productExchangeNameUsingDateConstantPropagatedFromQP" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".exchange from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'9999-12-31\' and "productclassificationtable_1".thru_z > \'9999-12-31\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'9999-12-31\' and "productexchangetable_1".thru_z > \'9999-12-31\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name)', + 'select "root".id as "id", "productexchangetable_0".name as "productExchangeNameUsingDateConstantPropagatedFromQP" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".exchange from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= DATE\'9999-12-31\' and "productclassificationtable_1".thru_z > DATE\'9999-12-31\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= DATE\'9999-12-31\' and "productexchangetable_1".thru_z > DATE\'9999-12-31\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name)', + $result->sqlRemoveFormatting() + ); } @@ -533,7 +735,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let result = execute(|Order.all()->project([o|$o.id, o|$o.stockProduct($businessDate).name],['orderId','stockProductName']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['1,TDSNull', '2,ProductName2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "producttable_0".name as "stockProductName" from OrderTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".prodFk = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join (select "producttable_1".id as id, "producttable_1".name as name from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-16\' and "producttable_1".thru_z > \'2015-10-16\') as "producttable_0" on ("producttable_0".id = "stockproducttable_0".id)', $result); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "producttable_0".name as "stockProductName" from OrderTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".prodFk = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join (select "producttable_1".id as id, "producttable_1".name as name from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-16\' and "producttable_1".thru_z > \'2015-10-16\') as "producttable_0" on ("producttable_0".id = "stockproducttable_0".id)', + 'select "root".id as "orderId", "producttable_0".name as "stockProductName" from OrderTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".prodFk = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join (select "producttable_1".id as id, "producttable_1".name as name from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-10-16\' and "producttable_1".thru_z > DATE\'2015-10-16\') as "producttable_0" on ("producttable_0".id = "stockproducttable_0".id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestonedQualifiedPropertyUsedOnSuperTypeInEmbedded():Boolean[1] @@ -544,7 +750,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let tds = $result.values->at(0); assertEquals(['STOCK', 'OPTION'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".type as "classificationType" from ProductTable as "root" where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'',$result); + assertEqualsH2Compatible( + 'select "root".type as "classificationType" from ProductTable as "root" where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".type as "classificationType" from ProductTable as "root" where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoneFiltersAreNotAppliedToEmbeddedPropertiesInQualifiersTriggeringIsolationSelfJoin():Boolean[1] @@ -555,7 +765,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let tds = $result.values->at(0); assertEquals(['LNSE'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "productexchangetable_0".name as "1" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where "root".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "productexchangetable_0".name as "1" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where "root".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "productexchangetable_0".name as "1" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where "root".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testIsolationOfIntermediateJoinsInMultiLevelPropertyJoin():Boolean[1] @@ -566,8 +780,11 @@ function <> meta::relational::tests::milestoning::businessdate::testI let tds = $result.values->at(0); assertEquals(['SYS1'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "systemtable_0".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-17\' and "productclassificationsystemtable_0".thru_z > \'2015-10-17\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); - + assertEqualsH2Compatible( + 'select "systemtable_0".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-17\' and "productclassificationsystemtable_0".thru_z > \'2015-10-17\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "systemtable_0".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= DATE\'2015-10-17\' and "productclassificationsystemtable_0".thru_z > DATE\'2015-10-17\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testIsolationWhereLeftSideOfFilterIsEmbedded():Boolean[1] @@ -578,7 +795,11 @@ function <> meta::relational::tests::milestoning::businessdate::testI let tds = $result.values->at(0); assertEquals(['ProductName2', 'ProductName3'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-16\' and "productclassificationsystemtable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "systemtable_0".name = \'SYS1\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-16\' and "productclassificationsystemtable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "systemtable_0".name = \'SYS1\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationsystemtable_0".thru_z > DATE\'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "systemtable_0".name = \'SYS1\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function meta::relational::tests::milestoning::businessdate::constantDate():Date[1] @@ -591,7 +812,11 @@ function <> meta::relational::tests::milestoning::businessdate::testD let query = {|Order.all()->project([o|$o.id, o|$o.stockProduct(constantDate()).name],['orderId','stockProductName'])}; let sql = toSQLString($query, milestoningmap, meta::relational::runtime::DatabaseType.H2, meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "orderId", "ProductTable_d#7_l_d_m2_r".name as "stockProductName" from OrderTable as "root" left outer join StockProductTable as "StockProductTable_d#7_d_m2" on ("root".prodFk = "StockProductTable_d#7_d_m2".id and "StockProductTable_d#7_d_m2".from_z <= \'2015-01-01\' and "StockProductTable_d#7_d_m2".thru_z > \'2015-01-01\') left outer join (select "ProductTable_d#7_l".id as id, "ProductTable_d#7_l".name as name from ProductTable as "ProductTable_d#7_l" where "ProductTable_d#7_l".from_z <= \'2015-01-01\' and "ProductTable_d#7_l".thru_z > \'2015-01-01\') as "ProductTable_d#7_l_d_m2_r" on ("ProductTable_d#7_l_d_m2_r".id = "StockProductTable_d#7_d_m2".id)',$sql); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "ProductTable_d#7_l_d_m2_r".name as "stockProductName" from OrderTable as "root" left outer join StockProductTable as "StockProductTable_d#7_d_m2" on ("root".prodFk = "StockProductTable_d#7_d_m2".id and "StockProductTable_d#7_d_m2".from_z <= \'2015-01-01\' and "StockProductTable_d#7_d_m2".thru_z > \'2015-01-01\') left outer join (select "ProductTable_d#7_l".id as id, "ProductTable_d#7_l".name as name from ProductTable as "ProductTable_d#7_l" where "ProductTable_d#7_l".from_z <= \'2015-01-01\' and "ProductTable_d#7_l".thru_z > \'2015-01-01\') as "ProductTable_d#7_l_d_m2_r" on ("ProductTable_d#7_l_d_m2_r".id = "StockProductTable_d#7_d_m2".id)', + 'select "root".id as "orderId", "ProductTable_d#7_l_d_m2_r".name as "stockProductName" from OrderTable as "root" left outer join StockProductTable as "StockProductTable_d#7_d_m2" on ("root".prodFk = "StockProductTable_d#7_d_m2".id and "StockProductTable_d#7_d_m2".from_z <= DATE\'2015-01-01\' and "StockProductTable_d#7_d_m2".thru_z > DATE\'2015-01-01\') left outer join (select "ProductTable_d#7_l".id as id, "ProductTable_d#7_l".name as name from ProductTable as "ProductTable_d#7_l" where "ProductTable_d#7_l".from_z <= DATE\'2015-01-01\' and "ProductTable_d#7_l".thru_z > DATE\'2015-01-01\') as "ProductTable_d#7_l_d_m2_r" on ("ProductTable_d#7_l_d_m2_r".id = "StockProductTable_d#7_d_m2".id)', + $sql->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testDateFunctionInMilestonedPropertyWithMilestonedEntity():Boolean[1] @@ -600,7 +825,11 @@ function <> meta::relational::tests::milestoning::businessdate::testD let query = {|Product.all($businessDate)->filter(p|$p.classification(constantDate()).system.name=='SYS1')->project([p|$p.name],['name'])}; let sql = toSQLString($query, milestoningMapWithEmbeddedSimple, meta::relational::runtime::DatabaseType.H2, meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "ProductClassificationSystemTable_d#5_d#2_m1" on ("root".classificationSystemId = "ProductClassificationSystemTable_d#5_d#2_m1".id and "ProductClassificationSystemTable_d#5_d#2_m1".from_z <= \'2015-01-01\' and "ProductClassificationSystemTable_d#5_d#2_m1".thru_z > \'2015-01-01\') left outer join SystemTable as "SystemTable_d#5_l_d#2_m1_r" on ("ProductClassificationSystemTable_d#5_d#2_m1".name = "SystemTable_d#5_l_d#2_m1_r".name) where "SystemTable_d#5_l_d#2_m1_r".name = \'SYS1\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $sql); + assertEqualsH2Compatible( + 'select "root".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "ProductClassificationSystemTable_d#5_d#2_m1" on ("root".classificationSystemId = "ProductClassificationSystemTable_d#5_d#2_m1".id and "ProductClassificationSystemTable_d#5_d#2_m1".from_z <= \'2015-01-01\' and "ProductClassificationSystemTable_d#5_d#2_m1".thru_z > \'2015-01-01\') left outer join SystemTable as "SystemTable_d#5_l_d#2_m1_r" on ("ProductClassificationSystemTable_d#5_d#2_m1".name = "SystemTable_d#5_l_d#2_m1_r".name) where "SystemTable_d#5_l_d#2_m1_r".name = \'SYS1\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name" from ProductTable as "root" left outer join ProductClassificationSystemTable as "ProductClassificationSystemTable_d#5_d#2_m1" on ("root".classificationSystemId = "ProductClassificationSystemTable_d#5_d#2_m1".id and "ProductClassificationSystemTable_d#5_d#2_m1".from_z <= DATE\'2015-01-01\' and "ProductClassificationSystemTable_d#5_d#2_m1".thru_z > DATE\'2015-01-01\') left outer join SystemTable as "SystemTable_d#5_l_d#2_m1_r" on ("ProductClassificationSystemTable_d#5_d#2_m1".name = "SystemTable_d#5_l_d#2_m1_r".name) where "SystemTable_d#5_l_d#2_m1_r".name = \'SYS1\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $sql->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testAllVersionsQueryWithMilestonedProperty():Boolean[1] @@ -622,7 +851,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM assertEquals(2, $pnls->size()); assertSameElements([200.0, 101.0], $pnls->map(p|$p.pnl)); assertEquals([$businessDate,$businessDate], $pnls->map(p|$p.businessDate)); - assertSameSQL('select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContact as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersontable_0".NAME as supportContact, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root"', $result); + assertEqualsH2Compatible( + 'select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContact as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersontable_0".NAME as supportContact, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root"', + 'select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContact as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersontable_0".NAME as supportContact, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= DATE\'2016-07-22\' and "salespersontable_0".thru_z > DATE\'2016-07-22\') where "root".from_z <= DATE\'2016-07-22\' and "root".thru_z > DATE\'2016-07-22\') as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningContextPropagatedFromParentViewToViewsReferencedInItsColumns():Boolean[1] @@ -633,7 +866,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM assertEquals(2, $pnls->size()); assertSameElements([200.0, 101.0], $pnls->map(p|$p.pnl)); assertEquals([$businessDate,$businessDate], $pnls->map(p|$p.businessDate)); - assertSameSQL('select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContactViaView as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersonview_0".SALES_PERSON_NAME as supportContactViaView, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') left outer join (select "root".ACCOUNT_ID as ACCOUNT_ID, "root".NAME as SALES_PERSON_NAME from salesPersonTable as "root" where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "salespersonview_0" on ("salespersontable_0".ACCOUNT_ID = "salespersonview_0".ACCOUNT_ID) where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root"', $result); + assertEqualsH2Compatible( + 'select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContactViaView as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersonview_0".SALES_PERSON_NAME as supportContactViaView, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') left outer join (select "root".ACCOUNT_ID as ACCOUNT_ID, "root".NAME as SALES_PERSON_NAME from salesPersonTable as "root" where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "salespersonview_0" on ("salespersontable_0".ACCOUNT_ID = "salespersonview_0".ACCOUNT_ID) where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root"', + 'select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContactViaView as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersonview_0".SALES_PERSON_NAME as supportContactViaView, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= DATE\'2016-07-22\' and "salespersontable_0".thru_z > DATE\'2016-07-22\') left outer join (select "root".ACCOUNT_ID as ACCOUNT_ID, "root".NAME as SALES_PERSON_NAME from salesPersonTable as "root" where "root".from_z <= DATE\'2016-07-22\' and "root".thru_z > DATE\'2016-07-22\') as "salespersonview_0" on ("salespersontable_0".ACCOUNT_ID = "salespersonview_0".ACCOUNT_ID) where "root".from_z <= DATE\'2016-07-22\' and "root".thru_z > DATE\'2016-07-22\') as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningContextPropagatedWithViewAsMainRelationOfView():Boolean[1] @@ -644,7 +881,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM assertEquals(2, $pnls->size()); assertSameElements([200.0, 101.0], $pnls->map(p|$p.pnl)); assertEquals([$businessDate,$businessDate], $pnls->map(p|$p.businessDate)); - assertSameSQL('select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContactViaView as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersonview_0".SALES_PERSON_NAME as supportContactViaView, \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root" left outer join tradePnlTable as "tradepnltable_1" on ("root".TRADE_ID = "tradepnltable_1".TRADE_ID and "tradepnltable_1".from_z <= \'2016-07-22\' and "tradepnltable_1".thru_z > \'2016-07-22\') left outer join tradeTable as "tradetable_0" on ("tradepnltable_1".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') left outer join (select "root".ACCOUNT_ID as ACCOUNT_ID, "root".NAME as SALES_PERSON_NAME from salesPersonTable as "root" where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "salespersonview_0" on ("salespersontable_0".ACCOUNT_ID = "salespersonview_0".ACCOUNT_ID)) as "root"', $result); + assertEqualsH2Compatible( + 'select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContactViaView as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersonview_0".SALES_PERSON_NAME as supportContactViaView, \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root" left outer join tradePnlTable as "tradepnltable_1" on ("root".TRADE_ID = "tradepnltable_1".TRADE_ID and "tradepnltable_1".from_z <= \'2016-07-22\' and "tradepnltable_1".thru_z > \'2016-07-22\') left outer join tradeTable as "tradetable_0" on ("tradepnltable_1".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') left outer join (select "root".ACCOUNT_ID as ACCOUNT_ID, "root".NAME as SALES_PERSON_NAME from salesPersonTable as "root" where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "salespersonview_0" on ("salespersontable_0".ACCOUNT_ID = "salespersonview_0".ACCOUNT_ID)) as "root"', + 'select "root".TRADE_ID as "pk_0", "root".pnl as "pnl", "root".supportContactViaView as "supportContactName", \'2016-07-22\' as "k_businessDate" from (select "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersonview_0".SALES_PERSON_NAME as supportContactViaView, \'2016-07-22\' as "k_businessDate" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" where "root".from_z <= DATE\'2016-07-22\' and "root".thru_z > DATE\'2016-07-22\') as "root" left outer join tradePnlTable as "tradepnltable_1" on ("root".TRADE_ID = "tradepnltable_1".TRADE_ID and "tradepnltable_1".from_z <= DATE\'2016-07-22\' and "tradepnltable_1".thru_z > DATE\'2016-07-22\') left outer join tradeTable as "tradetable_0" on ("tradepnltable_1".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= DATE\'2016-07-22\' and "salespersontable_0".thru_z > DATE\'2016-07-22\') left outer join (select "root".ACCOUNT_ID as ACCOUNT_ID, "root".NAME as SALES_PERSON_NAME from salesPersonTable as "root" where "root".from_z <= DATE\'2016-07-22\' and "root".thru_z > DATE\'2016-07-22\') as "salespersonview_0" on ("salespersontable_0".ACCOUNT_ID = "salespersonview_0".ACCOUNT_ID)) as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningCriteriaAppliedToJoinFromViewRoot():Boolean[1] @@ -653,7 +894,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let result = execute(|TradePnl.all($businessDate)->project([p|$p.pnl,p|$p.supportContactName],['pnl','supportContact']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['101.0,Joe Martinez', '200.0,John Martinez'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".pnl as "pnl", "root".supportContact as "supportContact" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersontable_0".NAME as supportContact, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root"', $result); + assertEqualsH2Compatible( + 'select "root".pnl as "pnl", "root".supportContact as "supportContact" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersontable_0".NAME as supportContact, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= \'2016-07-22\' and "salespersontable_0".thru_z > \'2016-07-22\') where "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\') as "root"', + 'select "root".pnl as "pnl", "root".supportContact as "supportContact" from (select distinct "root".TRADE_ID as TRADE_ID, "root".pnl as pnl, "salespersontable_0".NAME as supportContact, \'2016-07-22\' as "k_businessDate" from tradePnlTable as "root" left outer join tradeTable as "tradetable_0" on ("root".TRADE_ID = "tradetable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("tradetable_0".accountID = "salespersontable_0".ACCOUNT_ID and "salespersontable_0".from_z <= DATE\'2016-07-22\' and "salespersontable_0".thru_z > DATE\'2016-07-22\') where "root".from_z <= DATE\'2016-07-22\' and "root".thru_z > DATE\'2016-07-22\') as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testIsolationOfCaseStmtTrueFalseFilters():Boolean[1] @@ -662,7 +907,11 @@ function <> meta::relational::tests::milestoning::businessdate::testI let products = $result.values; assertEquals(1, $products->size()); assertEquals('ProductName2', $products->at(0).name); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2016-07-22\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2016-07-22\' and "stockproducttable_0".thru_z > \'2016-07-22\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2016-07-22\' and "productclassificationtable_0".thru_z > \'2016-07-22\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2016-07-23\' and "productclassificationtable_1".thru_z > \'2016-07-23\') left outer join ProductTable as "producttable_1" on ("producttable_1".type = "productclassificationtable_1".type and "producttable_1".from_z <= \'2016-07-23\' and "producttable_1".thru_z > \'2016-07-23\') left outer join ProductClassificationTable as "productclassificationtable_2" on ("root".type = "productclassificationtable_2".type and "productclassificationtable_2".from_z <= \'2016-07-24\' and "productclassificationtable_2".thru_z > \'2016-07-24\') left outer join ProductTable as "producttable_2" on ("producttable_2".type = "productclassificationtable_2".type and "producttable_2".from_z <= \'2016-07-24\' and "producttable_2".thru_z > \'2016-07-24\') where "root".name = case when "root".id = 1 then "producttable_1".name else "producttable_2".name end and "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2016-07-22\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2016-07-22\' and "stockproducttable_0".thru_z > \'2016-07-22\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2016-07-22\' and "productclassificationtable_0".thru_z > \'2016-07-22\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2016-07-23\' and "productclassificationtable_1".thru_z > \'2016-07-23\') left outer join ProductTable as "producttable_1" on ("producttable_1".type = "productclassificationtable_1".type and "producttable_1".from_z <= \'2016-07-23\' and "producttable_1".thru_z > \'2016-07-23\') left outer join ProductClassificationTable as "productclassificationtable_2" on ("root".type = "productclassificationtable_2".type and "productclassificationtable_2".from_z <= \'2016-07-24\' and "productclassificationtable_2".thru_z > \'2016-07-24\') left outer join ProductTable as "producttable_2" on ("producttable_2".type = "productclassificationtable_2".type and "producttable_2".from_z <= \'2016-07-24\' and "producttable_2".thru_z > \'2016-07-24\') where "root".name = case when "root".id = 1 then "producttable_1".name else "producttable_2".name end and "root".from_z <= \'2016-07-22\' and "root".thru_z > \'2016-07-22\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2016-07-22\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2016-07-22\' and "stockproducttable_0".thru_z > DATE\'2016-07-22\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2016-07-22\' and "productclassificationtable_0".thru_z > DATE\'2016-07-22\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2016-07-23\' and "productclassificationtable_1".thru_z > DATE\'2016-07-23\') left outer join ProductTable as "producttable_1" on ("producttable_1".type = "productclassificationtable_1".type and "producttable_1".from_z <= DATE\'2016-07-23\' and "producttable_1".thru_z > DATE\'2016-07-23\') left outer join ProductClassificationTable as "productclassificationtable_2" on ("root".type = "productclassificationtable_2".type and "productclassificationtable_2".from_z <= DATE\'2016-07-24\' and "productclassificationtable_2".thru_z > DATE\'2016-07-24\') left outer join ProductTable as "producttable_2" on ("producttable_2".type = "productclassificationtable_2".type and "producttable_2".from_z <= DATE\'2016-07-24\' and "producttable_2".thru_z > DATE\'2016-07-24\') where "root".name = case when "root".id = 1 then "producttable_1".name else "producttable_2".name end and "root".from_z <= DATE\'2016-07-22\' and "root".thru_z > DATE\'2016-07-22\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::qualifier::setUp():Any[0..1] @@ -670,7 +919,8 @@ function <> meta::relational::tests::milestoning::qualifier: initDatabase(); } -function <> meta::relational::tests::milestoning::qualifier::testFilterWithMilestoning():Boolean[1] +// Duplicated tests: InFlow does not add DATE specifier to return value while plan generation does. Probable milestoning type inference +function <> meta::relational::tests::milestoning::qualifier::testInFlowFilterWithMilestoning():Boolean[1] { let result = execute({| let date = %2015-10-16; @@ -679,7 +929,27 @@ function <> meta::relational::tests::milestoning::qualifier::testFilt let products = $result.values; assertEquals(1, $products->size()); assertEquals('ProductName2', $products->at(0).name); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); +} + +function <> meta::relational::tests::milestoning::qualifier::testPlanFilterWithMilestoning():Boolean[1] +{ + let result = execute({| + let date = %2015-10-16; + Product.all($date)->filter(p|$p.classification($date).type=='STOCK'); + }, milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); + let products = $result.values; + assertEquals(1, $products->size()); + assertEquals('ProductName2', $products->at(0).name); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", DATE\'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } @@ -691,7 +961,11 @@ function <> meta::relational::tests::milestoning::qualifier::testProj }, milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let products = $result.values->at(0); assertEquals(1, $products->size()); - assertSameSQL('select "productclassificationtable_0".type = \'STOCK\' as "c1" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "productclassificationtable_0".type = \'STOCK\' as "c1" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "productclassificationtable_0".type = \'STOCK\' as "c1" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } @@ -699,7 +973,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM { let businessDate = %2015-10-16; let result = execute(|Order.all()->project([o|$o.id, o|$o.product($businessDate).classificationWithDateConstant().exchangeName],['id','productExchangeNameUsingDateConstantPropagatedFromQP']), milestoningmapMultipleJoinOperations, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "id", "productexchangetable_0".name as "productExchangeNameUsingDateConstantPropagatedFromQP" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".exchange from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'9999-12-31\' and "productclassificationtable_1".thru_z > \'9999-12-31\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'9999-12-31\' and "productexchangetable_1".thru_z > \'9999-12-31\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name or ("productclassificationtable_0".exchange is null and "productexchangetable_0".name is null))', $result); + assertEqualsH2Compatible( + 'select "root".id as "id", "productexchangetable_0".name as "productExchangeNameUsingDateConstantPropagatedFromQP" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".exchange from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'9999-12-31\' and "productclassificationtable_1".thru_z > \'9999-12-31\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'9999-12-31\' and "productexchangetable_1".thru_z > \'9999-12-31\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name or ("productclassificationtable_0".exchange is null and "productexchangetable_0".name is null))', + 'select "root".id as "id", "productexchangetable_0".name as "productExchangeNameUsingDateConstantPropagatedFromQP" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".exchange from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= DATE\'9999-12-31\' and "productclassificationtable_1".thru_z > DATE\'9999-12-31\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= DATE\'9999-12-31\' and "productexchangetable_1".thru_z > DATE\'9999-12-31\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name or ("productclassificationtable_0".exchange is null and "productexchangetable_0".name is null))', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testConcatenationOfTemporalTdsQueries():Boolean[1] @@ -714,7 +992,11 @@ function <> meta::relational::tests::milestoning::businessdate::testC let tds = $result.values->at(0); assertEquals(['2015-08-16,ProductName,TDSNull', '2015-08-27,ProductName1,LNSE', '2015-08-27,ProductName3,TDSNull', '2015-10-16,ProductName2,LNSE', '2015-10-16,ProductName3,TDSNull', '2015-10-17,ProductName2,LNSE', '2015-10-17,ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."productName" as "productName", "unionalias_0"."exchangeName" as "exchangeName" from (select \'2015-08-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-16\' and "productexchangetable_0".thru_z > \'2015-08-16\') where (("productclassificationtable_0".from_z <= \'2015-08-16\' and "productclassificationtable_0".thru_z > \'2015-08-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-16\' and "root".thru_z > \'2015-08-16\' UNION ALL select \'2015-08-27\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-27\' and "productexchangetable_0".thru_z > \'2015-08-27\') where (("productclassificationtable_0".from_z <= \'2015-08-27\' and "productclassificationtable_0".thru_z > \'2015-08-27\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-27\' and "root".thru_z > \'2015-08-27\' UNION ALL select \'2015-10-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where (("productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' UNION ALL select \'2015-10-17\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where (("productclassificationtable_0".from_z <= \'2015-10-17\' and "productclassificationtable_0".thru_z > \'2015-10-17\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-17\' and "root".thru_z > \'2015-10-17\') as "unionalias_0"', $result); + assertEqualsH2Compatible( + 'select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."productName" as "productName", "unionalias_0"."exchangeName" as "exchangeName" from (select \'2015-08-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-16\' and "productexchangetable_0".thru_z > \'2015-08-16\') where (("productclassificationtable_0".from_z <= \'2015-08-16\' and "productclassificationtable_0".thru_z > \'2015-08-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-16\' and "root".thru_z > \'2015-08-16\' UNION ALL select \'2015-08-27\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-27\' and "productexchangetable_0".thru_z > \'2015-08-27\') where (("productclassificationtable_0".from_z <= \'2015-08-27\' and "productclassificationtable_0".thru_z > \'2015-08-27\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-27\' and "root".thru_z > \'2015-08-27\' UNION ALL select \'2015-10-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where (("productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' UNION ALL select \'2015-10-17\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where (("productclassificationtable_0".from_z <= \'2015-10-17\' and "productclassificationtable_0".thru_z > \'2015-10-17\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-17\' and "root".thru_z > \'2015-10-17\') as "unionalias_0"', + 'select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."productName" as "productName", "unionalias_0"."exchangeName" as "exchangeName" from (select DATE\'2015-08-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-08-16\' and "productexchangetable_0".thru_z > DATE\'2015-08-16\') where (("productclassificationtable_0".from_z <= DATE\'2015-08-16\' and "productclassificationtable_0".thru_z > DATE\'2015-08-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-08-16\' and "root".thru_z > DATE\'2015-08-16\' UNION ALL select DATE\'2015-08-27\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-08-27\' and "productexchangetable_0".thru_z > DATE\'2015-08-27\') where (("productclassificationtable_0".from_z <= DATE\'2015-08-27\' and "productclassificationtable_0".thru_z > DATE\'2015-08-27\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-08-27\' and "root".thru_z > DATE\'2015-08-27\' UNION ALL select DATE\'2015-10-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where (("productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\' UNION ALL select DATE\'2015-10-17\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-17\' and "productexchangetable_0".thru_z > DATE\'2015-10-17\') where (("productclassificationtable_0".from_z <= DATE\'2015-10-17\' and "productclassificationtable_0".thru_z > DATE\'2015-10-17\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-10-17\' and "root".thru_z > DATE\'2015-10-17\') as "unionalias_0"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testConcatenationOfTemporalTdsQueriesWithGroupBy():Boolean[1] @@ -729,7 +1011,11 @@ function <> meta::relational::tests::milestoning::businessdate::testC let tds = $result.values->at(0); assertEquals(['2015-08-16,ProductName,TDSNull,1', '2015-08-27,ProductName1,LNSE,1', '2015-08-27,ProductName3,TDSNull,1', '2015-10-16,ProductName2,LNSE,1', '2015-10-16,ProductName3,TDSNull,1', '2015-10-17,ProductName2,LNSE,1', '2015-10-17,ProductName3,TDSNull,1'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."productName" as "productName", "unionalias_0"."exchangeName" as "exchangeName", "unionalias_0"."count" as "count" from (select \'2015-08-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-16\' and "productexchangetable_0".thru_z > \'2015-08-16\') where (("productclassificationtable_0".from_z <= \'2015-08-16\' and "productclassificationtable_0".thru_z > \'2015-08-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-16\' and "root".thru_z > \'2015-08-16\' group by "businessDate","productName","exchangeName" UNION ALL select \'2015-08-27\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-27\' and "productexchangetable_0".thru_z > \'2015-08-27\') where (("productclassificationtable_0".from_z <= \'2015-08-27\' and "productclassificationtable_0".thru_z > \'2015-08-27\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-27\' and "root".thru_z > \'2015-08-27\' group by "businessDate","productName","exchangeName" UNION ALL select \'2015-10-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where (("productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' group by "businessDate","productName","exchangeName" UNION ALL select \'2015-10-17\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where (("productclassificationtable_0".from_z <= \'2015-10-17\' and "productclassificationtable_0".thru_z > \'2015-10-17\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-17\' and "root".thru_z > \'2015-10-17\' group by "businessDate","productName","exchangeName") as "unionalias_0"', $result); + assertEqualsH2Compatible( + 'select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."productName" as "productName", "unionalias_0"."exchangeName" as "exchangeName", "unionalias_0"."count" as "count" from (select \'2015-08-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-16\' and "productexchangetable_0".thru_z > \'2015-08-16\') where (("productclassificationtable_0".from_z <= \'2015-08-16\' and "productclassificationtable_0".thru_z > \'2015-08-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-16\' and "root".thru_z > \'2015-08-16\' group by "businessDate","productName","exchangeName" UNION ALL select \'2015-08-27\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-08-27\' and "productexchangetable_0".thru_z > \'2015-08-27\') where (("productclassificationtable_0".from_z <= \'2015-08-27\' and "productclassificationtable_0".thru_z > \'2015-08-27\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-08-27\' and "root".thru_z > \'2015-08-27\' group by "businessDate","productName","exchangeName" UNION ALL select \'2015-10-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where (("productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' group by "businessDate","productName","exchangeName" UNION ALL select \'2015-10-17\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') where (("productclassificationtable_0".from_z <= \'2015-10-17\' and "productclassificationtable_0".thru_z > \'2015-10-17\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= \'2015-10-17\' and "root".thru_z > \'2015-10-17\' group by "businessDate","productName","exchangeName") as "unionalias_0"', + 'select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."productName" as "productName", "unionalias_0"."exchangeName" as "exchangeName", "unionalias_0"."count" as "count" from (select DATE\'2015-08-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-08-16\' and "productexchangetable_0".thru_z > DATE\'2015-08-16\') where (("productclassificationtable_0".from_z <= DATE\'2015-08-16\' and "productclassificationtable_0".thru_z > DATE\'2015-08-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-08-16\' and "root".thru_z > DATE\'2015-08-16\' group by "businessDate","productName","exchangeName" UNION ALL select DATE\'2015-08-27\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-08-27\' and "productexchangetable_0".thru_z > DATE\'2015-08-27\') where (("productclassificationtable_0".from_z <= DATE\'2015-08-27\' and "productclassificationtable_0".thru_z > DATE\'2015-08-27\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-08-27\' and "root".thru_z > DATE\'2015-08-27\' group by "businessDate","productName","exchangeName" UNION ALL select DATE\'2015-10-16\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where (("productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\' group by "businessDate","productName","exchangeName" UNION ALL select DATE\'2015-10-17\' as "businessDate", "root".name as "productName", "productexchangetable_0".name as "exchangeName", count("root".name) as "count" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join SystemTable as "systemtable_0" on ("productclassificationtable_0".system = "systemtable_0".name) left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-17\' and "productexchangetable_0".thru_z > DATE\'2015-10-17\') where (("productclassificationtable_0".from_z <= DATE\'2015-10-17\' and "productclassificationtable_0".thru_z > DATE\'2015-10-17\' and "systemtable_0".name = \'SYS1\') or "root".type = \'OPTION\') and "root".from_z <= DATE\'2015-10-17\' and "root".thru_z > DATE\'2015-10-17\' group by "businessDate","productName","exchangeName") as "unionalias_0"', + $result->sqlRemoveFormatting() + ); } @@ -738,7 +1024,11 @@ function <> meta::relational::tests::milestoning::businessdate::testP let result = execute(|Order.all()->filter(o| $o.product(%2015-9-1).name == 'ProductName1'), partiallyMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); let order = $result.values; assertEquals([2, 2], $order.id); - assertEquals('select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".id as id, "root".name as "ProductTablename_ProductTableNoMilestoningname" from ProductTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".id as id, "root".name as "ProductTablename_ProductTableNoMilestoningname" from ProductTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (("unionalias_1"."from_z_0" <= \'2015-09-01\' and "unionalias_1"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) where "unionalias_1"."ProductTablename_ProductTableNoMilestoningname" = \'ProductName1\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".id as id, "root".name as "ProductTablename_ProductTableNoMilestoningname" from ProductTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".id as id, "root".name as "ProductTablename_ProductTableNoMilestoningname" from ProductTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (("unionalias_1"."from_z_0" <= \'2015-09-01\' and "unionalias_1"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) where "unionalias_1"."ProductTablename_ProductTableNoMilestoningname" = \'ProductName1\'', + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".id as id, "root".name as "ProductTablename_ProductTableNoMilestoningname" from ProductTable as "root" where "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".id as id, "root".name as "ProductTablename_ProductTableNoMilestoningname" from ProductTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (("unionalias_1"."from_z_0" <= DATE\'2015-09-01\' and "unionalias_1"."thru_z_0" > DATE\'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) where "unionalias_1"."ProductTablename_ProductTableNoMilestoningname" = \'ProductName1\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testPartiallyMilestoningUnionOperationWithNonTemporalRootWithPropagation():Boolean[1] @@ -746,7 +1036,11 @@ function <> meta::relational::tests::milestoning::businessdate::testP let result = execute(|Order.all()->filter(o| $o.product(%2015-9-1).classification.description == 'STOCK DESC-V2'), partiallyMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); let order = $result.values; assertEquals([1, 1, 2, 2, 1, 1, 2, 2], $order.id); - assertEquals('select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".id as id, "root".type as type_0, null as type_1 from ProductTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".id as id, null as type_0, "root".type as type_1 from ProductTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (("unionalias_1"."from_z_0" <= \'2015-09-01\' and "unionalias_1"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTableNoMilestoning as "root") as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type) and (("unionalias_2"."from_z_0" <= \'2015-09-01\' and "unionalias_2"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."thru_z_0") is null)) where "unionalias_2"."ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" = \'STOCK DESC-V2\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".id as id, "root".type as type_0, null as type_1 from ProductTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".id as id, null as type_0, "root".type as type_1 from ProductTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (("unionalias_1"."from_z_0" <= \'2015-09-01\' and "unionalias_1"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTableNoMilestoning as "root") as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type) and (("unionalias_2"."from_z_0" <= \'2015-09-01\' and "unionalias_2"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."thru_z_0") is null)) where "unionalias_2"."ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" = \'STOCK DESC-V2\'', + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".id as id, "root".type as type_0, null as type_1 from ProductTable as "root" where "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".id as id, null as type_0, "root".type as type_1 from ProductTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (("unionalias_1"."from_z_0" <= DATE\'2015-09-01\' and "unionalias_1"."thru_z_0" > DATE\'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTable as "root" where "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTableNoMilestoning as "root") as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type) and (("unionalias_2"."from_z_0" <= DATE\'2015-09-01\' and "unionalias_2"."thru_z_0" > DATE\'2015-09-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."thru_z_0") is null)) where "unionalias_2"."ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" = \'STOCK DESC-V2\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testPartiallyMilestoningUnionOperationWithTemporalRootWithPropagation():Boolean[1] @@ -754,7 +1048,11 @@ function <> meta::relational::tests::milestoning::businessdate::testP let result = execute(|Product.all(%2015-9-1)->filter(p| $p.classification.description == 'STOCK DESC-V2'), partiallyMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); let product = $result.values; assertEquals([2, 2, 1, 1], $product.id); - assertEquals('select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2015-09-01\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type_0, null as type_1 from ProductTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2015-09-01\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as type_0, "root".type as type_1 from ProductTableNoMilestoning as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (("unionalias_1"."from_z_0" <= \'2015-09-01\' and "unionalias_1"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) where "unionalias_1"."ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" = \'STOCK DESC-V2\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2015-09-01\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type_0, null as type_1 from ProductTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2015-09-01\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as type_0, "root".type as type_1 from ProductTableNoMilestoning as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTable as "root" where "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (("unionalias_1"."from_z_0" <= \'2015-09-01\' and "unionalias_1"."thru_z_0" > \'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) where "unionalias_1"."ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" = \'STOCK DESC-V2\'', + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2015-09-01\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type_0, null as type_1 from ProductTable as "root" where "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-09-01\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2015-09-01\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as type_0, "root".type as type_1 from ProductTableNoMilestoning as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTable as "root" where "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-09-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".type as type, "root".type_description as "ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" from ProductClassificationTableNoMilestoning as "root") as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (("unionalias_1"."from_z_0" <= DATE\'2015-09-01\' and "unionalias_1"."thru_z_0" > DATE\'2015-09-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null)) where "unionalias_1"."ProductClassificationTabletype_description_ProductClassificationTableNoMilestoningtype_description" = \'STOCK DESC-V2\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningContextPropagationForSimplePropertyReferenceWithMultipleJoinsViaProject():Boolean[1] @@ -762,7 +1060,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let businessDate = %2015-9-1; let result = execute(| meta::relational::tests::milestoning::Order.all()->project([o|$o.product($businessDate)->filter(p|$p.name=='ProductName1').name],['productName']) , TestMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['TDSNull','ProductName1'], $result.values.rows->map(r|$r.values->makeString(','))); - assertEquals('select "producttable_0".name as "productName" from OrderTable as "root" left outer join (select "producttable_1".id as id, "producttable_1".from_z as from_z, "producttable_1".thru_z as thru_z, "producttable3_2".name as name from ProductTable as "producttable_1" left outer join (select "producttable2_1".identifier as identifier from ProductTable2 as "producttable2_1" where "producttable2_1".from_z <= \'2015-09-01\' and "producttable2_1".thru_z > \'2015-09-01\') as "producttable2_0" on ("producttable_1".id = "producttable2_0".identifier) left outer join (select "producttable3_1".name as name, "producttable3_1".id as id from ProductTable3 as "producttable3_1" where "producttable3_1".from_z <= \'2015-09-01\' and "producttable3_1".thru_z > \'2015-09-01\') as "producttable3_0" on ("producttable2_0".identifier = "producttable3_0".id) left outer join ProductTable2 as "producttable2_2" on ("producttable_1".id = "producttable2_2".identifier and "producttable2_2".from_z <= \'2015-09-01\' and "producttable2_2".thru_z > \'2015-09-01\') left outer join (select "producttable3_2".name as name, "producttable3_2".id as id from ProductTable3 as "producttable3_2" where "producttable3_2".from_z <= \'2015-09-01\' and "producttable3_2".thru_z > \'2015-09-01\') as "producttable3_2" on ("producttable2_2".identifier = "producttable3_2".id) where "producttable3_0".name = \'ProductName1\') as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-09-01\' and "producttable_0".thru_z > \'2015-09-01\')', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "producttable_0".name as "productName" from OrderTable as "root" left outer join (select "producttable_1".id as id, "producttable_1".from_z as from_z, "producttable_1".thru_z as thru_z, "producttable3_2".name as name from ProductTable as "producttable_1" left outer join (select "producttable2_1".identifier as identifier from ProductTable2 as "producttable2_1" where "producttable2_1".from_z <= \'2015-09-01\' and "producttable2_1".thru_z > \'2015-09-01\') as "producttable2_0" on ("producttable_1".id = "producttable2_0".identifier) left outer join (select "producttable3_1".name as name, "producttable3_1".id as id from ProductTable3 as "producttable3_1" where "producttable3_1".from_z <= \'2015-09-01\' and "producttable3_1".thru_z > \'2015-09-01\') as "producttable3_0" on ("producttable2_0".identifier = "producttable3_0".id) left outer join ProductTable2 as "producttable2_2" on ("producttable_1".id = "producttable2_2".identifier and "producttable2_2".from_z <= \'2015-09-01\' and "producttable2_2".thru_z > \'2015-09-01\') left outer join (select "producttable3_2".name as name, "producttable3_2".id as id from ProductTable3 as "producttable3_2" where "producttable3_2".from_z <= \'2015-09-01\' and "producttable3_2".thru_z > \'2015-09-01\') as "producttable3_2" on ("producttable2_2".identifier = "producttable3_2".id) where "producttable3_0".name = \'ProductName1\') as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-09-01\' and "producttable_0".thru_z > \'2015-09-01\')', + 'select "producttable_0".name as "productName" from OrderTable as "root" left outer join (select "producttable_1".id as id, "producttable_1".from_z as from_z, "producttable_1".thru_z as thru_z, "producttable3_2".name as name from ProductTable as "producttable_1" left outer join (select "producttable2_1".identifier as identifier from ProductTable2 as "producttable2_1" where "producttable2_1".from_z <= DATE\'2015-09-01\' and "producttable2_1".thru_z > DATE\'2015-09-01\') as "producttable2_0" on ("producttable_1".id = "producttable2_0".identifier) left outer join (select "producttable3_1".name as name, "producttable3_1".id as id from ProductTable3 as "producttable3_1" where "producttable3_1".from_z <= DATE\'2015-09-01\' and "producttable3_1".thru_z > DATE\'2015-09-01\') as "producttable3_0" on ("producttable2_0".identifier = "producttable3_0".id) left outer join ProductTable2 as "producttable2_2" on ("producttable_1".id = "producttable2_2".identifier and "producttable2_2".from_z <= DATE\'2015-09-01\' and "producttable2_2".thru_z > DATE\'2015-09-01\') left outer join (select "producttable3_2".name as name, "producttable3_2".id as id from ProductTable3 as "producttable3_2" where "producttable3_2".from_z <= DATE\'2015-09-01\' and "producttable3_2".thru_z > DATE\'2015-09-01\') as "producttable3_2" on ("producttable2_2".identifier = "producttable3_2".id) where "producttable3_0".name = \'ProductName1\') as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-09-01\' and "producttable_0".thru_z > DATE\'2015-09-01\')', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testFilterOnMilestonedClassInProjectWithTDSFilter():Boolean[1] @@ -770,8 +1072,11 @@ function <> meta::relational::tests::milestoning::businessdate::testF let businessDate = %2015-9-1; let result = execute(| meta::relational::tests::milestoning::Order.all()->project([o|$o.product($businessDate)->filter(p|$p.name=='ProductName1').name],['productName'])->filter(x|$x.getString('productName')=='ProductName1') , TestMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['ProductName1'], $result.values.rows->map(r|$r.values->makeString(','))); - assertEquals('select "producttable_0".name as "productName" from OrderTable as "root" left outer join (select "producttable_1".id as id, "producttable_1".from_z as from_z, "producttable_1".thru_z as thru_z, "producttable3_2".name as name from ProductTable as "producttable_1" left outer join (select "producttable2_1".identifier as identifier from ProductTable2 as "producttable2_1" where "producttable2_1".from_z <= \'2015-09-01\' and "producttable2_1".thru_z > \'2015-09-01\') as "producttable2_0" on ("producttable_1".id = "producttable2_0".identifier) left outer join (select "producttable3_1".name as name, "producttable3_1".id as id from ProductTable3 as "producttable3_1" where "producttable3_1".from_z <= \'2015-09-01\' and "producttable3_1".thru_z > \'2015-09-01\') as "producttable3_0" on ("producttable2_0".identifier = "producttable3_0".id) left outer join ProductTable2 as "producttable2_2" on ("producttable_1".id = "producttable2_2".identifier and "producttable2_2".from_z <= \'2015-09-01\' and "producttable2_2".thru_z > \'2015-09-01\') left outer join (select "producttable3_2".name as name, "producttable3_2".id as id from ProductTable3 as "producttable3_2" where "producttable3_2".from_z <= \'2015-09-01\' and "producttable3_2".thru_z > \'2015-09-01\') as "producttable3_2" on ("producttable2_2".identifier = "producttable3_2".id) where "producttable3_0".name = \'ProductName1\') as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-09-01\' and "producttable_0".thru_z > \'2015-09-01\') where "producttable_0".name = \'ProductName1\'', $result->sqlRemoveFormatting()); - + assertEqualsH2Compatible( + 'select "producttable_0".name as "productName" from OrderTable as "root" left outer join (select "producttable_1".id as id, "producttable_1".from_z as from_z, "producttable_1".thru_z as thru_z, "producttable3_2".name as name from ProductTable as "producttable_1" left outer join (select "producttable2_1".identifier as identifier from ProductTable2 as "producttable2_1" where "producttable2_1".from_z <= \'2015-09-01\' and "producttable2_1".thru_z > \'2015-09-01\') as "producttable2_0" on ("producttable_1".id = "producttable2_0".identifier) left outer join (select "producttable3_1".name as name, "producttable3_1".id as id from ProductTable3 as "producttable3_1" where "producttable3_1".from_z <= \'2015-09-01\' and "producttable3_1".thru_z > \'2015-09-01\') as "producttable3_0" on ("producttable2_0".identifier = "producttable3_0".id) left outer join ProductTable2 as "producttable2_2" on ("producttable_1".id = "producttable2_2".identifier and "producttable2_2".from_z <= \'2015-09-01\' and "producttable2_2".thru_z > \'2015-09-01\') left outer join (select "producttable3_2".name as name, "producttable3_2".id as id from ProductTable3 as "producttable3_2" where "producttable3_2".from_z <= \'2015-09-01\' and "producttable3_2".thru_z > \'2015-09-01\') as "producttable3_2" on ("producttable2_2".identifier = "producttable3_2".id) where "producttable3_0".name = \'ProductName1\') as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-09-01\' and "producttable_0".thru_z > \'2015-09-01\') where "producttable_0".name = \'ProductName1\'', + 'select "producttable_0".name as "productName" from OrderTable as "root" left outer join (select "producttable_1".id as id, "producttable_1".from_z as from_z, "producttable_1".thru_z as thru_z, "producttable3_2".name as name from ProductTable as "producttable_1" left outer join (select "producttable2_1".identifier as identifier from ProductTable2 as "producttable2_1" where "producttable2_1".from_z <= DATE\'2015-09-01\' and "producttable2_1".thru_z > DATE\'2015-09-01\') as "producttable2_0" on ("producttable_1".id = "producttable2_0".identifier) left outer join (select "producttable3_1".name as name, "producttable3_1".id as id from ProductTable3 as "producttable3_1" where "producttable3_1".from_z <= DATE\'2015-09-01\' and "producttable3_1".thru_z > DATE\'2015-09-01\') as "producttable3_0" on ("producttable2_0".identifier = "producttable3_0".id) left outer join ProductTable2 as "producttable2_2" on ("producttable_1".id = "producttable2_2".identifier and "producttable2_2".from_z <= DATE\'2015-09-01\' and "producttable2_2".thru_z > DATE\'2015-09-01\') left outer join (select "producttable3_2".name as name, "producttable3_2".id as id from ProductTable3 as "producttable3_2" where "producttable3_2".from_z <= DATE\'2015-09-01\' and "producttable3_2".thru_z > DATE\'2015-09-01\') as "producttable3_2" on ("producttable2_2".identifier = "producttable3_2".id) where "producttable3_0".name = \'ProductName1\') as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-09-01\' and "producttable_0".thru_z > DATE\'2015-09-01\') where "producttable_0".name = \'ProductName1\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testIsolationOfMilestoningFiltersReferencedInAllPartsOfIfStmt():Boolean[1] @@ -779,7 +1084,11 @@ function <> meta::relational::tests::milestoning::businessdate::testI let result = execute(|Order.all()->filter(o| $o.productName(%2015-8-15) == 'ProductName' ), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let orders = $result.values; assertEquals([1], $orders.id); - assertEquals('select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') where case when "producttable_0".name is null then \'empty\' else "producttable_0".name end = \'ProductName\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') where case when "producttable_0".name is null then \'empty\' else "producttable_0".name end = \'ProductName\'', + 'select "root".id as "pk_0", "root".id as "id", "root".orderDate as "orderDate" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-08-15\' and "producttable_0".thru_z > DATE\'2015-08-15\') where case when "producttable_0".name is null then \'empty\' else "producttable_0".name end = \'ProductName\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMultiLevelIsolatedToSubSelectHasCorrectExtraColumns():Boolean[1] @@ -789,7 +1098,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->toOne(); assertEquals(['2, true', '3, false'], $tds.rows->map(r|$r.values->makeString(', '))); - assertEquals('select "root".id as "id", case when "productexchangetable_0".city = \'London\' then \'true\' else \'false\' end as "isBrexitClassificationTypeExchange" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join (select "productexchangetable_1".city as city, "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".thru_z = \'9999-12-31 00:00:00.0000\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id", case when "productexchangetable_0".city = \'London\' then \'true\' else \'false\' end as "isBrexitClassificationTypeExchange" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join (select "productexchangetable_1".city as city, "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".thru_z = \'9999-12-31 00:00:00.0000\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "root".id as "id", cast(case when "productexchangetable_0".city = \'London\' then \'true\' else \'false\' end as boolean) as "isBrexitClassificationTypeExchange" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') left outer join (select "productexchangetable_1".city as city, "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } @@ -805,7 +1118,11 @@ function <> meta::relational::tests::milestoning::businessdate::testM let tds = $result.values->at(0); assertEquals(['ProductName'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name" from ProductTable as "root" where not (not exists(select 1 from OrderTable as "ordertable_0" where "ordertable_0".id = 1 and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\' and "ordertable_0".prodFk = "root".id)) and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name" from ProductTable as "root" where not (not exists(select 1 from OrderTable as "ordertable_0" where "ordertable_0".id = 1 and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\' and "ordertable_0".prodFk = "root".id)) and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\'', + 'select "root".name as "name" from ProductTable as "root" where not (not exists(select 1 from OrderTable as "ordertable_0" where "ordertable_0".id = 1 and "root".from_z <= DATE\'2015-08-15\' and "root".thru_z > DATE\'2015-08-15\' and "ordertable_0".prodFk = "root".id)) and "root".from_z <= DATE\'2015-08-15\' and "root".thru_z > DATE\'2015-08-15\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningFilterPropagationThroughNestedFilter():Boolean[1] @@ -814,21 +1131,33 @@ function <> meta::relational::tests::milestoning::businessdate::testM let tds = $result.values->at(0); assertEquals(['ProductName'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name" from ProductTable as "root" left outer join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) left outer join (select distinct "orderdescriptiontable_0".id from ProductTable as "root" left outer join OrderTable as "ordertable_1" on ("ordertable_1".prodFk = "root".id) left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("ordertable_1".id = "orderdescriptiontable_0".id and "orderdescriptiontable_0".id = 1) where "ordertable_1".id = 1 and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\') as "producttable_1" on ("ordertable_0".id = "producttable_1".id and "producttable_1".id = 1) where ("ordertable_0".id = 1 and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\' and not "producttable_1".id is null) and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name" from ProductTable as "root" left outer join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) left outer join (select distinct "orderdescriptiontable_0".id from ProductTable as "root" left outer join OrderTable as "ordertable_1" on ("ordertable_1".prodFk = "root".id) left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("ordertable_1".id = "orderdescriptiontable_0".id and "orderdescriptiontable_0".id = 1) where "ordertable_1".id = 1 and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\') as "producttable_1" on ("ordertable_0".id = "producttable_1".id and "producttable_1".id = 1) where ("ordertable_0".id = 1 and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\' and not "producttable_1".id is null) and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\'', + 'select "root".name as "name" from ProductTable as "root" left outer join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) left outer join (select distinct "orderdescriptiontable_0".id from ProductTable as "root" left outer join OrderTable as "ordertable_1" on ("ordertable_1".prodFk = "root".id) left outer join OrderDescriptionTable as "orderdescriptiontable_0" on ("ordertable_1".id = "orderdescriptiontable_0".id and "orderdescriptiontable_0".id = 1) where "ordertable_1".id = 1 and "root".from_z <= DATE\'2015-08-15\' and "root".thru_z > DATE\'2015-08-15\') as "producttable_1" on ("ordertable_0".id = "producttable_1".id and "producttable_1".id = 1) where ("ordertable_0".id = 1 and "root".from_z <= DATE\'2015-08-15\' and "root".thru_z > DATE\'2015-08-15\' and not "producttable_1".id is null) and "root".from_z <= DATE\'2015-08-15\' and "root".thru_z > DATE\'2015-08-15\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningFilterPropagationWithNowInFilter():Boolean[1] { // Note: Using now in test deliberately to safegaurd change in sql gen flow. Since change depends on variable date hence not asserting on values but sql let result = execute(|Product.all(%2015-8-15)->filter(p|$p.orders.orderDate->toOne() < now())->project([p|$p.name],['name']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions(), noDebug()); - assertSameSQL('select "root".name as "name" from ProductTable as "root" left outer join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".orderDate < current_timestamp() and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name" from ProductTable as "root" left outer join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".orderDate < current_timestamp() and "root".from_z <= \'2015-08-15\' and "root".thru_z > \'2015-08-15\'', + 'select "root".name as "name" from ProductTable as "root" left outer join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".orderDate < current_timestamp() and "root".from_z <= DATE\'2015-08-15\' and "root".thru_z > DATE\'2015-08-15\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testFilterOnView():Boolean[1] { let query = {|meta::relational::tests::milestoning::Product.all(%2017-6-10)->filter(x|!($x.id->isEmpty()))->project([x|$x.id],['Id'])->distinct()}; let result = meta::pure::router::execute($query,meta::relational::tests::milestoning::viewFilter::MilestoningWithFiltersOnView,meta::relational::tests::testRuntime(),meta::relational::extension::relationalExtensions()); - assertEquals('select distinct "stockproductview_0".id as "Id" from ProductTable as "root" left outer join (select "root".id as id, \'2017-06-10\' as "k_businessDate" from StockProductTable as "root" where ("root".id > 152 or "root".id < 123) and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\') as "stockproductview_0" on ("stockproductview_0".id = "root".id) where not "stockproductview_0".id is null and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', $result->meta::relational::mapping::sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select distinct "stockproductview_0".id as "Id" from ProductTable as "root" left outer join (select "root".id as id, \'2017-06-10\' as "k_businessDate" from StockProductTable as "root" where ("root".id > 152 or "root".id < 123) and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\') as "stockproductview_0" on ("stockproductview_0".id = "root".id) where not "stockproductview_0".id is null and "root".from_z <= \'2017-06-10\' and "root".thru_z > \'2017-06-10\'', + 'select distinct "stockproductview_0".id as "Id" from ProductTable as "root" left outer join (select "root".id as id, \'2017-06-10\' as "k_businessDate" from StockProductTable as "root" where ("root".id > 152 or "root".id < 123) and "root".from_z <= DATE\'2017-06-10\' and "root".thru_z > DATE\'2017-06-10\') as "stockproductview_0" on ("stockproductview_0".id = "root".id) where not "stockproductview_0".id is null and "root".from_z <= DATE\'2017-06-10\' and "root".thru_z > DATE\'2017-06-10\'', + $result->meta::relational::mapping::sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::businessdate::testMilestoningFilterPropagationThroughProject():Boolean[1] @@ -879,7 +1208,11 @@ function <> meta::relational::tests::milestoning::businessdate::testC let tds = $result.values->at(0); assertEquals([%2015-10-15,'ProductName1', %2015-10-15,'ProductName3', %2015-10-16,'ProductName2', %2015-10-16,'ProductName3'],$tds.rows.values); - assertSameSQL('select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."name" as "name" from (select "root".name as "name", cast(truncate(\'2015-10-16\') as date) as "businessDate" from ProductTable as "root" where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' UNION ALL select "root".name as "name", cast(truncate(dateadd(DAY, -1, \'2015-10-16\')) as date) as "businessDate" from ProductTable as "root" where "root".from_z <= dateadd(DAY, -1, \'2015-10-16\') and "root".thru_z > dateadd(DAY, -1, \'2015-10-16\')) as "unionalias_0" order by "businessDate","name"', $result); + assertEqualsH2Compatible( + 'select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."name" as "name" from (select "root".name as "name", cast(truncate(\'2015-10-16\') as date) as "businessDate" from ProductTable as "root" where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\' UNION ALL select "root".name as "name", cast(truncate(dateadd(DAY, -1, \'2015-10-16\')) as date) as "businessDate" from ProductTable as "root" where "root".from_z <= dateadd(DAY, -1, \'2015-10-16\') and "root".thru_z > dateadd(DAY, -1, \'2015-10-16\')) as "unionalias_0" order by "businessDate","name"', + 'select "unionalias_0"."businessDate" as "businessDate", "unionalias_0"."name" as "name" from (select "root".name as "name", cast(truncate(DATE\'2015-10-16\') as date) as "businessDate" from ProductTable as "root" where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\' UNION ALL select "root".name as "name", cast(truncate(dateadd(DAY, -1, DATE\'2015-10-16\')) as date) as "businessDate" from ProductTable as "root" where "root".from_z <= dateadd(DAY, -1, DATE\'2015-10-16\') and "root".thru_z > dateadd(DAY, -1, DATE\'2015-10-16\')) as "unionalias_0" order by "businessDate","name"', + $result->sqlRemoveFormatting() + ); } // workaround for https://github.com/finos/legend-pure/issues/686 diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessSnapshotMilestoning.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessSnapshotMilestoning.pure index b2e8b0ee46c..eb1aa91a997 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessSnapshotMilestoning.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testBusinessSnapshotMilestoning.pure @@ -13,6 +13,7 @@ // limitations under the License. ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::runtime::*; import meta::relational::mapping::*; import meta::relational::tests::*; @@ -22,123 +23,191 @@ import meta::relational::functions::asserts::*; function <> meta::relational::tests::milestoning::snapshot::testQueryOnTemporalRoot():Boolean[1] { let result = execute(|Product.all(%2015-08-26)->filter(p|$p.name == 'ProductName1')->project([p|$p.id],['id']), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = \'2015-08-26\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = \'2015-08-26\'', + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = DATE\'2015-08-26\'', + $result->sqlRemoveFormatting() + ); assertEquals(2, $result.values.rows.get('id')); } function <> meta::relational::tests::milestoning::snapshot::testQueryOnNonTemporalRootWithTemporalProperty():Boolean[1] { let result = execute(|Order.all()->filter(o|$o.product(%2015-08-26).name == 'ProductName1')->project([o|$o.product(%2015-08-26).id],['id']), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "producttablewithbusinesssnapshotmilestoning_0".id as "id" from OrderTable as "root" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("root".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') where "producttablewithbusinesssnapshotmilestoning_0".name = \'ProductName1\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "producttablewithbusinesssnapshotmilestoning_0".id as "id" from OrderTable as "root" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("root".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') where "producttablewithbusinesssnapshotmilestoning_0".name = \'ProductName1\'', + 'select "producttablewithbusinesssnapshotmilestoning_0".id as "id" from OrderTable as "root" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("root".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2015-08-26\') where "producttablewithbusinesssnapshotmilestoning_0".name = \'ProductName1\'', + $result->sqlRemoveFormatting() + ); assertEquals(2, $result.values.rows.get('id')); } function <> meta::relational::tests::milestoning::snapshot::testQueryWithPropagationOnTemporalRoot():Boolean[1] { let result = execute(|Product.all(%2015-08-26)->filter(p|$p.classification.description == 'STOCK DESC-V2')->project([p|$p.classification.type],['type']), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = \'2015-08-26\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = \'2015-08-26\'', + 'select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2015-08-26\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = DATE\'2015-08-26\'', + $result->sqlRemoveFormatting() + ); assertEquals('STOCK', $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::testQueryWithPropagationOnNonTemporalRootWithTemporalProperty():Boolean[1] { let result = execute(|Order.all()->filter(o|$o.product(%2015-08-26).classification.description == 'STOCK DESC-V2')->project([o|$o.product(%2015-08-26).classification.type],['type']), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "productclassificationtablewithbusinesssnapshotmilestoning_1".type as "type" from OrderTable as "root" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("root".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("producttablewithbusinesssnapshotmilestoning_0".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') left outer join (select "productclassificationtablewithbusinesssnapshotmilestoning_2".type as type from ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_2" where "productclassificationtablewithbusinesssnapshotmilestoning_2".snapshotDate = \'2015-08-26\') as "productclassificationtablewithbusinesssnapshotmilestoning_1" on ("producttablewithbusinesssnapshotmilestoning_0".type = "productclassificationtablewithbusinesssnapshotmilestoning_1".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "productclassificationtablewithbusinesssnapshotmilestoning_1".type as "type" from OrderTable as "root" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("root".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("producttablewithbusinesssnapshotmilestoning_0".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2015-08-26\') left outer join (select "productclassificationtablewithbusinesssnapshotmilestoning_2".type as type from ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_2" where "productclassificationtablewithbusinesssnapshotmilestoning_2".snapshotDate = \'2015-08-26\') as "productclassificationtablewithbusinesssnapshotmilestoning_1" on ("producttablewithbusinesssnapshotmilestoning_0".type = "productclassificationtablewithbusinesssnapshotmilestoning_1".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\'', + 'select "productclassificationtablewithbusinesssnapshotmilestoning_1".type as "type" from OrderTable as "root" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("root".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2015-08-26\') left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("producttablewithbusinesssnapshotmilestoning_0".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2015-08-26\') left outer join (select "productclassificationtablewithbusinesssnapshotmilestoning_2".type as type from ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_2" where "productclassificationtablewithbusinesssnapshotmilestoning_2".snapshotDate = DATE\'2015-08-26\') as "productclassificationtablewithbusinesssnapshotmilestoning_1" on ("producttablewithbusinesssnapshotmilestoning_0".type = "productclassificationtablewithbusinesssnapshotmilestoning_1".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\'', + $result->sqlRemoveFormatting() + ); assertEquals('STOCK', $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::testUnionQueryOnTemporalRoot():Boolean[1] { let result = execute(|Product.all(%2015-08-26)->filter(p|$p.name == 'ProductName1')->project([p|$p.id],['id']), businessSnapshotMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "pk_0_0", null as "pk_0_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", null as "pk_0_0", "root".id as "pk_0_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionBase" where "unionBase"."ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname" = \'ProductName1\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "pk_0_0", null as "pk_0_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", null as "pk_0_0", "root".id as "pk_0_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionBase" where "unionBase"."ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname" = \'ProductName1\'', + 'select "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "pk_0_0", null as "pk_0_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", null as "pk_0_0", "root".id as "pk_0_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\') as "unionBase" where "unionBase"."ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname" = \'ProductName1\'', + $result->sqlRemoveFormatting() + ); assertEquals([2, 2], $result.values.rows.get('id')); } function <> meta::relational::tests::milestoning::snapshot::testUnionQueryOnNonTemporalRootWithTemporalProperty():Boolean[1] { let result = execute(|Order.all()->filter(o|$o.product(%2015-08-26).name == 'ProductName1')->project([o|$o.product(%2015-08-26).id],['id']), businessSnapshotMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "unionalias_1"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id" from (select "root".prodFk as prodFk_0, null as prodFk_1, "root".id as "pk_0_0", null as "pk_0_1" from OrderTable as "root" UNION ALL select null as prodFk_0, "root".prodFk as prodFk_1, null as "pk_0_0", "root".id as "pk_0_1" from OrderTable as "root") as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as id, "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as id, "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname" = \'ProductName1\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionalias_1"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id" from (select "root".prodFk as prodFk_0, null as prodFk_1, "root".id as "pk_0_0", null as "pk_0_1" from OrderTable as "root" UNION ALL select null as prodFk_0, "root".prodFk as prodFk_1, null as "pk_0_0", "root".id as "pk_0_1" from OrderTable as "root") as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as id, "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as id, "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname" = \'ProductName1\'', + 'select "unionalias_1"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id" from (select "root".prodFk as prodFk_0, null as prodFk_1, "root".id as "pk_0_0", null as "pk_0_1" from OrderTable as "root" UNION ALL select null as prodFk_0, "root".prodFk as prodFk_1, null as "pk_0_0", "root".id as "pk_0_1" from OrderTable as "root") as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as id, "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as id, "root".name as "ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\') as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = DATE\'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductTableWithBusinessSnapshotMilestoningname_ProductTableWithBusinessSnapshotMilestoningname" = \'ProductName1\'', + $result->sqlRemoveFormatting() + ); assertEquals([2, 2, 2, 2], $result.values.rows.get('id')); } function <> meta::relational::tests::milestoning::snapshot::testUnionQueryWithPropagationOnTemporalRoot():Boolean[1] { let result = execute(|Product.all(%2015-08-26)->filter(p|$p.classification.description == 'STOCK DESC-V2')->project([p|$p.classification.type],['type']), businessSnapshotMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + 'select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\') as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\') as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = DATE\'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + $result->sqlRemoveFormatting() + ); assertEquals(['STOCK', 'STOCK', 'STOCK', 'STOCK'], $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::testUnionQueryWithPropagationOnNonTemporalRootWithTemporalProperty():Boolean[1] { let result = execute(|Order.all()->filter(o|$o.product(%2015-08-26).classification.description == 'STOCK DESC-V2')->project([o|$o.product(%2015-08-26).classification.type],['type']), businessSnapshotMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "unionalias_3"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".prodFk as prodFk_0, null as prodFk_1, "root".id as "pk_0_0", null as "pk_0_1" from OrderTable as "root" UNION ALL select null as prodFk_0, "root".prodFk as prodFk_1, null as "pk_0_0", "root".id as "pk_0_1" from OrderTable as "root") as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as id, "root".type as type_0, null as type_1 from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as id, null as type_0, "root".type as type_1 from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type) and (coalesce("unionalias_2"."snapshotDate_0", "unionalias_2"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_2"."snapshotDate_0", "unionalias_2"."snapshotDate_1") is null)) left outer join (select "unionalias_4".type as type, "unionalias_4"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_4" where coalesce("unionalias_4"."snapshotDate_0", "unionalias_4"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_4"."snapshotDate_0", "unionalias_4"."snapshotDate_1") is null) as "unionalias_3" on ("unionalias_1".type_0 = "unionalias_3".type or "unionalias_1".type_1 = "unionalias_3".type) where "unionalias_2"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionalias_3"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".prodFk as prodFk_0, null as prodFk_1, "root".id as "pk_0_0", null as "pk_0_1" from OrderTable as "root" UNION ALL select null as prodFk_0, "root".prodFk as prodFk_1, null as "pk_0_0", "root".id as "pk_0_1" from OrderTable as "root") as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as id, "root".type as type_0, null as type_1 from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as id, null as type_0, "root".type as type_1 from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type) and (coalesce("unionalias_2"."snapshotDate_0", "unionalias_2"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_2"."snapshotDate_0", "unionalias_2"."snapshotDate_1") is null)) left outer join (select "unionalias_4".type as type, "unionalias_4"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2015-08-26\') as "unionalias_4" where coalesce("unionalias_4"."snapshotDate_0", "unionalias_4"."snapshotDate_1") = \'2015-08-26\' or coalesce("unionalias_4"."snapshotDate_0", "unionalias_4"."snapshotDate_1") is null) as "unionalias_3" on ("unionalias_1".type_0 = "unionalias_3".type or "unionalias_1".type_1 = "unionalias_3".type) where "unionalias_2"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + 'select "unionalias_3"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".prodFk as prodFk_0, null as prodFk_1, "root".id as "pk_0_0", null as "pk_0_1" from OrderTable as "root" UNION ALL select null as prodFk_0, "root".prodFk as prodFk_1, null as "pk_0_0", "root".id as "pk_0_1" from OrderTable as "root") as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as id, "root".type as type_0, null as type_1 from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as id, null as type_0, "root".type as type_1 from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\') as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = DATE\'2015-08-26\' or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\') as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type) and (coalesce("unionalias_2"."snapshotDate_0", "unionalias_2"."snapshotDate_1") = DATE\'2015-08-26\' or coalesce("unionalias_2"."snapshotDate_0", "unionalias_2"."snapshotDate_1") is null)) left outer join (select "unionalias_4".type as type, "unionalias_4"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\') as "unionalias_4" where coalesce("unionalias_4"."snapshotDate_0", "unionalias_4"."snapshotDate_1") = DATE\'2015-08-26\' or coalesce("unionalias_4"."snapshotDate_0", "unionalias_4"."snapshotDate_1") is null) as "unionalias_3" on ("unionalias_1".type_0 = "unionalias_3".type or "unionalias_1".type_1 = "unionalias_3".type) where "unionalias_2"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + $result->sqlRemoveFormatting() + ); assertEquals(['STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK', 'STOCK'], $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::testAllVersionInRangeForBuisnessSnapshotMilestoning():Boolean[1] { let result = execute(|Product.allVersionsInRange(%2012-1-1, %2016-1-1)->filter(p|$p.name == 'ProductName1')->project([p|$p.id],['id']), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate >= \'2012-01-01\' and "root".snapshotDate <= \'2016-01-01\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate >= \'2012-01-01\' and "root".snapshotDate <= \'2016-01-01\'', + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate >= DATE\'2012-01-01\' and "root".snapshotDate <= DATE\'2016-01-01\'', + $result->sqlRemoveFormatting() + ); assertEquals(2, $result.values.rows.get('id')); } function <> meta::relational::tests::milestoning::snapshot::testBuisnessSnapshotRangeQueryOnProperty():Boolean[1] { let result = execute(|Product.allVersions()->filter(x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type == 'STOCK')->project([x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type], ['type'])->distinct(), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate >= \'2015-01-01\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate <= \'2015-09-01\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'STOCK\'', $result); + assertEqualsH2Compatible( + 'select distinct "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate >= \'2015-01-01\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate <= \'2015-09-01\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'STOCK\'', + 'select distinct "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate >= DATE\'2015-01-01\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate <= DATE\'2015-09-01\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'STOCK\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['STOCK'], $result.values.rows.getString('type')); } function <> meta::relational::tests::milestoning::rangeQuery::testBuisnessSnapshotRangeQueryOnRootAndProperty():Boolean[1] { let result = execute(|Product.allVersionsInRange(%2015-1-1, %2015-9-1)->filter(x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type == 'STOCK')->project([x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type], ['type'])->distinct(), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate >= \'2015-01-01\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate <= \'2015-09-01\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'STOCK\' and "root".snapshotDate >= \'2015-01-01\' and "root".snapshotDate <= \'2015-09-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate >= \'2015-01-01\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate <= \'2015-09-01\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'STOCK\' and "root".snapshotDate >= \'2015-01-01\' and "root".snapshotDate <= \'2015-09-01\'', + 'select distinct "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate >= DATE\'2015-01-01\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate <= DATE\'2015-09-01\') where "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'STOCK\' and "root".snapshotDate >= DATE\'2015-01-01\' and "root".snapshotDate <= DATE\'2015-09-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['STOCK'], $result.values.rows.getString('type')); } function <> meta::relational::tests::milestoning::snapshot::testDateTimeMilestoningParam():Boolean[1] { let result = execute(|Product.all(%2015-08-26T02:00:00)->filter(p|$p.name == 'ProductName1')->project([p|$p.id],['id']), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)', + $result->sqlRemoveFormatting() + ); assertEquals(2, $result.values.rows.get('id')); } function <> meta::relational::tests::milestoning::snapshot::testDateTimeVariableMilestoningParam():Boolean[1] { let result = execute({|let dt = '2015-08-26T02:00:00'->parseDate(); Product.all($dt)->filter(p|$p.name == 'ProductName1')->project([p|$p.id],['id']);}, businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', + 'select "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".name = \'ProductName1\' and "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)', + $result->sqlRemoveFormatting() + ); assertEquals(2, $result.values.rows.get('id')); } function <> meta::relational::tests::milestoning::snapshot::testDateTimeMilestoningParamPropagation():Boolean[1] { let result = execute(|Product.all(%2015-08-26T02:00:00)->filter(p|$p.classification.description == 'STOCK DESC-V2')->project([p|$p.classification.type],['type']), businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', + 'select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)', + $result->sqlRemoveFormatting() + ); assertEquals('STOCK', $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::testDateTimeVariableMilestoningParamPropagation():Boolean[1] { let result = execute({|let dt = '2015-08-26T02:00:00'->parseDate(); Product.all($dt)->filter(p|$p.classification.description == 'STOCK DESC-V2')->project([p|$p.classification.type],['type']);}, businessSnapshotMilestoningMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)', + 'select "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)) where "productclassificationtablewithbusinesssnapshotmilestoning_0".type_description = \'STOCK DESC-V2\' and "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)', + $result->sqlRemoveFormatting() + ); assertEquals('STOCK', $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::testDateTimeMilestoningParamUnion():Boolean[1] { let result = execute(|Product.all(%2015-08-26T02:00:00)->filter(p|$p.classification.description == 'STOCK DESC-V2')->project([p|$p.classification.type],['type']), businessSnapshotMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = cast(truncate(\'2015-08-26 02:00:00\') as date) or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = cast(truncate(\'2015-08-26 02:00:00\') as date) or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + 'select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)) as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)) as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date) or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + $result->sqlRemoveFormatting() + ); assertEquals(['STOCK', 'STOCK', 'STOCK', 'STOCK'], $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::testDateTimeVariableMilestoningParamUnion():Boolean[1] { let result = execute({|let dt = '2015-08-26T02:00:00'->parseDate(); Product.all($dt)->filter(p|$p.classification.description == 'STOCK DESC-V2')->project([p|$p.classification.type],['type']);}, businessSnapshotMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = cast(truncate(\'2015-08-26 02:00:00\') as date) or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(\'2015-08-26 02:00:00\') as date)) as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = cast(truncate(\'2015-08-26 02:00:00\') as date) or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + 'select "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" as "type" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type_0, null as type_1, "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", null as type_0, "root".type as type_1, null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)) as "unionBase" left outer join (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date) UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".type as type, "root".type_description as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description", "root".type as "ProductClassificationTableWithBusinessSnapshotMilestoningtype_ProductClassificationTableWithBusinessSnapshotMilestoningtype" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date)) as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type) and (coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") = cast(truncate(TIMESTAMP\'2015-08-26 02:00:00\') as date) or coalesce("unionalias_1"."snapshotDate_0", "unionalias_1"."snapshotDate_1") is null)) where "unionalias_1"."ProductClassificationTableWithBusinessSnapshotMilestoningtype_description_ProductClassificationTableWithBusinessSnapshotMilestoningtype_description" = \'STOCK DESC-V2\'', + $result->sqlRemoveFormatting() + ); assertEquals(['STOCK', 'STOCK', 'STOCK', 'STOCK'], $result.values.rows.get('type')); } function <> meta::relational::tests::milestoning::snapshot::setUp():Runtime[1] { initDatabase(); -} \ No newline at end of file +} diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testGetAllForEachDate.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testGetAllForEachDate.pure index 74032a694da..9809e77d8d8 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testGetAllForEachDate.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testGetAllForEachDate.pure @@ -13,6 +13,8 @@ // limitations under the License. ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::relational::tests::csv::*; import meta::pure::runtime::*; @@ -77,7 +79,11 @@ function <> meta::relational::tests::milestoning:: 'ProductName3,2020-01-11\n'; let actualValue = $result.values->toCSV(); assertSameElements($expectedValue, $actualValue); - assertSameSQL('select "root".name as "name", "calendartable_0".calendar_date as "date" from (select "root".calendar_date from CalendarTable as "root" where ("root".calendar_date > \'2020-01-02\' and "root".calendar_date < \'2020-01-15\')) as "calendartable_0" left outer join ProductTable as "root" on ("root".from_z <= "calendartable_0".calendar_date and "root".thru_z > "calendartable_0".calendar_date) where "root".name = \'ProductName3\'',$result); + assertEqualsH2Compatible( + 'select "root".name as "name", "calendartable_0".calendar_date as "date" from (select "root".calendar_date from CalendarTable as "root" where ("root".calendar_date > \'2020-01-02\' and "root".calendar_date < \'2020-01-15\')) as "calendartable_0" left outer join ProductTable as "root" on ("root".from_z <= "calendartable_0".calendar_date and "root".thru_z > "calendartable_0".calendar_date) where "root".name = \'ProductName3\'', + 'select "root".name as "name", "calendartable_0".calendar_date as "date" from (select "root".calendar_date from CalendarTable as "root" where ("root".calendar_date > DATE\'2020-01-02\' and "root".calendar_date < DATE\'2020-01-15\')) as "calendartable_0" left outer join ProductTable as "root" on ("root".from_z <= "calendartable_0".calendar_date and "root".thru_z > "calendartable_0".calendar_date) where "root".name = \'ProductName3\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::temporalDateProjectionQuery::testProcessingTemporalQueryWithInnerQueryWithQualifiedProperty():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testInheritanceMappingWithMilestonedTypes.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testInheritanceMappingWithMilestonedTypes.pure index e74b09d5386..c157c6012cb 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testInheritanceMappingWithMilestonedTypes.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testInheritanceMappingWithMilestonedTypes.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; import meta::relational::metamodel::execute::*; @@ -26,7 +27,11 @@ function <> meta::relational::tests::milestoning: { let result = execute(|Order.all()->project([o|$o.id, o|$o.product(%2016-9-23).synonymsByType('CUSIP').createActivity.createdBy], ['orderId','productSynonymCreator']), inheritanceUnionMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['1,TDSNull', '2,smith', '2,smith', '2,smith', '2,smith'], $result.values->at(0).rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "productsynonymintermediate_0"."ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" as "productSynonymCreator" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) where "producttable_0".from_z <= \'2016-09-23\' and "producttable_0".thru_z > \'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId) left outer join (select "productsynonymintermediate_1".prodId as prodId, "unionalias_0"."ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from productSynonymIntermediate as "productsynonymintermediate_1" inner join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".prodId as prodId_0, null as prodId_1, \'CUSIP\' as "CUSIP_ISIN", "root".createdBy as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from ProductSynonymTable as "root" UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as prodId_0, "root".prodId as prodId_1, \'ISIN\' as "CUSIP_ISIN", "root".createdBy as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from ProductSynonymTable as "root") as "unionalias_0" on ("productsynonymintermediate_1".synProdId = "unionalias_0".prodId_0 or "productsynonymintermediate_1".synProdId = "unionalias_0".prodId_1) where "unionalias_0"."CUSIP_ISIN" = \'CUSIP\') as "productsynonymintermediate_0" on ("orderproductintermediate_0".id = "productsynonymintermediate_0".prodId)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "productsynonymintermediate_0"."ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" as "productSynonymCreator" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) where "producttable_0".from_z <= \'2016-09-23\' and "producttable_0".thru_z > \'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId) left outer join (select "productsynonymintermediate_1".prodId as prodId, "unionalias_0"."ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from productSynonymIntermediate as "productsynonymintermediate_1" inner join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".prodId as prodId_0, null as prodId_1, \'CUSIP\' as "CUSIP_ISIN", "root".createdBy as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from ProductSynonymTable as "root" UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as prodId_0, "root".prodId as prodId_1, \'ISIN\' as "CUSIP_ISIN", "root".createdBy as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from ProductSynonymTable as "root") as "unionalias_0" on ("productsynonymintermediate_1".synProdId = "unionalias_0".prodId_0 or "productsynonymintermediate_1".synProdId = "unionalias_0".prodId_1) where "unionalias_0"."CUSIP_ISIN" = \'CUSIP\') as "productsynonymintermediate_0" on ("orderproductintermediate_0".id = "productsynonymintermediate_0".prodId)', + 'select "root".id as "orderId", "productsynonymintermediate_0"."ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" as "productSynonymCreator" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) where "producttable_0".from_z <= DATE\'2016-09-23\' and "producttable_0".thru_z > DATE\'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId) left outer join (select "productsynonymintermediate_1".prodId as prodId, "unionalias_0"."ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from productSynonymIntermediate as "productsynonymintermediate_1" inner join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".prodId as prodId_0, null as prodId_1, \'CUSIP\' as "CUSIP_ISIN", "root".createdBy as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from ProductSynonymTable as "root" UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as prodId_0, "root".prodId as prodId_1, \'ISIN\' as "CUSIP_ISIN", "root".createdBy as "ProductSynonymTablecreatedBy_ProductSynonymTablecreatedBy" from ProductSynonymTable as "root") as "unionalias_0" on ("productsynonymintermediate_1".synProdId = "unionalias_0".prodId_0 or "productsynonymintermediate_1".synProdId = "unionalias_0".prodId_1) where "unionalias_0"."CUSIP_ISIN" = \'CUSIP\') as "productsynonymintermediate_0" on ("orderproductintermediate_0".id = "productsynonymintermediate_0".prodId)', + $result->sqlRemoveFormatting() + ); } //Alloy Exclusion Reason: Store Resolution Wrong (Cant Find Join) @@ -34,7 +39,11 @@ function <> meta::relational::tests::milestoning: { let result = execute(|Order.all()->project([o|$o.id, o|$o.product(%2016-9-23)->filter(p|($p.id==1 || $p.id==2) && $p.referenceSystem.name=='SYS1').id], ['orderId','filteredProductId']), inheritanceUnionMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['1,TDSNull', '2,2'], $result.values->at(0).rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "orderproductintermediate_0".id as "filteredProductId" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id, "producttable_0".referenceSystemName as referenceSystemName from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) left outer join SystemTable as "systemtable_0" on ("producttable_0".referenceSystemName = "systemtable_0".name) where (("producttable_0".id = 1 or "producttable_0".id = 2) and "systemtable_0".name = \'SYS1\') and "producttable_0".from_z <= \'2016-09-23\' and "producttable_0".thru_z > \'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "orderproductintermediate_0".id as "filteredProductId" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id, "producttable_0".referenceSystemName as referenceSystemName from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) left outer join SystemTable as "systemtable_0" on ("producttable_0".referenceSystemName = "systemtable_0".name) where (("producttable_0".id = 1 or "producttable_0".id = 2) and "systemtable_0".name = \'SYS1\') and "producttable_0".from_z <= \'2016-09-23\' and "producttable_0".thru_z > \'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId)', + 'select "root".id as "orderId", "orderproductintermediate_0".id as "filteredProductId" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id, "producttable_0".referenceSystemName as referenceSystemName from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) left outer join SystemTable as "systemtable_0" on ("producttable_0".referenceSystemName = "systemtable_0".name) where (("producttable_0".id = 1 or "producttable_0".id = 2) and "systemtable_0".name = \'SYS1\') and "producttable_0".from_z <= DATE\'2016-09-23\' and "producttable_0".thru_z > DATE\'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId)', + $result->sqlRemoveFormatting() + ); } //Alloy Exclusion Reason: Store Resolution Wrong (Cant Find Join) @@ -42,7 +51,11 @@ function <> meta::relational::tests::milestoning: { let result = execute(|Order.all()->project([o|$o.id, o|$o.product(%2016-9-23)->filter(p|$p.id==2).id, o|$o.product(%2016-9-23)->filter(p|$p.id==2).name], ['orderId','productId','productName']), inheritanceUnionMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['1,TDSNull,TDSNull', '2,2,ProductName2'], $result.values->at(0).rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "orderproductintermediate_0".id as "productId", "orderproductintermediate_0".name as "productName" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id, "producttable_0".name as name from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) where "producttable_0".from_z <= \'2016-09-23\' and "producttable_0".thru_z > \'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId and "orderproductintermediate_0".id = 2)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "orderproductintermediate_0".id as "productId", "orderproductintermediate_0".name as "productName" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id, "producttable_0".name as name from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) where "producttable_0".from_z <= \'2016-09-23\' and "producttable_0".thru_z > \'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId and "orderproductintermediate_0".id = 2)', + 'select "root".id as "orderId", "orderproductintermediate_0".id as "productId", "orderproductintermediate_0".name as "productName" from OrderTable as "root" left outer join (select "orderproductintermediate_1".orderId as orderId, "producttable_0".id as id, "producttable_0".name as name from orderProductIntermediate as "orderproductintermediate_1" inner join ProductTable as "producttable_0" on ("orderproductintermediate_1".prodId = "producttable_0".id) where "producttable_0".from_z <= DATE\'2016-09-23\' and "producttable_0".thru_z > DATE\'2016-09-23\') as "orderproductintermediate_0" on ("root".id = "orderproductintermediate_0".orderId and "orderproductintermediate_0".id = 2)', + $result->sqlRemoveFormatting() + ); } @@ -51,7 +64,11 @@ function <> meta::relational::tests::milestoning: { let result = execute(|BiTemporalProduct.all(%2018-05-10, %2018-05-09)->project([p|$p.name, p|$p.type],['name', 'type']), inheritanceUnionMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['p1s1,STOCK', 'p2s1,STOCK', 'p3s1,STOCK', 'p10s2,notSet', 'p11s2,notSet'], $result.values->at(0).rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "unionBase"."BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename" as "name", "unionBase"."BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" as "type" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", "productclassificationtable_0".type as "BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" from BiTemporalProductTable_Out_From_Inclusive as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2018-05-09\' and "productclassificationtable_0".thru_z > \'2018-05-09\') where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z <= \'2018-05-09\' and "root".thru_z > \'2018-05-09\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", \'notSet\' as "BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z < \'2018-05-09\' and "root".thru_z >= \'2018-05-09\') as "unionBase"', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase"."BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename" as "name", "unionBase"."BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" as "type" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", "productclassificationtable_0".type as "BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" from BiTemporalProductTable_Out_From_Inclusive as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2018-05-09\' and "productclassificationtable_0".thru_z > \'2018-05-09\') where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z <= \'2018-05-09\' and "root".thru_z > \'2018-05-09\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", \'notSet\' as "BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z < \'2018-05-09\' and "root".thru_z >= \'2018-05-09\') as "unionBase"', + 'select "unionBase"."BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename" as "name", "unionBase"."BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" as "type" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", "productclassificationtable_0".type as "BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" from BiTemporalProductTable_Out_From_Inclusive as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2018-05-09\' and "productclassificationtable_0".thru_z > DATE\'2018-05-09\') where "root".in_z < DATE\'2018-05-10\' and "root".out_z >= DATE\'2018-05-10\' and "root".from_z <= DATE\'2018-05-09\' and "root".thru_z > DATE\'2018-05-09\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", \'notSet\' as "BiTemporalProductTable_Out_From_Inclusive_ClassificationProductClassificationTabletype_notSet" from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".in_z < DATE\'2018-05-10\' and "root".out_z >= DATE\'2018-05-10\' and "root".from_z < DATE\'2018-05-09\' and "root".thru_z >= DATE\'2018-05-09\') as "unionBase"', + $result->sqlRemoveFormatting() + ); } //Alloy Exclusion Reason: Store Resolution Wrong (Cant Find Join) @@ -59,7 +76,11 @@ function <> meta::relational::tests::milestoning: { let result = execute(|BiTemporalProduct.all(%2018-05-10, %2018-05-09)->project([p|$p.name,p|$p.classification.type],['name', 'type']), inheritanceUnionMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['p1s1,STOCK', 'p2s1,STOCK', 'p3s1,STOCK', 'p10s2,STOCK', 'p11s2,STOCK'], $result.values->at(0).rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "unionBase"."BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename" as "name", "productclassificationtable_0".type as "type" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", "root".type as type_0, null as type_1 from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z <= \'2018-05-09\' and "root".thru_z > \'2018-05-09\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", null as type_0, "root".type as type_1 from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z < \'2018-05-09\' and "root".thru_z >= \'2018-05-09\') as "unionBase" left outer join ProductClassificationTable as "productclassificationtable_0" on (("unionBase".type_0 = "productclassificationtable_0".type or "unionBase".type_1 = "productclassificationtable_0".type) and "productclassificationtable_0".from_z <= \'2018-05-09\' and "productclassificationtable_0".thru_z > \'2018-05-09\')', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase"."BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename" as "name", "productclassificationtable_0".type as "type" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", "root".type as type_0, null as type_1 from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z <= \'2018-05-09\' and "root".thru_z > \'2018-05-09\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", null as type_0, "root".type as type_1 from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".in_z < \'2018-05-10\' and "root".out_z >= \'2018-05-10\' and "root".from_z < \'2018-05-09\' and "root".thru_z >= \'2018-05-09\') as "unionBase" left outer join ProductClassificationTable as "productclassificationtable_0" on (("unionBase".type_0 = "productclassificationtable_0".type or "unionBase".type_1 = "productclassificationtable_0".type) and "productclassificationtable_0".from_z <= \'2018-05-09\' and "productclassificationtable_0".thru_z > \'2018-05-09\')', + 'select "unionBase"."BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename" as "name", "productclassificationtable_0".type as "type" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", "root".type as type_0, null as type_1 from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < DATE\'2018-05-10\' and "root".out_z >= DATE\'2018-05-10\' and "root".from_z <= DATE\'2018-05-09\' and "root".thru_z > DATE\'2018-05-09\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".name as "BiTemporalProductTable_Out_From_Inclusivename_BiTemporalProductTable_Out_Thru_Inclusivename", null as type_0, "root".type as type_1 from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".in_z < DATE\'2018-05-10\' and "root".out_z >= DATE\'2018-05-10\' and "root".from_z < DATE\'2018-05-09\' and "root".thru_z >= DATE\'2018-05-09\') as "unionBase" left outer join ProductClassificationTable as "productclassificationtable_0" on (("unionBase".type_0 = "productclassificationtable_0".type or "unionBase".type_1 = "productclassificationtable_0".type) and "productclassificationtable_0".from_z <= DATE\'2018-05-09\' and "productclassificationtable_0".thru_z > DATE\'2018-05-09\')', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::inheritance::union::createTablesAndFillDb():Any[0..1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningContextPropagation.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningContextPropagation.pure index 428b3b3133e..542cfcc1e91 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningContextPropagation.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningContextPropagation.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::pure::runtime::*; import meta::relational::mapping::*; @@ -33,7 +34,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['system A order description 1', 'system A order description 2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "systemaorderdescriptiontable_0".description as "systemADescription" from OrderTable as "root" left outer join OrderToSystemADescriptions as "ordertosystemadescriptions_0" on ("root".id = "ordertosystemadescriptions_0".orderId and "ordertosystemadescriptions_0".from_z <= \'2015-08-14\' and "ordertosystemadescriptions_0".thru_z > \'2015-08-14\') left outer join SystemAOrderDescriptionTable as "systemaorderdescriptiontable_0" on ("ordertosystemadescriptions_0".systemADescriptionId = "systemaorderdescriptiontable_0".descriptionId)', $result); + assertEqualsH2Compatible( + 'select "systemaorderdescriptiontable_0".description as "systemADescription" from OrderTable as "root" left outer join OrderToSystemADescriptions as "ordertosystemadescriptions_0" on ("root".id = "ordertosystemadescriptions_0".orderId and "ordertosystemadescriptions_0".from_z <= \'2015-08-14\' and "ordertosystemadescriptions_0".thru_z > \'2015-08-14\') left outer join SystemAOrderDescriptionTable as "systemaorderdescriptiontable_0" on ("ordertosystemadescriptions_0".systemADescriptionId = "systemaorderdescriptiontable_0".descriptionId)', + 'select "systemaorderdescriptiontable_0".description as "systemADescription" from OrderTable as "root" left outer join OrderToSystemADescriptions as "ordertosystemadescriptions_0" on ("root".id = "ordertosystemadescriptions_0".orderId and "ordertosystemadescriptions_0".from_z <= DATE\'2015-08-14\' and "ordertosystemadescriptions_0".thru_z > DATE\'2015-08-14\') left outer join SystemAOrderDescriptionTable as "systemaorderdescriptiontable_0" on ("ordertosystemadescriptions_0".systemADescriptionId = "systemaorderdescriptiontable_0".descriptionId)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testExtraColumnsAreNotAppliedToIntermediateMilestonedJoinTables():Boolean[1] @@ -44,7 +49,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName', 'TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-08-15\' and "stockproducttable_1".thru_z > \'2015-08-15\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', $result); + assertEqualsH2Compatible( + 'select "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-08-15\' and "stockproducttable_1".thru_z > \'2015-08-15\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', + 'select "productdescriptiontable_0".description as "stockProductName" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-08-15\' and "producttable_0".thru_z > DATE\'2015-08-15\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= DATE\'2015-08-15\' and "stockproducttable_1".thru_z > DATE\'2015-08-15\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersAppliedToIntermediateMilestonedJoinTablesWhereSourceIsEmbeddedTargetTypeIsNonTemporalAndTargetMainTableIsNotMilestoned():Boolean[1] @@ -55,8 +64,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['SYS1', 'SYS1'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "systemtable_0".name as "systemName" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-16\' and "productclassificationsystemtable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); - + assertEqualsH2Compatible( + 'select "systemtable_0".name as "systemName" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-16\' and "productclassificationsystemtable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "systemtable_0".name as "systemName" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationsystemtable_0".thru_z > DATE\'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersPropogatedToDataTypePropertiesFromAllInProject():Boolean[1] @@ -67,13 +79,21 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testLatestMilestoningFiltersPropogatedToDataTypePropertiesFromAllInProject():Boolean[1] { let result = execute(|Product.all(%latest)->project([p|$p.name, p|$p.classificationType],['name','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') where "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') where "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') where "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersPropogatedFromAllThroughFilterToDataTypePropertiesInProject():Boolean[1] @@ -84,7 +104,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersPropogatedToDataTypePropertiesFromAllInFilter():Boolean[1] @@ -94,7 +118,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let result = execute(|Product.all($businessDate)->filter(p|$p.classificationType == ProductClassificationType.STOCK), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals([ProductClassificationType.STOCK], $result.values->map(p|$p.classificationType)); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersNotPropogatedFromAllToNonTemporalClassMappedToTemporalTable():Boolean[1] @@ -105,7 +133,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['2,smith', '3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "name", "newactivityinfotable_0".created_by as "classificationType" from ProductTable as "root" left outer join NewActivityInfoTable as "newactivityinfotable_0" on ("root".id = "newactivityinfotable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "name", "newactivityinfotable_0".created_by as "classificationType" from ProductTable as "root" left outer join NewActivityInfoTable as "newactivityinfotable_0" on ("root".id = "newactivityinfotable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "name", "newactivityinfotable_0".created_by as "classificationType" from ProductTable as "root" left outer join NewActivityInfoTable as "newactivityinfotable_0" on ("root".id = "newactivityinfotable_0".productId) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersUsedOnIntermediateJoinOnlyFromAllToNonTemporalClassMappedToTemporalTable():Boolean[1] @@ -116,7 +148,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['2,smith', '3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "name", "newactivityinfotable_0".created_by as "classificationType" from ProductTable as "root" left outer join CancelActivitiesTable as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId and "cancelactivitiestable_0".from_z <= \'2015-10-16\' and "cancelactivitiestable_0".thru_z > \'2015-10-16\') left outer join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_0".productId = "newactivityinfotable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "name", "newactivityinfotable_0".created_by as "classificationType" from ProductTable as "root" left outer join CancelActivitiesTable as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId and "cancelactivitiestable_0".from_z <= \'2015-10-16\' and "cancelactivitiestable_0".thru_z > \'2015-10-16\') left outer join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_0".productId = "newactivityinfotable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "name", "newactivityinfotable_0".created_by as "classificationType" from ProductTable as "root" left outer join CancelActivitiesTable as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId and "cancelactivitiestable_0".from_z <= DATE\'2015-10-16\' and "cancelactivitiestable_0".thru_z > DATE\'2015-10-16\') left outer join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_0".productId = "newactivityinfotable_0".productId) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersUsedOnIntermediateJoinOnlyFromAllToNonTemporalClassMappedToTemporalTableWithFilter():Boolean[1] @@ -127,14 +163,22 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['2,smith', '3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "name", "cancelactivitiestable_0".created_by as "classificationType" from ProductTable as "root" left outer join (select "cancelactivitiestable_1".productId as productId, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_1" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_1".productId = "newactivityinfotable_0".productId) where "newactivityinfotable_0".productId > 0 and "cancelactivitiestable_1".from_z <= \'2015-10-16\' and "cancelactivitiestable_1".thru_z > \'2015-10-16\') as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "name", "cancelactivitiestable_0".created_by as "classificationType" from ProductTable as "root" left outer join (select "cancelactivitiestable_1".productId as productId, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_1" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_1".productId = "newactivityinfotable_0".productId) where "newactivityinfotable_0".productId > 0 and "cancelactivitiestable_1".from_z <= \'2015-10-16\' and "cancelactivitiestable_1".thru_z > \'2015-10-16\') as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "name", "cancelactivitiestable_0".created_by as "classificationType" from ProductTable as "root" left outer join (select "cancelactivitiestable_1".productId as productId, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_1" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_1".productId = "newactivityinfotable_0".productId) where "newactivityinfotable_0".productId > 0 and "cancelactivitiestable_1".from_z <= DATE\'2015-10-16\' and "cancelactivitiestable_1".thru_z > DATE\'2015-10-16\') as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testIsolationOfMilestoningFiltersUsedOnIntermediateJoinInOR():Boolean[1] { let businessDate = %2015-10-16; let result = execute(|Product.all($businessDate)->filter(p| $p.cancelProductActivity.createdBy == 'David' || $p.newActivity.createdBy == 'Peter'), propagationMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "cancelactivitiestable_0".created_by as "cancelProductActivityCreatedBy", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join (select "cancelactivitiestable_0".productId as productId, "cancelactivitiestable_0".from_z as from_z, "cancelactivitiestable_0".thru_z as thru_z, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_0" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_0".productId = "newactivityinfotable_0".productId and "newactivityinfotable_0".from_z <= \'2015-10-16\' and "newactivityinfotable_0".thru_z > \'2015-10-16\')) as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId and "cancelactivitiestable_0".from_z <= \'2015-10-16\' and "cancelactivitiestable_0".thru_z > \'2015-10-16\') left outer join (select "cancelactivitiestable_2".productId as productId, "newactivityinfotable_1".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_2" inner join NewActivityInfoTable as "newactivityinfotable_1" on ("cancelactivitiestable_2".productId = "newactivityinfotable_1".productId) where "newactivityinfotable_1".productId > 0 and "cancelactivitiestable_2".from_z <= \'2015-10-16\' and "cancelactivitiestable_2".thru_z > \'2015-10-16\') as "cancelactivitiestable_1" on ("root".id = "cancelactivitiestable_1".productId) left outer join NewActivityInfoTable as "newactivityinfotable_2" on ("root".id = "newactivityinfotable_2".productId) where ("cancelactivitiestable_1".created_by = \'David\' or "newactivityinfotable_2".created_by = \'Peter\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "cancelactivitiestable_0".created_by as "cancelProductActivityCreatedBy", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join (select "cancelactivitiestable_0".productId as productId, "cancelactivitiestable_0".from_z as from_z, "cancelactivitiestable_0".thru_z as thru_z, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_0" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_0".productId = "newactivityinfotable_0".productId and "newactivityinfotable_0".from_z <= \'2015-10-16\' and "newactivityinfotable_0".thru_z > \'2015-10-16\')) as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId and "cancelactivitiestable_0".from_z <= \'2015-10-16\' and "cancelactivitiestable_0".thru_z > \'2015-10-16\') left outer join (select "cancelactivitiestable_2".productId as productId, "newactivityinfotable_1".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_2" inner join NewActivityInfoTable as "newactivityinfotable_1" on ("cancelactivitiestable_2".productId = "newactivityinfotable_1".productId) where "newactivityinfotable_1".productId > 0 and "cancelactivitiestable_2".from_z <= \'2015-10-16\' and "cancelactivitiestable_2".thru_z > \'2015-10-16\') as "cancelactivitiestable_1" on ("root".id = "cancelactivitiestable_1".productId) left outer join NewActivityInfoTable as "newactivityinfotable_2" on ("root".id = "newactivityinfotable_2".productId) where ("cancelactivitiestable_1".created_by = \'David\' or "newactivityinfotable_2".created_by = \'Peter\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "cancelactivitiestable_0".created_by as "cancelProductActivityCreatedBy", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join (select "cancelactivitiestable_0".productId as productId, "cancelactivitiestable_0".from_z as from_z, "cancelactivitiestable_0".thru_z as thru_z, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_0" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_0".productId = "newactivityinfotable_0".productId and "newactivityinfotable_0".from_z <= DATE\'2015-10-16\' and "newactivityinfotable_0".thru_z > DATE\'2015-10-16\')) as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId and "cancelactivitiestable_0".from_z <= DATE\'2015-10-16\' and "cancelactivitiestable_0".thru_z > DATE\'2015-10-16\') left outer join (select "cancelactivitiestable_2".productId as productId, "newactivityinfotable_1".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_2" inner join NewActivityInfoTable as "newactivityinfotable_1" on ("cancelactivitiestable_2".productId = "newactivityinfotable_1".productId) where "newactivityinfotable_1".productId > 0 and "cancelactivitiestable_2".from_z <= DATE\'2015-10-16\' and "cancelactivitiestable_2".thru_z > DATE\'2015-10-16\') as "cancelactivitiestable_1" on ("root".id = "cancelactivitiestable_1".productId) left outer join NewActivityInfoTable as "newactivityinfotable_2" on ("root".id = "newactivityinfotable_2".productId) where ("cancelactivitiestable_1".created_by = \'David\' or "newactivityinfotable_2".created_by = \'Peter\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningFiltersOnIntermediateInnerJoins():Boolean[1] @@ -145,7 +189,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['2,TDSNull', '3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "name", "cancelactivitiestable_0".created_by as "cancelProductActivityCreatedBy" from ProductTable as "root" left outer join (select "cancelactivitiestable_1".productId as productId, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_1" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_1".productId = "newactivityinfotable_0".productId) where "newactivityinfotable_0".from_z <= \'2015-10-16\' and "newactivityinfotable_0".thru_z > \'2015-10-16\' and "cancelactivitiestable_1".from_z <= \'2015-10-16\' and "cancelactivitiestable_1".thru_z > \'2015-10-16\') as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "name", "cancelactivitiestable_0".created_by as "cancelProductActivityCreatedBy" from ProductTable as "root" left outer join (select "cancelactivitiestable_1".productId as productId, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_1" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_1".productId = "newactivityinfotable_0".productId) where "newactivityinfotable_0".from_z <= \'2015-10-16\' and "newactivityinfotable_0".thru_z > \'2015-10-16\' and "cancelactivitiestable_1".from_z <= \'2015-10-16\' and "cancelactivitiestable_1".thru_z > \'2015-10-16\') as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "name", "cancelactivitiestable_0".created_by as "cancelProductActivityCreatedBy" from ProductTable as "root" left outer join (select "cancelactivitiestable_1".productId as productId, "newactivityinfotable_0".created_by as created_by from CancelActivitiesTable as "cancelactivitiestable_1" inner join NewActivityInfoTable as "newactivityinfotable_0" on ("cancelactivitiestable_1".productId = "newactivityinfotable_0".productId) where "newactivityinfotable_0".from_z <= DATE\'2015-10-16\' and "newactivityinfotable_0".thru_z > DATE\'2015-10-16\' and "cancelactivitiestable_1".from_z <= DATE\'2015-10-16\' and "cancelactivitiestable_1".thru_z > DATE\'2015-10-16\') as "cancelactivitiestable_0" on ("root".id = "cancelactivitiestable_0".productId) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextNotPropogatedThroughNonTemporalPropertiesFromAll():Boolean[1] @@ -156,13 +204,21 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['2,SYS1 description 1-v1', '2,SYS1 description 1-v2', '3,SYS1 description 1-v1', '3,SYS1 description 1-v2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextWithLatestDateNotPropogatedThroughNonTemporalPropertiesFromAll():Boolean[1] { let result = execute(|Product.all(%latest)->project([p|$p.id, p|$p.referenceSystem.systemDescriptionAllVersions.description],['name','sysDescription']), propagationMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName) where "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextNotPropogatedThroughNonTemporalPropertiesFromMilestonedQualifiedProperty():Boolean[1] @@ -173,7 +229,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['1,TDSNull', '2,SYS1 description 1-v1', '2,SYS1 description 1-v2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("producttable_0".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName)', $result); + assertEqualsH2Compatible( + 'select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("producttable_0".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName)', + 'select "root".id as "name", "systemdescriptiontable_0".description as "sysDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("producttable_0".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoneDatePropogationThruFilterIsIndenpendentOfDateManipulationWithinTheFilter():Boolean[1] @@ -181,7 +241,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let resultWithDatePropogated = execute(|Product.all(%2015-10-16)->filter(p|$p.classification(%2015-10-15).type=='STOCK')->project([p|$p.id, p|$p.classification.type],['id','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $resultWithDatePropogated.values->at(0); assertEquals(['2,STOCK'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL( 'select "root".id as "id", "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-15\' and "productclassificationtable_0".thru_z > \'2015-10-15\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $resultWithDatePropogated->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id", "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-15\' and "productclassificationtable_0".thru_z > \'2015-10-15\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "id", "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-15\' and "productclassificationtable_0".thru_z > DATE\'2015-10-15\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $resultWithDatePropogated->sqlRemoveFormatting() + ); let resultWithDateSpecified = execute(|Product.all(%2015-10-16)->filter(p|$p.classification(%2015-10-15).type=='STOCK')->project([p|$p.id, p|$p.classification(%2015-10-16).type],['id','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals($resultWithDatePropogated->sqlRemoveFormatting(),$resultWithDateSpecified->sqlRemoveFormatting()); } @@ -194,7 +258,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: assertEquals(1, $products->size()); assertEquals(['ProductName2'], $products->map(p|$p.name)); assertEquals([%2015-10-16], $products->map(p|$p.businessDate)); - assertSameSQL( 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoneDatePropogationFromTypeQueryThroughFilterToNoArgMilestonedQpInProject():Boolean[1] @@ -202,7 +270,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let result = execute(|Product.all(%2015-10-16)->filter(p|$p.classification.type=='STOCK')->project([p|$p.classification.type],['classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['STOCK'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL( 'select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoneDatePropogationFromTypeQueryDoesNotOverrideThatSpecifiedAsArgToMilestonedQpInFilter():Boolean[1] @@ -212,19 +284,31 @@ function <> meta::relational::tests::milestoning::contextpropagation: assertEquals(1, $products->size()); assertEquals(['ProductName2'], $products->map(p|$p.name)); assertEquals([%2015-10-16], $products->map(p|$p.businessDate)); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-17\' and "productclassificationtable_1".thru_z > \'2015-10-17\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= \'2015-10-16\' and "stockproducttable_0".thru_z > \'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-17\' and "productclassificationtable_1".thru_z > \'2015-10-17\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'2015-10-16\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".from_z <= DATE\'2015-10-16\' and "stockproducttable_0".thru_z > DATE\'2015-10-16\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-17\' and "productclassificationtable_1".thru_z > DATE\'2015-10-17\') where "productclassificationtable_1".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testLatestMilestoneDatePropogationFromTypeQueryDoesNotOverrideThatSpecifiedAsArgToMilestonedQpInFilter():Boolean[1] { let result = execute(|Product.all(%latest)->filter(p|$p.classification(%2015-10-17).type=='STOCK'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-17\' and "productclassificationtable_1".thru_z > \'2015-10-17\') where "productclassificationtable_1".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-17\' and "productclassificationtable_1".thru_z > \'2015-10-17\') where "productclassificationtable_1".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-17\' and "productclassificationtable_1".thru_z > DATE\'2015-10-17\') where "productclassificationtable_1".type = \'STOCK\' and "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testLatestMilestoneDateMappedTableDateDoesNotOverrideLatestDateFromChildPropertyInPropogation():Boolean[1] { let result = execute(|Product.all(%latest)->filter(p|$p.classification.type=='STOCK'), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".thru_z = \'9999-12-31 00:00:00.0000\') where "productclassificationtable_1".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".thru_z = \'9999-12-31 00:00:00.0000\') where "productclassificationtable_1".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", "productdescriptiontable_0".description as "stockProductName", "productclassificationtable_0".type as "classificationType", \'9999-12-31T00:00:00.0000+0000\' as "k_businessDate" from ProductTable as "root" left outer join StockProductTable as "stockproducttable_0" on ("root".id = "stockproducttable_0".id and "stockproducttable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') where "productclassificationtable_1".type = \'STOCK\' and "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoneDatePropogationFromTypeQueryDoesNotOverrideThatSpecifiedAsArgToMilestonedQpInProject():Boolean[1] @@ -232,7 +316,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let result = execute(|Product.all(%2015-10-16)->filter(p|$p.classification(%2017-10-16).type=='STOCK')->project([p|$p.classification(%2018-10-16).type],['classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['STOCK'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2017-10-16\' and "productclassificationtable_0".thru_z > \'2017-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2018-10-16\' and "productclassificationtable_1".thru_z > \'2018-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2017-10-16\' and "productclassificationtable_0".thru_z > \'2017-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2018-10-16\' and "productclassificationtable_1".thru_z > \'2018-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2017-10-16\' and "productclassificationtable_0".thru_z > DATE\'2017-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2018-10-16\' and "productclassificationtable_1".thru_z > DATE\'2018-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoneDatePropogationFromTypeQueryToProjectIsNotOverridenBySamePropertyUsedInFilterWithDifferentDateArguments():Boolean[1] @@ -240,7 +328,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let result = execute(|Product.all(%2015-10-16)->filter(p|$p.classification(%2017-10-16).type=='STOCK')->project([p|$p.classification.type],['classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['STOCK'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2017-10-16\' and "productclassificationtable_0".thru_z > \'2017-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2017-10-16\' and "productclassificationtable_0".thru_z > \'2017-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "productclassificationtable_1".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2017-10-16\' and "productclassificationtable_0".thru_z > DATE\'2017-10-16\') left outer join ProductClassificationTable as "productclassificationtable_1" on ("root".type = "productclassificationtable_1".type and "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoneDateNotPropogatedThroughNonMilestonedType():Boolean[1] @@ -248,7 +340,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let result = execute(|Product.all(%2015-10-16)->filter(p|$p.referenceSystem->toOne().systemDescription(%2014-10-17).description=='SYS1 description 1-v1')->project([p|$p.id],['id']), propagationMapping, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['2','3'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "id" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= \'2014-10-17\' and "systemdescriptiontable_0".thru_z > \'2014-10-17\') where "systemdescriptiontable_0".description = \'SYS1 description 1-v1\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".id as "id" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= \'2014-10-17\' and "systemdescriptiontable_0".thru_z > \'2014-10-17\') where "systemdescriptiontable_0".description = \'SYS1 description 1-v1\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "id" from ProductTable as "root" left outer join SystemTable as "systemtable_0" on ("root".referenceSystemName = "systemtable_0".name) left outer join SystemDescriptionTable as "systemdescriptiontable_0" on ("systemtable_0".name = "systemdescriptiontable_0".systemName and "systemdescriptiontable_0".from_z <= DATE\'2014-10-17\' and "systemdescriptiontable_0".thru_z > DATE\'2014-10-17\') where "systemdescriptiontable_0".description = \'SYS1 description 1-v1\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } //we don't support this yet in the Compiler @@ -328,7 +424,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $resultWithDatePropogated.values->at(0); assertEquals(['2,STOCK'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "id", "productclassificationtable_2".type as "classificationType" from ProductTable as "root" left outer join (select distinct "productclassificationtable_1".type from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-10-15\' and "productclassificationtable_1".thru_z > \'2015-10-15\' and "productclassificationtable_1".type = \'STOCK\') as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join ProductClassificationTable as "productclassificationtable_2" on ("root".type = "productclassificationtable_2".type and "productclassificationtable_2".from_z <= \'2015-10-16\' and "productclassificationtable_2".thru_z > \'2015-10-16\') where "productclassificationtable_0".type is not null and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $resultWithDatePropogated); + assertEqualsH2Compatible( + 'select "root".id as "id", "productclassificationtable_2".type as "classificationType" from ProductTable as "root" left outer join (select distinct "productclassificationtable_1".type from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-10-15\' and "productclassificationtable_1".thru_z > \'2015-10-15\' and "productclassificationtable_1".type = \'STOCK\') as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join ProductClassificationTable as "productclassificationtable_2" on ("root".type = "productclassificationtable_2".type and "productclassificationtable_2".from_z <= \'2015-10-16\' and "productclassificationtable_2".thru_z > \'2015-10-16\') where "productclassificationtable_0".type is not null and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".id as "id", "productclassificationtable_2".type as "classificationType" from ProductTable as "root" left outer join (select distinct "productclassificationtable_1".type from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= DATE\'2015-10-15\' and "productclassificationtable_1".thru_z > DATE\'2015-10-15\' and "productclassificationtable_1".type = \'STOCK\') as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) left outer join ProductClassificationTable as "productclassificationtable_2" on ("root".type = "productclassificationtable_2".type and "productclassificationtable_2".from_z <= DATE\'2015-10-16\' and "productclassificationtable_2".thru_z > DATE\'2015-10-16\') where "productclassificationtable_0".type is not null and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $resultWithDatePropogated->sqlRemoveFormatting() + ); let resultWithDateSpecified = execute(|Product.all(%2015-10-16)->filter(p|$p.classification(%2015-10-15)->exists(c|$c.type=='STOCK'))->project([p|$p.id, p|$p.classification(%2015-10-16).type],['id','classificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals($resultWithDatePropogated->sqlRemoveFormatting(),$resultWithDateSpecified->sqlRemoveFormatting()); } @@ -348,7 +448,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['1,STOCK DESC-V1', '2,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "productclassificationtable_0".type_description as "classificationDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-08-15\' and "productclassificationtable_1".thru_z > \'2015-08-15\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', $result); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "productclassificationtable_0".type_description as "classificationDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-08-15\' and "productclassificationtable_1".thru_z > \'2015-08-15\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', + 'select "root".id as "orderId", "productclassificationtable_0".type_description as "classificationDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-08-15\' and "producttable_0".thru_z > DATE\'2015-08-15\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= DATE\'2015-08-15\' and "productclassificationtable_1".thru_z > DATE\'2015-08-15\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextIsPropogatedThroughSubType():Boolean[1] @@ -359,7 +463,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['1,STOCK DESC-V1', '2,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".id as "orderId", "productclassificationtable_0".type_description as "classificationDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-08-15\' and "productclassificationtable_1".thru_z > \'2015-08-15\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', $result); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "productclassificationtable_0".type_description as "classificationDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-15\' and "producttable_0".thru_z > \'2015-08-15\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-08-15\' and "productclassificationtable_1".thru_z > \'2015-08-15\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', + 'select "root".id as "orderId", "productclassificationtable_0".type_description as "classificationDescription" from OrderTable as "root" left outer join ProductTable as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-08-15\' and "producttable_0".thru_z > DATE\'2015-08-15\') left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= DATE\'2015-08-15\' and "productclassificationtable_1".thru_z > DATE\'2015-08-15\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextPropagatedThroughFilterToNoArgMilestonedQualifiedPropertyInProjectPath():Boolean[1] @@ -370,7 +478,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK DESC-V3', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextPropagatedThroughToLeftSideOfQualifiedPropertyFilter():Boolean[1] @@ -378,11 +490,12 @@ function <> meta::relational::tests::milestoning::contextpropagation: let result = execute(|ProductClassification.all(%2015-10-16)->project([#/ProductClassification/product/stockProductName#]), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['ProductName2'],$tds.rows->map(r|$r.values->makeString(','))); - let expectedSQL = 'select "productdescriptiontable_0".description as "stockProductName" from ProductClassificationTable as "root" left outer join ProductTable as "producttable_0" on ("producttable_0".type = "root".type and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-10-16\' and "stockproducttable_1".thru_z > \'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\''; - assertSameSQL($expectedSQL , $result); + let expectedLegacyH2SQL = 'select "productdescriptiontable_0".description as "stockProductName" from ProductClassificationTable as "root" left outer join ProductTable as "producttable_0" on ("producttable_0".type = "root".type and "producttable_0".from_z <= \'2015-10-16\' and "producttable_0".thru_z > \'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= \'2015-10-16\' and "stockproducttable_1".thru_z > \'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\''; + let expectedNewH2SQL = 'select "productdescriptiontable_0".description as "stockProductName" from ProductClassificationTable as "root" left outer join ProductTable as "producttable_0" on ("producttable_0".type = "root".type and "producttable_0".from_z <= DATE\'2015-10-16\' and "producttable_0".thru_z > DATE\'2015-10-16\') left outer join (select "stockproducttable_1".id as id from StockProductTable as "stockproducttable_1" where "stockproducttable_1".from_z <= DATE\'2015-10-16\' and "stockproducttable_1".thru_z > DATE\'2015-10-16\') as "stockproducttable_0" on ("producttable_0".id = "stockproducttable_0".id) left outer join ProductDescriptionTable as "productdescriptiontable_0" on ("stockproducttable_0".id = "productdescriptiontable_0".id) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\''; + assertEqualsH2Compatible($expectedLegacyH2SQL, $expectedNewH2SQL, $result->sqlRemoveFormatting()); let businessDate = %2015-8-15; let resultWithVar = execute(|ProductClassification.all(%2015-10-16)->project([#/ProductClassification/product/stockProductName#]), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL($expectedSQL ,$resultWithVar); + assertEqualsH2Compatible($expectedLegacyH2SQL, $expectedNewH2SQL, $resultWithVar->sqlRemoveFormatting()); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextPropagatedFromMilestoningQualifiedPropertyWithArgToNoArgMilestonedQualifiedPropertyInProjectPath():Boolean[1] @@ -393,7 +506,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName2,LNSE', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2016-10-16\' and "productclassificationtable_0".thru_z > \'2016-10-16\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2016-10-16\' and "productexchangetable_1".thru_z > \'2016-10-16\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2016-10-16\' and "productclassificationtable_0".thru_z > \'2016-10-16\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2016-10-16\' and "productexchangetable_1".thru_z > \'2016-10-16\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "productName", "productexchangetable_0".name as "exchangeName" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2016-10-16\' and "productclassificationtable_0".thru_z > DATE\'2016-10-16\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= DATE\'2016-10-16\' and "productexchangetable_1".thru_z > DATE\'2016-10-16\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where ("root".name <> \'\' OR "root".name is null) and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextPropagatedUsingVariableInProjectPath():Boolean[1] @@ -404,7 +521,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK DESC-V3', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testCurrentMappingPropagationThroughMilestonedQualifiedPropertyWithEmbeddedLeftSideToSubsequentPropertyInProjectPath():Boolean[1] @@ -415,7 +536,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName2,SYS1', 'ProductName3,SYS1'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "productName", "systemtable_0".name as "classificationSystemName" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-16\' and "productclassificationsystemtable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "productName", "systemtable_0".name as "classificationSystemName" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= \'2015-10-16\' and "productclassificationsystemtable_0".thru_z > \'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "productName", "systemtable_0".name as "classificationSystemName" from ProductTable as "root" left outer join ProductClassificationSystemTable as "productclassificationsystemtable_0" on ("root".classificationSystemId = "productclassificationsystemtable_0".id and "productclassificationsystemtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationsystemtable_0".thru_z > DATE\'2015-10-16\') left outer join SystemTable as "systemtable_0" on ("productclassificationsystemtable_0".name = "systemtable_0".name) where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testMilestoningContextPropagatedUsingVariableInProject():Boolean[1] @@ -426,7 +551,11 @@ function <> meta::relational::tests::milestoning::contextpropagation: let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK DESC-V3', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> {meta::pure::executionPlan::profiles::serverVersion.start='V1_7_0'} meta::relational::tests::milestoning::contextpropagation::testMilestoningContextPropagatedUsingVariableInProjectMoveLetInBlock():Boolean[1] @@ -443,12 +572,20 @@ function <> meta::relational::tests::milestoning::contextpropagation: Product.all($businessDate)->project([p|$p.name, p|$p.classification.description],['name','description']);, milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['ProductName2,STOCK DESC-V3', 'ProductName3,TDSNull'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type_description as "description" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::contextpropagation::testDatePropagationWithInheritance():Boolean[1] { let businessDate = %2015-8-14; let result = execute(|OrderWithProductWithConstraints.all($businessDate)->project([o|$o.getClassificationDescription($businessDate)],['classificationDescription']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "ordertable_1".aggCol as "classificationDescription" from OrderTable as "root" left outer join (select "ordertable_2".id as id, group_concat("productclassificationtable_0".type_description ) as aggCol from OrderTable as "ordertable_2" left outer join ProductTable as "producttable_0" on ("ordertable_2".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-14\' and "producttable_0".thru_z > \'2015-08-14\') left outer join (select "productclassificationtable_0".type as type, "productclassificationtable_0".type_description as type_description from ProductClassificationTable as "productclassificationtable_0" where "productclassificationtable_0".from_z <= \'2015-08-14\' and "productclassificationtable_0".thru_z > \'2015-08-14\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id)',$result); + assertEqualsH2Compatible( + 'select "ordertable_1".aggCol as "classificationDescription" from OrderTable as "root" left outer join (select "ordertable_2".id as id, group_concat("productclassificationtable_0".type_description ) as aggCol from OrderTable as "ordertable_2" left outer join ProductTable as "producttable_0" on ("ordertable_2".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-08-14\' and "producttable_0".thru_z > \'2015-08-14\') left outer join (select "productclassificationtable_0".type as type, "productclassificationtable_0".type_description as type_description from ProductClassificationTable as "productclassificationtable_0" where "productclassificationtable_0".from_z <= \'2015-08-14\' and "productclassificationtable_0".thru_z > \'2015-08-14\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id)', + 'select "ordertable_1".aggCol as "classificationDescription" from OrderTable as "root" left outer join (select "ordertable_2".id as id, group_concat("productclassificationtable_0".type_description ) as aggCol from OrderTable as "ordertable_2" left outer join ProductTable as "producttable_0" on ("ordertable_2".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-08-14\' and "producttable_0".thru_z > DATE\'2015-08-14\') left outer join (select "productclassificationtable_0".type as type, "productclassificationtable_0".type_description as type_description from ProductClassificationTable as "productclassificationtable_0" where "productclassificationtable_0".from_z <= DATE\'2015-08-14\' and "productclassificationtable_0".thru_z > DATE\'2015-08-14\') as "productclassificationtable_0" on ("producttable_0".type = "productclassificationtable_0".type) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id)', + $result->sqlRemoveFormatting() + ); } \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithDistinct.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithDistinct.pure index b78b55dcbd3..e219dd61a47 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithDistinct.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithDistinct.pure @@ -13,6 +13,8 @@ // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::metamodel::execute::*; import meta::relational::functions::asserts::*; import meta::relational::runtime::*; @@ -38,7 +40,11 @@ function <> meta::relational::tests::milestoning::distinct::testDisti let result = execute(|Product.all(%2015-8-16)->project([p|$p.id, p|$p.name, p|$p.type],['id','name', 'type']), milestoningdistinctmapping, testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['1,ProductName,STOCK', '2,ProductName1,STOCK'], $tds.rows->map(r|$r.values->makeString(','))->sort()); - assertSameSQL('select "root".id as "id", "root".name as "name", "root".type as "type" from (select distinct "producttable_1".id as id, "producttable_1".name as name, "producttable_1".type as type, \'2015-08-16\' as "k_businessDate" from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-08-16\' and "producttable_1".thru_z > \'2015-08-16\') as "root"', $result); + assertEqualsH2Compatible( + 'select "root".id as "id", "root".name as "name", "root".type as "type" from (select distinct "producttable_1".id as id, "producttable_1".name as name, "producttable_1".type as type, \'2015-08-16\' as "k_businessDate" from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-08-16\' and "producttable_1".thru_z > \'2015-08-16\') as "root"', + 'select "root".id as "id", "root".name as "name", "root".type as "type" from (select distinct "producttable_1".id as id, "producttable_1".name as name, "producttable_1".type as type, \'2015-08-16\' as "k_businessDate" from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-08-16\' and "producttable_1".thru_z > DATE\'2015-08-16\') as "root"', + $result->sqlRemoveFormatting() + ); } ###Relational diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithInclusive.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithInclusive.pure index 3c906a6acec..7223f598d34 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithInclusive.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testMilestoningWithInclusive.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::runtime::*; import meta::relational::mapping::*; import meta::relational::tests::*; @@ -21,84 +22,96 @@ import meta::relational::tests::milestoning::inclusive::*; function <> meta::relational::tests::milestoning::inclusive::testInFromInclusive():Boolean[1] { let result1 = execute(|BiTemporalProduct.all(%2018-05-05, %2018-05-04)->filter(p | $p.id == 2), InFromInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_In_From_Inclusive as "root" where "root".id = 2 and "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\''; - assertEquals($expectedSQL1, $result1->sqlRemoveFormatting()); + let expectedLegacySQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_In_From_Inclusive as "root" where "root".id = 2 and "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\''; + let expectedNewSQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_In_From_Inclusive as "root" where "root".id = 2 and "root".in_z <= DATE\'2018-05-05\' and "root".out_z > DATE\'2018-05-05\' and "root".from_z <= DATE\'2018-05-04\' and "root".thru_z > DATE\'2018-05-04\''; + assertEqualsH2Compatible($expectedLegacySQL1, $expectedNewSQL1, $result1->sqlRemoveFormatting()); assertSameElements(['def2'], $result1.values.name); let result2 = execute(|Order.all()->filter(o | $o.biTemporalProduct(%2018-05-05, %2018-05-04).name == 'def2'), InFromInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_In_From_Inclusive as "bitemporalproducttable_in_from_inclusive_0" on ("root".prodFk = "bitemporalproducttable_in_from_inclusive_0".id and ("bitemporalproducttable_in_from_inclusive_0".in_z <= \'2018-05-05\' and "bitemporalproducttable_in_from_inclusive_0".out_z > \'2018-05-05\' and "bitemporalproducttable_in_from_inclusive_0".from_z <= \'2018-05-04\' and "bitemporalproducttable_in_from_inclusive_0".thru_z > \'2018-05-04\')) where "bitemporalproducttable_in_from_inclusive_0".name = \'def2\''; - assertEquals($expectedSQL2, $result2->sqlRemoveFormatting()); + let expectedLegacySQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_In_From_Inclusive as "bitemporalproducttable_in_from_inclusive_0" on ("root".prodFk = "bitemporalproducttable_in_from_inclusive_0".id and ("bitemporalproducttable_in_from_inclusive_0".in_z <= \'2018-05-05\' and "bitemporalproducttable_in_from_inclusive_0".out_z > \'2018-05-05\' and "bitemporalproducttable_in_from_inclusive_0".from_z <= \'2018-05-04\' and "bitemporalproducttable_in_from_inclusive_0".thru_z > \'2018-05-04\')) where "bitemporalproducttable_in_from_inclusive_0".name = \'def2\''; + let expectedNewSQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_In_From_Inclusive as "bitemporalproducttable_in_from_inclusive_0" on ("root".prodFk = "bitemporalproducttable_in_from_inclusive_0".id and ("bitemporalproducttable_in_from_inclusive_0".in_z <= DATE\'2018-05-05\' and "bitemporalproducttable_in_from_inclusive_0".out_z > DATE\'2018-05-05\' and "bitemporalproducttable_in_from_inclusive_0".from_z <= DATE\'2018-05-04\' and "bitemporalproducttable_in_from_inclusive_0".thru_z > DATE\'2018-05-04\')) where "bitemporalproducttable_in_from_inclusive_0".name = \'def2\''; + assertEqualsH2Compatible($expectedLegacySQL2, $expectedNewSQL2, $result2->sqlRemoveFormatting()); assertSameElements([2], $result2.values.id); } function <> meta::relational::tests::milestoning::inclusive::testInThruInclusive():Boolean[1] { let result1 = execute(|BiTemporalProduct.all(%2018-05-05, %2018-05-04)->filter(p | $p.id == 2), InThruInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".id = 2 and "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\''; - assertEquals($expectedSQL1, $result1->sqlRemoveFormatting()); + let expectedLegacySQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".id = 2 and "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\''; + let expectedNewSQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".id = 2 and "root".in_z <= DATE\'2018-05-05\' and "root".out_z > DATE\'2018-05-05\' and "root".from_z < DATE\'2018-05-04\' and "root".thru_z >= DATE\'2018-05-04\''; + assertEqualsH2Compatible($expectedLegacySQL1, $expectedNewSQL1, $result1->sqlRemoveFormatting()); assertSameElements(['def2'], $result1.values.name); let result2 = execute(|Order.all()->filter(o | $o.biTemporalProduct(%2018-05-05, %2018-05-04).name == 'def2'), InThruInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_In_Thru_Inclusive as "bitemporalproducttable_in_thru_inclusive_0" on ("root".prodFk = "bitemporalproducttable_in_thru_inclusive_0".id and ("bitemporalproducttable_in_thru_inclusive_0".in_z <= \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".out_z > \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".from_z < \'2018-05-04\' and "bitemporalproducttable_in_thru_inclusive_0".thru_z >= \'2018-05-04\')) where "bitemporalproducttable_in_thru_inclusive_0".name = \'def2\''; - assertEquals($expectedSQL2, $result2->sqlRemoveFormatting()); + let expectedLegacySQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_In_Thru_Inclusive as "bitemporalproducttable_in_thru_inclusive_0" on ("root".prodFk = "bitemporalproducttable_in_thru_inclusive_0".id and ("bitemporalproducttable_in_thru_inclusive_0".in_z <= \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".out_z > \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".from_z < \'2018-05-04\' and "bitemporalproducttable_in_thru_inclusive_0".thru_z >= \'2018-05-04\')) where "bitemporalproducttable_in_thru_inclusive_0".name = \'def2\''; + let expectedNewSQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_In_Thru_Inclusive as "bitemporalproducttable_in_thru_inclusive_0" on ("root".prodFk = "bitemporalproducttable_in_thru_inclusive_0".id and ("bitemporalproducttable_in_thru_inclusive_0".in_z <= DATE\'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".out_z > DATE\'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".from_z < DATE\'2018-05-04\' and "bitemporalproducttable_in_thru_inclusive_0".thru_z >= DATE\'2018-05-04\')) where "bitemporalproducttable_in_thru_inclusive_0".name = \'def2\''; + assertEqualsH2Compatible($expectedLegacySQL2, $expectedNewSQL2, $result2->sqlRemoveFormatting()); assertSameElements([2], $result2.values.id); } function <> meta::relational::tests::milestoning::inclusive::testOutFromInclusive():Boolean[1] { let result1 = execute(|BiTemporalProduct.all(%2018-05-05, %2018-05-04)->filter(p | $p.id == 2), OutFromInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".id = 2 and "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\''; - assertEquals($expectedSQL1, $result1->sqlRemoveFormatting()); + let expectedLegacyH2SQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".id = 2 and "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\''; + let expectedNewH2SQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".id = 2 and "root".in_z < DATE\'2018-05-05\' and "root".out_z >= DATE\'2018-05-05\' and "root".from_z <= DATE\'2018-05-04\' and "root".thru_z > DATE\'2018-05-04\''; + assertEqualsH2Compatible($expectedLegacyH2SQL1, $expectedNewH2SQL1, $result1->sqlRemoveFormatting()); assertSameElements(['def2'], $result1.values.name); let result2 = execute(|Order.all()->filter(o | $o.biTemporalProduct(%2018-05-05, %2018-05-04).name == 'def2'), OutFromInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_Out_From_Inclusive as "bitemporalproducttable_out_from_inclusive_0" on ("root".prodFk = "bitemporalproducttable_out_from_inclusive_0".id and ("bitemporalproducttable_out_from_inclusive_0".in_z < \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".out_z >= \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".from_z <= \'2018-05-04\' and "bitemporalproducttable_out_from_inclusive_0".thru_z > \'2018-05-04\')) where "bitemporalproducttable_out_from_inclusive_0".name = \'def2\''; - assertEquals($expectedSQL2, $result2->sqlRemoveFormatting()); + let expectedLegacyH2SQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_Out_From_Inclusive as "bitemporalproducttable_out_from_inclusive_0" on ("root".prodFk = "bitemporalproducttable_out_from_inclusive_0".id and ("bitemporalproducttable_out_from_inclusive_0".in_z < \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".out_z >= \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".from_z <= \'2018-05-04\' and "bitemporalproducttable_out_from_inclusive_0".thru_z > \'2018-05-04\')) where "bitemporalproducttable_out_from_inclusive_0".name = \'def2\''; + let expectedNewH2SQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_Out_From_Inclusive as "bitemporalproducttable_out_from_inclusive_0" on ("root".prodFk = "bitemporalproducttable_out_from_inclusive_0".id and ("bitemporalproducttable_out_from_inclusive_0".in_z < DATE\'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".out_z >= DATE\'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".from_z <= DATE\'2018-05-04\' and "bitemporalproducttable_out_from_inclusive_0".thru_z > DATE\'2018-05-04\')) where "bitemporalproducttable_out_from_inclusive_0".name = \'def2\''; + assertEqualsH2Compatible($expectedLegacyH2SQL2, $expectedNewH2SQL2, $result2->sqlRemoveFormatting()); assertSameElements([2], $result2.values.id); } function <> meta::relational::tests::milestoning::inclusive::testOutThruInclusive():Boolean[1] { let result1 = execute(|BiTemporalProduct.all(%2018-05-05, %2018-05-04)->filter(p | $p.id == 2), OutThruInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".id = 2 and "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\''; - assertEquals($expectedSQL1, $result1->sqlRemoveFormatting()); + let expectedLegacyH2SQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".id = 2 and "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\''; + let expectedNewH2SQL1 = 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate" from BiTemporalProductTable_Out_Thru_Inclusive as "root" where "root".id = 2 and "root".in_z < DATE\'2018-05-05\' and "root".out_z >= DATE\'2018-05-05\' and "root".from_z < DATE\'2018-05-04\' and "root".thru_z >= DATE\'2018-05-04\''; + assertEqualsH2Compatible($expectedLegacyH2SQL1, $expectedNewH2SQL1, $result1->sqlRemoveFormatting()); assertSameElements(['def2'], $result1.values.name); let result2 = execute(|Order.all()->filter(o | $o.biTemporalProduct(%2018-05-05, %2018-05-04).name == 'def2'), OutThruInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_Out_Thru_Inclusive as "bitemporalproducttable_out_thru_inclusive_0" on ("root".prodFk = "bitemporalproducttable_out_thru_inclusive_0".id and ("bitemporalproducttable_out_thru_inclusive_0".in_z < \'2018-05-05\' and "bitemporalproducttable_out_thru_inclusive_0".out_z >= \'2018-05-05\' and "bitemporalproducttable_out_thru_inclusive_0".from_z < \'2018-05-04\' and "bitemporalproducttable_out_thru_inclusive_0".thru_z >= \'2018-05-04\')) where "bitemporalproducttable_out_thru_inclusive_0".name = \'def2\''; - assertEquals($expectedSQL2, $result2->sqlRemoveFormatting()); + let expectedLegacyH2SQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_Out_Thru_Inclusive as "bitemporalproducttable_out_thru_inclusive_0" on ("root".prodFk = "bitemporalproducttable_out_thru_inclusive_0".id and ("bitemporalproducttable_out_thru_inclusive_0".in_z < \'2018-05-05\' and "bitemporalproducttable_out_thru_inclusive_0".out_z >= \'2018-05-05\' and "bitemporalproducttable_out_thru_inclusive_0".from_z < \'2018-05-04\' and "bitemporalproducttable_out_thru_inclusive_0".thru_z >= \'2018-05-04\')) where "bitemporalproducttable_out_thru_inclusive_0".name = \'def2\''; + let expectedNewH2SQL2 = 'select "root".id as "pk_0", "root".id as "id" from MyOrderTable as "root" left outer join BiTemporalProductTable_Out_Thru_Inclusive as "bitemporalproducttable_out_thru_inclusive_0" on ("root".prodFk = "bitemporalproducttable_out_thru_inclusive_0".id and ("bitemporalproducttable_out_thru_inclusive_0".in_z < DATE\'2018-05-05\' and "bitemporalproducttable_out_thru_inclusive_0".out_z >= DATE\'2018-05-05\' and "bitemporalproducttable_out_thru_inclusive_0".from_z < DATE\'2018-05-04\' and "bitemporalproducttable_out_thru_inclusive_0".thru_z >= DATE\'2018-05-04\')) where "bitemporalproducttable_out_thru_inclusive_0".name = \'def2\''; + assertEqualsH2Compatible($expectedLegacyH2SQL2, $expectedNewH2SQL2, $result2->sqlRemoveFormatting()); assertSameElements([2], $result2.values.id); } function <> meta::relational::tests::milestoning::inclusive::testInThruInclusiveUnionOutFromInclusive():Boolean[1] { let result = execute(|BiTemporalProduct.all(%2018-05-05, %2018-05-04)->filter(p | $p.id == 2), InThruInclusiveUnionOutFromInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."in_z_0" as "in_z_0", "unionBase"."out_z_0" as "out_z_0", "unionBase"."from_z_1" as "from_z_1", "unionBase"."thru_z_1" as "thru_z_1", "unionBase"."in_z_1" as "in_z_1", "unionBase"."out_z_1" as "out_z_1" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", "root".id as "BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\') as "unionBase" where "unionBase"."BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" = 2'; - assertEquals($expectedSQL, $result->sqlRemoveFormatting()); + let expectedLegacyH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."in_z_0" as "in_z_0", "unionBase"."out_z_0" as "out_z_0", "unionBase"."from_z_1" as "from_z_1", "unionBase"."thru_z_1" as "thru_z_1", "unionBase"."in_z_1" as "in_z_1", "unionBase"."out_z_1" as "out_z_1" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", "root".id as "BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\') as "unionBase" where "unionBase"."BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" = 2'; + let expectedNewH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."in_z_0" as "in_z_0", "unionBase"."out_z_0" as "out_z_0", "unionBase"."from_z_1" as "from_z_1", "unionBase"."thru_z_1" as "thru_z_1", "unionBase"."in_z_1" as "in_z_1", "unionBase"."out_z_1" as "out_z_1" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".in_z <= DATE\'2018-05-05\' and "root".out_z > DATE\'2018-05-05\' and "root".from_z < DATE\'2018-05-04\' and "root".thru_z >= DATE\'2018-05-04\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", "root".id as "BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < DATE\'2018-05-05\' and "root".out_z >= DATE\'2018-05-05\' and "root".from_z <= DATE\'2018-05-04\' and "root".thru_z > DATE\'2018-05-04\') as "unionBase" where "unionBase"."BiTemporalProductTable_In_Thru_Inclusiveid_BiTemporalProductTable_Out_From_Inclusiveid" = 2'; + assertEqualsH2Compatible($expectedLegacyH2SQL, $expectedNewH2SQL, $result->sqlRemoveFormatting()); assertSameElements(['def2', 'def2'], $result.values.name); } function <> meta::relational::tests::milestoning::inclusive::testOutFromInclusiveUnionInThruInclusive():Boolean[1] { let result = execute(|BiTemporalProduct.all(%2018-05-05, %2018-05-04)->filter(p | $p.id == 2), OutFromInclusiveUnionInThruInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."in_z_0" as "in_z_0", "unionBase"."out_z_0" as "out_z_0", "unionBase"."from_z_1" as "from_z_1", "unionBase"."thru_z_1" as "thru_z_1", "unionBase"."in_z_1" as "in_z_1", "unionBase"."out_z_1" as "out_z_1" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", "root".id as "BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\') as "unionBase" where "unionBase"."BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" = 2'; - assertEquals($expectedSQL, $result->sqlRemoveFormatting()); + let expectedLegacyH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."in_z_0" as "in_z_0", "unionBase"."out_z_0" as "out_z_0", "unionBase"."from_z_1" as "from_z_1", "unionBase"."thru_z_1" as "thru_z_1", "unionBase"."in_z_1" as "in_z_1", "unionBase"."out_z_1" as "out_z_1" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < \'2018-05-05\' and "root".out_z >= \'2018-05-05\' and "root".from_z <= \'2018-05-04\' and "root".thru_z > \'2018-05-04\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", "root".id as "BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".in_z <= \'2018-05-05\' and "root".out_z > \'2018-05-05\' and "root".from_z < \'2018-05-04\' and "root".thru_z >= \'2018-05-04\') as "unionBase" where "unionBase"."BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" = 2'; + let expectedNewH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_1_0" as "pk_1_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_1_1" as "pk_1_1", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."in_z_0" as "in_z_0", "unionBase"."out_z_0" as "out_z_0", "unionBase"."from_z_1" as "from_z_1", "unionBase"."thru_z_1" as "thru_z_1", "unionBase"."in_z_1" as "in_z_1", "unionBase"."out_z_1" as "out_z_1" from (select \'0\' as u_type, "root".id as "pk_0_0", "root".name as "pk_1_0", null as "pk_0_1", null as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", "root".in_z as "in_z_0", "root".out_z as "out_z_0", null as "from_z_1", null as "thru_z_1", null as "in_z_1", null as "out_z_1", "root".id as "BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" from BiTemporalProductTable_Out_From_Inclusive as "root" where "root".in_z < DATE\'2018-05-05\' and "root".out_z >= DATE\'2018-05-05\' and "root".from_z <= DATE\'2018-05-04\' and "root".thru_z > DATE\'2018-05-04\' UNION ALL select \'1\' as u_type, null as "pk_0_0", null as "pk_1_0", "root".id as "pk_0_1", "root".name as "pk_1_1", "root".id as "id", "root".name as "name", \'2018-05-05\' as "k_processingDate", \'2018-05-04\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "in_z_0", null as "out_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".in_z as "in_z_1", "root".out_z as "out_z_1", "root".id as "BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" from BiTemporalProductTable_In_Thru_Inclusive as "root" where "root".in_z <= DATE\'2018-05-05\' and "root".out_z > DATE\'2018-05-05\' and "root".from_z < DATE\'2018-05-04\' and "root".thru_z >= DATE\'2018-05-04\') as "unionBase" where "unionBase"."BiTemporalProductTable_Out_From_Inclusiveid_BiTemporalProductTable_In_Thru_Inclusiveid" = 2'; + assertEqualsH2Compatible($expectedLegacyH2SQL, $expectedNewH2SQL, $result->sqlRemoveFormatting()); assertSameElements(['def2', 'def2'], $result.values.name); } function <> meta::relational::tests::milestoning::inclusive::testInThruInclusiveUnionInThruInclusive():Boolean[1] { let result = execute(|Order.all()->filter(o | $o.biTemporalProduct(%2018-05-05, %2018-05-04).name == 'def2'), InThruInclusiveUnionInThruInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", null as prodFk_1 from MyOrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_1 from MyOrderTable as "root") as "unionBase" left outer join BiTemporalProductTable_In_Thru_Inclusive as "bitemporalproducttable_in_thru_inclusive_0" on ("unionBase".prodFk_1 = "bitemporalproducttable_in_thru_inclusive_0".id and ("bitemporalproducttable_in_thru_inclusive_0".in_z <= \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".out_z > \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".from_z < \'2018-05-04\' and "bitemporalproducttable_in_thru_inclusive_0".thru_z >= \'2018-05-04\')) where "bitemporalproducttable_in_thru_inclusive_0".name = \'def2\''; - assertEquals($expectedSQL, $result->sqlRemoveFormatting()); + let expectedLegacyH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", null as prodFk_1 from MyOrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_1 from MyOrderTable as "root") as "unionBase" left outer join BiTemporalProductTable_In_Thru_Inclusive as "bitemporalproducttable_in_thru_inclusive_0" on ("unionBase".prodFk_1 = "bitemporalproducttable_in_thru_inclusive_0".id and ("bitemporalproducttable_in_thru_inclusive_0".in_z <= \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".out_z > \'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".from_z < \'2018-05-04\' and "bitemporalproducttable_in_thru_inclusive_0".thru_z >= \'2018-05-04\')) where "bitemporalproducttable_in_thru_inclusive_0".name = \'def2\''; + let expectedNewH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", null as prodFk_1 from MyOrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_1 from MyOrderTable as "root") as "unionBase" left outer join BiTemporalProductTable_In_Thru_Inclusive as "bitemporalproducttable_in_thru_inclusive_0" on ("unionBase".prodFk_1 = "bitemporalproducttable_in_thru_inclusive_0".id and ("bitemporalproducttable_in_thru_inclusive_0".in_z <= DATE\'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".out_z > DATE\'2018-05-05\' and "bitemporalproducttable_in_thru_inclusive_0".from_z < DATE\'2018-05-04\' and "bitemporalproducttable_in_thru_inclusive_0".thru_z >= DATE\'2018-05-04\')) where "bitemporalproducttable_in_thru_inclusive_0".name = \'def2\''; + assertEqualsH2Compatible($expectedLegacyH2SQL, $expectedNewH2SQL, $result->sqlRemoveFormatting()); assertSameElements([2], $result.values.id); } function <> meta::relational::tests::milestoning::inclusive::testOutFromInclusiveUnionOutFromInclusive():Boolean[1] { let result = execute(|Order.all()->filter(o | $o.biTemporalProduct(%2018-05-05, %2018-05-04).name == 'def2'), OutFromInclusiveUnionOutFromInclusiveMapping, testRuntime(), meta::relational::extension::relationalExtensions()); - let expectedSQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", null as prodFk_1 from MyOrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_1 from MyOrderTable as "root") as "unionBase" left outer join BiTemporalProductTable_Out_From_Inclusive as "bitemporalproducttable_out_from_inclusive_0" on ("unionBase".prodFk_1 = "bitemporalproducttable_out_from_inclusive_0".id and ("bitemporalproducttable_out_from_inclusive_0".in_z < \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".out_z >= \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".from_z <= \'2018-05-04\' and "bitemporalproducttable_out_from_inclusive_0".thru_z > \'2018-05-04\')) where "bitemporalproducttable_out_from_inclusive_0".name = \'def2\''; - assertEquals($expectedSQL, $result->sqlRemoveFormatting()); + let expectedLegacyH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", null as prodFk_1 from MyOrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_1 from MyOrderTable as "root") as "unionBase" left outer join BiTemporalProductTable_Out_From_Inclusive as "bitemporalproducttable_out_from_inclusive_0" on ("unionBase".prodFk_1 = "bitemporalproducttable_out_from_inclusive_0".id and ("bitemporalproducttable_out_from_inclusive_0".in_z < \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".out_z >= \'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".from_z <= \'2018-05-04\' and "bitemporalproducttable_out_from_inclusive_0".thru_z > \'2018-05-04\')) where "bitemporalproducttable_out_from_inclusive_0".name = \'def2\''; + let expectedNewH2SQL = 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", "root".id as "id", null as prodFk_1 from MyOrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", "root".id as "id", "root".prodFk as prodFk_1 from MyOrderTable as "root") as "unionBase" left outer join BiTemporalProductTable_Out_From_Inclusive as "bitemporalproducttable_out_from_inclusive_0" on ("unionBase".prodFk_1 = "bitemporalproducttable_out_from_inclusive_0".id and ("bitemporalproducttable_out_from_inclusive_0".in_z < DATE\'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".out_z >= DATE\'2018-05-05\' and "bitemporalproducttable_out_from_inclusive_0".from_z <= DATE\'2018-05-04\' and "bitemporalproducttable_out_from_inclusive_0".thru_z > DATE\'2018-05-04\')) where "bitemporalproducttable_out_from_inclusive_0".name = \'def2\''; + assertEqualsH2Compatible($expectedLegacyH2SQL, $expectedNewH2SQL, $result->sqlRemoveFormatting()); assertSameElements([2], $result.values.id); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testOtherwise.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testOtherwise.pure index 36f09646a3c..6afa11e0a3b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testOtherwise.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testOtherwise.pure @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; function <> meta::relational::tests::milestoning::otherwise::setUp():Any[0..1] { @@ -24,7 +26,11 @@ function <> meta::relational::tests::milestoning::otherwise::testAsso let result = execute(|meta::relational::tests::milestoning::StockProduct.all(%latest)->project(p|$p.classification(%latest).description, 'ok'), meta::relational::tests::milestoning::otherwiseMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions(), noDebug()); - assertSameSQL('select "productclassificationtable_0".type_description as "ok" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".type = \'STOCK\' and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') where "root".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result); + assertEqualsH2Compatible( + 'select "productclassificationtable_0".type_description as "ok" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".type = \'STOCK\' and "productclassificationtable_0".thru_z = \'9999-12-31 00:00:00.0000\') where "root".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "productclassificationtable_0".type_description as "ok" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".type = \'STOCK\' and "productclassificationtable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\') where "root".type = \'STOCK\' and "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::otherwise::testAssoWithOtherwiseDeep():Boolean[1] @@ -32,5 +38,9 @@ function <> meta::relational::tests::milestoning::otherwise::testAsso let result = execute(|meta::relational::tests::milestoning::StockProduct.all(%latest)->project(p|$p.classification(%2008-10-10).exchange(%2009-12-10).name, 'ok'), meta::relational::tests::milestoning::otherwiseMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions(), noDebug()); - assertSameSQL('select "productexchangetable_0".name as "ok" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".type = \'STOCK\' and "productclassificationtable_0".from_z <= \'2008-10-10\' and "productclassificationtable_0".thru_z > \'2008-10-10\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2009-12-10\' and "productexchangetable_1".thru_z > \'2009-12-10\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', $result); + assertEqualsH2Compatible( + 'select "productexchangetable_0".name as "ok" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".type = \'STOCK\' and "productclassificationtable_0".from_z <= \'2008-10-10\' and "productclassificationtable_0".thru_z > \'2008-10-10\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2009-12-10\' and "productexchangetable_1".thru_z > \'2009-12-10\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".type = \'STOCK\' and "root".thru_z = \'9999-12-31 00:00:00.0000\'', + 'select "productexchangetable_0".name as "ok" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".type = \'STOCK\' and "productclassificationtable_0".from_z <= DATE\'2008-10-10\' and "productclassificationtable_0".thru_z > DATE\'2008-10-10\') left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= DATE\'2009-12-10\' and "productexchangetable_1".thru_z > DATE\'2009-12-10\') as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name) where "root".type = \'STOCK\' and "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.0000\'', + $result->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testProcessingDateMilestoning.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testProcessingDateMilestoning.pure index c901592dd6f..9d102591ed1 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testProcessingDateMilestoning.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testProcessingDateMilestoning.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; import meta::relational::tests::milestoning::*; @@ -26,7 +27,11 @@ function <> meta::relational::tests::milestoning::processingDate::tes { let processingDate = %2015-10-16; let result = execute(|Trader.all($processingDate), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'',$result); + assertEqualsH2Compatible( + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'', + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where "root".in_z <= DATE\'2015-10-16\' and "root".out_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); let traders = $result.values; assertEquals(2, $traders->size()); assertEquals([$processingDate,$processingDate], $traders->map(p|$p.processingDate)); @@ -36,12 +41,20 @@ function <> meta::relational::tests::milestoning::processingDate::tes { let processingDate = %2015-10-16; let result = execute(|Trader.all($processingDate)->filter(t|$t.certifications($processingDate).name->contains(['SRCE'])), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where exists(select 1 from CertificationTable as "certificationtable_0" where "certificationtable_0".name = \'SRCE\' and "root".kerberos = "certificationtable_0".kerberos and "certificationtable_0".in_z <= \'2015-10-16\' and "certificationtable_0".out_z > \'2015-10-16\') and "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where exists(select 1 from CertificationTable as "certificationtable_0" where "certificationtable_0".name = \'SRCE\' and "root".kerberos = "certificationtable_0".kerberos and "certificationtable_0".in_z <= \'2015-10-16\' and "certificationtable_0".out_z > \'2015-10-16\') and "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'', + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where exists(select 1 from CertificationTable as "certificationtable_0" where "certificationtable_0".name = \'SRCE\' and "root".kerberos = "certificationtable_0".kerberos and "certificationtable_0".in_z <= DATE\'2015-10-16\' and "certificationtable_0".out_z > DATE\'2015-10-16\') and "root".in_z <= DATE\'2015-10-16\' and "root".out_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::processingDate::testProcessingTemporalPropertyPropagationInQuery():Boolean[1] { let processingDate = %2015-10-16; let result = execute(|Trader.all($processingDate)->filter(t|$t.certifications.name->contains(['SRCE'])), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where exists(select 1 from CertificationTable as "certificationtable_0" where "certificationtable_0".name = \'SRCE\' and "root".kerberos = "certificationtable_0".kerberos and "certificationtable_0".in_z <= \'2015-10-16\' and "certificationtable_0".out_z > \'2015-10-16\') and "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where exists(select 1 from CertificationTable as "certificationtable_0" where "certificationtable_0".name = \'SRCE\' and "root".kerberos = "certificationtable_0".kerberos and "certificationtable_0".in_z <= \'2015-10-16\' and "certificationtable_0".out_z > \'2015-10-16\') and "root".in_z <= \'2015-10-16\' and "root".out_z > \'2015-10-16\'', + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", \'2015-10-16\' as "k_processingDate" from TraderTable as "root" where exists(select 1 from CertificationTable as "certificationtable_0" where "certificationtable_0".name = \'SRCE\' and "root".kerberos = "certificationtable_0".kerberos and "certificationtable_0".in_z <= DATE\'2015-10-16\' and "certificationtable_0".out_z > DATE\'2015-10-16\') and "root".in_z <= DATE\'2015-10-16\' and "root".out_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalDate.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalDate.pure index fc10a0b942d..d5c1b35c928 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalDate.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalDate.pure @@ -13,6 +13,8 @@ // limitations under the License. ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::relational::tests::milestoning::*; import meta::relational::tests::*; @@ -80,7 +82,11 @@ function <> meta::relational::tests::milestoning::temporalDate::testT function <> meta::relational::tests::milestoning::temporalDate::testBusinessDateForAllVersionsInRange():Boolean[1] { let result = execute(|ProductSynonym.allVersionsInRange(%2012-1-1, %2016-1-1), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".name as "pk_0", "root".synonym as "pk_1", "root".type as "pk_2", "root".synonym as "synonym", "root".type as "type", "root".from_z as "k_businessDate" from ProductSynonymTable as "root" where "root".from_z <= \'2016-01-01\' and "root".thru_z > \'2012-01-01\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "pk_0", "root".synonym as "pk_1", "root".type as "pk_2", "root".synonym as "synonym", "root".type as "type", "root".from_z as "k_businessDate" from ProductSynonymTable as "root" where "root".from_z <= \'2016-01-01\' and "root".thru_z > \'2012-01-01\'', + 'select "root".name as "pk_0", "root".synonym as "pk_1", "root".type as "pk_2", "root".synonym as "synonym", "root".type as "type", "root".from_z as "k_businessDate" from ProductSynonymTable as "root" where "root".from_z <= DATE\'2016-01-01\' and "root".thru_z > DATE\'2012-01-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['CUSIP', 'CUSIP', 'CUSIP', 'CUSIP', 'STOCK', 'STOCK'], $result.values.type); assertSameElements([%2015-01-01T00:00:00.000000000+0000, %2015-08-15T00:00:00.000000000+0000, %2015-08-15T00:00:00.000000000+0000, %2015-08-26T00:00:00.000000000+0000, %2015-09-26T00:00:00.000000000+0000, %2015-10-17T00:00:00.000000000+0000], $result.values.businessDate); } @@ -88,7 +94,11 @@ function <> meta::relational::tests::milestoning::temporalDate::testB function <> meta::relational::tests::milestoning::temporalDate::testProcessingDateForAllVersionsInRange():Boolean[1] { let result = execute(|Trader.allVersionsInRange(%2012-1-1, %2016-1-1), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "root".kerberos as "pk_0", "root".kerberos as "kerberos", "root".in_z as "k_processingDate" from TraderTable as "root" where "root".in_z <= \'2016-01-01\' and "root".out_z > \'2012-01-01\'', $result); + assertEqualsH2Compatible( + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", "root".in_z as "k_processingDate" from TraderTable as "root" where "root".in_z <= \'2016-01-01\' and "root".out_z > \'2012-01-01\'', + 'select "root".kerberos as "pk_0", "root".kerberos as "kerberos", "root".in_z as "k_processingDate" from TraderTable as "root" where "root".in_z <= DATE\'2016-01-01\' and "root".out_z > DATE\'2012-01-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['bfox', 'ggekko'], $result.values.kerberos); assertSameElements([%2013-01-01T00:00:00.000000000+0000, %2015-01-01T00:00:00.000000000+0000], $result.values.processingDate); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalMilestoningPostProcessor.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalMilestoningPostProcessor.pure index e29b3c7a143..a0a8b616db3 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalMilestoningPostProcessor.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalMilestoningPostProcessor.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::mapping::*; import meta::pure::extension::*; import meta::relational::extension::*; @@ -51,5 +52,9 @@ function <> meta::relational::tests::milestoning:: let result = execute(|Product.all()->project([p|$p.name, p|$p.synonyms.name],['name','synonym']), simpleRelationalMapping, $updatedRuntime, meta::relational::extension::relationalExtensions()); let tds = $result.values->at(0); assertEquals(['Firm A,ISIN1', 'Firm D,ISIN2'],$tds.rows->map(r|$r.values->makeString(','))); - assertSameSQL('select "root".NAME as "name", "synonymtable_0".NAME as "synonym" from productSchema.productTable as "root" left outer join productSchema.synonymTable as "synonymtable_0" on ("synonymtable_0".PRODID = "root".ID and "synonymtable_0".thru_z = \'9999-12-31 00:00:00.000\') where "root".thru_z = \'9999-12-31 00:00:00.000\'', $result); + assertEqualsH2Compatible( + 'select "root".NAME as "name", "synonymtable_0".NAME as "synonym" from productSchema.productTable as "root" left outer join productSchema.synonymTable as "synonymtable_0" on ("synonymtable_0".PRODID = "root".ID and "synonymtable_0".thru_z = \'9999-12-31 00:00:00.000\') where "root".thru_z = \'9999-12-31 00:00:00.000\'', + 'select "root".NAME as "name", "synonymtable_0".NAME as "synonym" from productSchema.productTable as "root" left outer join productSchema.synonymTable as "synonymtable_0" on ("synonymtable_0".PRODID = "root".ID and "synonymtable_0".thru_z = TIMESTAMP\'9999-12-31 00:00:00.000\') where "root".thru_z = TIMESTAMP\'9999-12-31 00:00:00.000\'', + $result->sqlRemoveFormatting() + ); } \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalRangeQuery.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalRangeQuery.pure index f1ac28ac49c..a9b10f01c95 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalRangeQuery.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testTemporalRangeQuery.pure @@ -13,6 +13,8 @@ // limitations under the License. ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::relational::tests::milestoning::businessdate::*; import meta::relational::tests::milestoning::*; @@ -21,7 +23,11 @@ import meta::relational::tests::*; function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnRoot():Boolean[1] { let result = execute(|Product.allVersionsInRange(%2015-1-1, %2015-9-1)->filter(x|$x.type == 'STOCK')->project([x|$x.type, x|$x.milestoning.from, x|$x.milestoning.thru], ['type', 'from', 'thru'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "root".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" where "root".type = \'STOCK\' and "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-01-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "root".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" where "root".type = \'STOCK\' and "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-01-01\'', + 'select distinct "root".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" where "root".type = \'STOCK\' and "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-01-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['STOCK', 'STOCK'], $result.values.rows.getString('type')); assertSameElements([%2015-8-15T00:00:00.000000000+0000, %2015-8-26T00:00:00.000000000+0000], $result.values.rows.getDate('from')); assertSameElements([%2015-8-26T00:00:00.000000000+0000, %2015-10-16T00:00:00.000000000+0000], $result.values.rows.getDate('thru')); @@ -30,7 +36,11 @@ function <> meta::relational::tests::milestoning::rangeQuery::testBus function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnRootAndProperty():Boolean[1] { let result = execute(|Product.allVersionsInRange(%2015-1-1, %2015-9-1)->filter(x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type == 'STOCK')->project([x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type, x|$x.milestoning.from, x|$x.milestoning.thru], ['type', 'from', 'thru'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "productclassificationtable_0".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-01-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "productclassificationtable_0".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-01-01\'', + 'select distinct "productclassificationtable_0".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-09-01\' and "productclassificationtable_0".thru_z > DATE\'2015-01-01\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-01-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['STOCK', 'STOCK'], $result.values.rows.getString('type')); assertSameElements([%2015-8-15T00:00:00.000000000+0000, %2015-8-26T00:00:00.000000000+0000], $result.values.rows.getDate('from')); assertSameElements([%2015-8-26T00:00:00.000000000+0000, %2015-10-16T00:00:00.000000000+0000], $result.values.rows.getDate('thru')); @@ -39,7 +49,11 @@ function <> meta::relational::tests::milestoning::rangeQuery::testBus function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnRootAndPropertyDeep():Boolean[1] { let result = execute(|Product.allVersionsInRange(%2015-1-1, %2015-9-1)->filter(x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).exchangeAllVersionsInRange(%2015-1-1, %2015-9-1).name == 'LNSE')->project([x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).exchangeAllVersionsInRange(%2015-1-1, %2015-9-1).name, x|$x.milestoning.from, x|$x.milestoning.thru], ['name', 'from', 'thru'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "productexchangetable_1".name as "name", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-09-01\' and "productexchangetable_0".thru_z > \'2015-01-01\') left outer join (select "productexchangetable_2".name as name from ProductExchangeTable as "productexchangetable_2" where "productexchangetable_2".from_z <= \'2015-09-01\' and "productexchangetable_2".thru_z > \'2015-01-01\') as "productexchangetable_1" on ("productclassificationtable_0".exchange = "productexchangetable_1".name) where "productexchangetable_0".name = \'LNSE\' and "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-01-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "productexchangetable_1".name as "name", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-09-01\' and "productexchangetable_0".thru_z > \'2015-01-01\') left outer join (select "productexchangetable_2".name as name from ProductExchangeTable as "productexchangetable_2" where "productexchangetable_2".from_z <= \'2015-09-01\' and "productexchangetable_2".thru_z > \'2015-01-01\') as "productexchangetable_1" on ("productclassificationtable_0".exchange = "productexchangetable_1".name) where "productexchangetable_0".name = \'LNSE\' and "root".from_z <= \'2015-09-01\' and "root".thru_z > \'2015-01-01\'', + 'select distinct "productexchangetable_1".name as "name", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-09-01\' and "productclassificationtable_0".thru_z > DATE\'2015-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-09-01\' and "productexchangetable_0".thru_z > DATE\'2015-01-01\') left outer join (select "productexchangetable_2".name as name from ProductExchangeTable as "productexchangetable_2" where "productexchangetable_2".from_z <= DATE\'2015-09-01\' and "productexchangetable_2".thru_z > DATE\'2015-01-01\') as "productexchangetable_1" on ("productclassificationtable_0".exchange = "productexchangetable_1".name) where "productexchangetable_0".name = \'LNSE\' and "root".from_z <= DATE\'2015-09-01\' and "root".thru_z > DATE\'2015-01-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['LNSE', 'LNSE'], $result.values.rows.getString('name')); assertSameElements([%2015-8-15T00:00:00.000000000+0000, %2015-8-26T00:00:00.000000000+0000], $result.values.rows.getDate('from')); assertSameElements([%2015-8-26T00:00:00.000000000+0000, %2015-10-16T00:00:00.000000000+0000], $result.values.rows.getDate('thru')); @@ -48,7 +62,11 @@ function <> meta::relational::tests::milestoning::rangeQuery::testBus function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnProperty():Boolean[1] { let result = execute(|Product.allVersions()->filter(x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type == 'STOCK')->project([x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).type, x|$x.milestoning.from, x|$x.milestoning.thru], ['type', 'from', 'thru'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "productclassificationtable_0".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') where "productclassificationtable_0".type = \'STOCK\'', $result); + assertEqualsH2Compatible( + 'select distinct "productclassificationtable_0".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') where "productclassificationtable_0".type = \'STOCK\'', + 'select distinct "productclassificationtable_0".type as "type", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-09-01\' and "productclassificationtable_0".thru_z > DATE\'2015-01-01\') where "productclassificationtable_0".type = \'STOCK\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['STOCK', 'STOCK', 'STOCK'], $result.values.rows.getString('type')); assertSameElements([%2015-08-15T00:00:00.000000000+0000, %2015-08-26T00:00:00.000000000+0000, %2015-10-16T00:00:00.000000000+0000], $result.values.rows.getDate('from')); assertSameElements([%2015-08-26T00:00:00.000000000+0000, %2015-10-16T00:00:00.000000000+0000, %9999-12-31T00:00:00.000000000+0000], $result.values.rows.getDate('thru')); @@ -57,7 +75,11 @@ function <> meta::relational::tests::milestoning::rangeQuery::testBus function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnPropertyDeep():Boolean[1] { let result = execute(|Product.allVersions()->filter(x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).exchangeAllVersionsInRange(%2015-1-1, %2015-9-1).name == 'LNSE')->project([x|$x.classificationAllVersionsInRange(%2015-1-1, %2015-9-1).exchangeAllVersionsInRange(%2015-1-1, %2015-9-1).name, x|$x.milestoning.from, x|$x.milestoning.thru], ['name', 'from', 'thru'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "productexchangetable_1".name as "name", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-09-01\' and "productexchangetable_0".thru_z > \'2015-01-01\') left outer join (select "productexchangetable_2".name as name from ProductExchangeTable as "productexchangetable_2" where "productexchangetable_2".from_z <= \'2015-09-01\' and "productexchangetable_2".thru_z > \'2015-01-01\') as "productexchangetable_1" on ("productclassificationtable_0".exchange = "productexchangetable_1".name) where "productexchangetable_0".name = \'LNSE\'', $result); + assertEqualsH2Compatible( + 'select distinct "productexchangetable_1".name as "name", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-09-01\' and "productclassificationtable_0".thru_z > \'2015-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-09-01\' and "productexchangetable_0".thru_z > \'2015-01-01\') left outer join (select "productexchangetable_2".name as name from ProductExchangeTable as "productexchangetable_2" where "productexchangetable_2".from_z <= \'2015-09-01\' and "productexchangetable_2".thru_z > \'2015-01-01\') as "productexchangetable_1" on ("productclassificationtable_0".exchange = "productexchangetable_1".name) where "productexchangetable_0".name = \'LNSE\'', + 'select distinct "productexchangetable_1".name as "name", "root".from_z as "from", "root".thru_z as "thru" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-09-01\' and "productclassificationtable_0".thru_z > DATE\'2015-01-01\') left outer join ProductExchangeTable as "productexchangetable_0" on ("productclassificationtable_0".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-09-01\' and "productexchangetable_0".thru_z > DATE\'2015-01-01\') left outer join (select "productexchangetable_2".name as name from ProductExchangeTable as "productexchangetable_2" where "productexchangetable_2".from_z <= DATE\'2015-09-01\' and "productexchangetable_2".thru_z > DATE\'2015-01-01\') as "productexchangetable_1" on ("productclassificationtable_0".exchange = "productexchangetable_1".name) where "productexchangetable_0".name = \'LNSE\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['LNSE', 'LNSE', 'LNSE'], $result.values.rows.getString('name')); assertSameElements([%2015-08-15T00:00:00.000000000+0000, %2015-08-26T00:00:00.000000000+0000, %2015-10-16T00:00:00.000000000+0000], $result.values.rows.getDate('from')); assertSameElements([%2015-08-26T00:00:00.000000000+0000, %2015-10-16T00:00:00.000000000+0000, %9999-12-31T00:00:00.000000000+0000], $result.values.rows.getDate('thru')); @@ -66,7 +88,11 @@ function <> meta::relational::tests::milestoning::rangeQuery::testBus function <> meta::relational::tests::milestoning::rangeQuery::testProcessingTemporalRangeQueryOnRoot():Boolean[1] { let result = execute(|Certification.allVersionsInRange(%1979-1-1, %1982-1-1)->filter(x|$x.name == 'APCE' || $x.name == 'SRCE')->project([x|$x.name, x|$x.milestoning.in, x|$x.milestoning.out], ['name', 'in', 'out'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "root".name as "name", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" where ("root".name = \'APCE\' or "root".name = \'SRCE\') and "root".in_z <= \'1982-01-01\' and "root".out_z > \'1979-01-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "root".name as "name", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" where ("root".name = \'APCE\' or "root".name = \'SRCE\') and "root".in_z <= \'1982-01-01\' and "root".out_z > \'1979-01-01\'', + 'select distinct "root".name as "name", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" where ("root".name = \'APCE\' or "root".name = \'SRCE\') and "root".in_z <= DATE\'1982-01-01\' and "root".out_z > DATE\'1979-01-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['APCE', 'SRCE'], $result.values.rows.getString('name')); assertSameElements([%1980-01-01T00:00:00.000000000+0000, %1981-01-01T00:00:00.000000000+0000], $result.values.rows.getDate('in')); assertSameElements([%9999-12-31T00:00:00.000000000+0000, %9999-12-31T00:00:00.000000000+0000], $result.values.rows.getDate('out')); @@ -75,7 +101,11 @@ function <> meta::relational::tests::milestoning::rangeQuery::testPro function <> meta::relational::tests::milestoning::rangeQuery::testProcessingTemporalRangeQueryOnProperty():Boolean[1] { let result = execute(|Certification.allVersions()->filter(x|$x.traderAllVersionsInRange(%2012-1-1, %2014-1-1).kerberos == 'ggekko')->project([x|$x.traderAllVersionsInRange(%2012-1-1, %2014-1-1).kerberos, x|$x.milestoning.in, x|$x.milestoning.out], ['kerberos', 'in', 'out'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "tradertable_0".kerberos as "kerberos", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= \'2014-01-01\' and "tradertable_0".out_z > \'2012-01-01\') where "tradertable_0".kerberos = \'ggekko\'', $result); + assertEqualsH2Compatible( + 'select distinct "tradertable_0".kerberos as "kerberos", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= \'2014-01-01\' and "tradertable_0".out_z > \'2012-01-01\') where "tradertable_0".kerberos = \'ggekko\'', + 'select distinct "tradertable_0".kerberos as "kerberos", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= DATE\'2014-01-01\' and "tradertable_0".out_z > DATE\'2012-01-01\') where "tradertable_0".kerberos = \'ggekko\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['ggekko', 'ggekko'], $result.values.rows.getString('kerberos')); assertSameElements([%1980-01-01T00:00:00.000000000+0000, %1981-01-01T00:00:00.000000000+0000], $result.values.rows.getDate('in')); assertSameElements([%9999-12-31T00:00:00.000000000+0000, %9999-12-31T00:00:00.000000000+0000], $result.values.rows.getDate('out')); @@ -84,7 +114,11 @@ function <> meta::relational::tests::milestoning::rangeQuery::testPro function <> meta::relational::tests::milestoning::rangeQuery::testProcessingTemporalRangeQueryOnRootAndProperty():Boolean[1] { let result = execute(|Certification.allVersionsInRange(%1979-1-1, %1982-1-1)->filter(x|$x.traderAllVersionsInRange(%2012-1-1, %2014-1-1).kerberos == 'ggekko')->project([x|$x.traderAllVersionsInRange(%2012-1-1, %2014-1-1).kerberos, x|$x.milestoning.in, x|$x.milestoning.out], ['kerberos', 'in', 'out'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "tradertable_0".kerberos as "kerberos", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= \'2014-01-01\' and "tradertable_0".out_z > \'2012-01-01\') where "tradertable_0".kerberos = \'ggekko\' and "root".in_z <= \'1982-01-01\' and "root".out_z > \'1979-01-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "tradertable_0".kerberos as "kerberos", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= \'2014-01-01\' and "tradertable_0".out_z > \'2012-01-01\') where "tradertable_0".kerberos = \'ggekko\' and "root".in_z <= \'1982-01-01\' and "root".out_z > \'1979-01-01\'', + 'select distinct "tradertable_0".kerberos as "kerberos", "root".in_z as "in", "root".out_z as "out" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= DATE\'2014-01-01\' and "tradertable_0".out_z > DATE\'2012-01-01\') where "tradertable_0".kerberos = \'ggekko\' and "root".in_z <= DATE\'1982-01-01\' and "root".out_z > DATE\'1979-01-01\'', + $result->sqlRemoveFormatting() + ); assertSameElements(['ggekko', 'ggekko'], $result.values.rows.getString('kerberos')); assertSameElements([%1980-01-01T00:00:00.000000000+0000, %1981-01-01T00:00:00.000000000+0000], $result.values.rows.getDate('in')); assertSameElements([%9999-12-31T00:00:00.000000000+0000, %9999-12-31T00:00:00.000000000+0000], $result.values.rows.getDate('out')); @@ -93,13 +127,21 @@ function <> meta::relational::tests::milestoning::rangeQuery::testPro function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnRootWithSubsequentCallToMilestonedQualifiedPropertyWithFunction():Boolean[1] { let result = execute(|Certification.allVersionsInRange(%1979-1-1, %1982-1-1)->project(x|$x.trader(constantDate()).kerberos, ['kerberos'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "tradertable_0".kerberos as "kerberos" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= \'2015-01-01\' and "tradertable_0".out_z > \'2015-01-01\') where "root".in_z <= \'1982-01-01\' and "root".out_z > \'1979-01-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "tradertable_0".kerberos as "kerberos" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= \'2015-01-01\' and "tradertable_0".out_z > \'2015-01-01\') where "root".in_z <= \'1982-01-01\' and "root".out_z > \'1979-01-01\'', + 'select distinct "tradertable_0".kerberos as "kerberos" from CertificationTable as "root" left outer join TraderTable as "tradertable_0" on ("tradertable_0".kerberos = "root".kerberos and "tradertable_0".in_z <= DATE\'2015-01-01\' and "tradertable_0".out_z > DATE\'2015-01-01\') where "root".in_z <= DATE\'1982-01-01\' and "root".out_z > DATE\'1979-01-01\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnRootWithSubsequentCallToMilestonedQualifiedPropertyWithThisBusinessDate():Boolean[1] { let result = execute(|Product.allVersionsInRange(%1979-1-1, %1982-1-1)->project(x|$x.classificationTypeStr(), ['classificationType'])->distinct(), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select distinct "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= "root".from_z and "productclassificationtable_0".thru_z > "root".from_z) where "root".from_z <= \'1982-01-01\' and "root".thru_z > \'1979-01-01\'', $result); + assertEqualsH2Compatible( + 'select distinct "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= "root".from_z and "productclassificationtable_0".thru_z > "root".from_z) where "root".from_z <= \'1982-01-01\' and "root".thru_z > \'1979-01-01\'', + 'select distinct "productclassificationtable_0".type as "classificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= "root".from_z and "productclassificationtable_0".thru_z > "root".from_z) where "root".from_z <= DATE\'1982-01-01\' and "root".thru_z > DATE\'1979-01-01\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::milestoning::rangeQuery::testBusinessTemporalRangeQueryOnRootWithSubsequentCallToMilestonedQualifiedPropertyWithFunctionCallWithThisBusinessDateParameter():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testUnionOperationWithHybridMilestoningAcrossTables.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testUnionOperationWithHybridMilestoningAcrossTables.pure index e2123e5103f..2620ac5b888 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testUnionOperationWithHybridMilestoningAcrossTables.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/milestoning/tests/testUnionOperationWithHybridMilestoningAcrossTables.pure @@ -13,6 +13,7 @@ // limitations under the License. ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::runtime::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; @@ -23,7 +24,11 @@ import meta::relational::tests::milestoning::union::*; function <> meta::relational::tests::milestoning::union::testHybridMilestoningUnionOperationWithNonTemporalRoot():Boolean[1] { let result = execute(|Order.all()->filter(o|$o.biTemporalProduct(%2015-8-25, %2018-8-26).name == 'ProductName1'), hybridMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, "root".prodFk as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, null as prodFk_2, "root".prodFk as prodFk_3 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id or "unionBase".prodFk_2 = "unionalias_1".id or "unionBase".prodFk_3 = "unionalias_1".id) and (("unionalias_1"."in_z_2" <= \'2015-08-25\' and "unionalias_1"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= \'2018-08-26\' and "unionalias_1"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = \'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) where "unionalias_1"."BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" = \'ProductName1\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, "root".prodFk as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, null as prodFk_2, "root".prodFk as prodFk_3 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id or "unionBase".prodFk_2 = "unionalias_1".id or "unionBase".prodFk_3 = "unionalias_1".id) and (("unionalias_1"."in_z_2" <= \'2015-08-25\' and "unionalias_1"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= \'2018-08-26\' and "unionalias_1"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = \'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) where "unionalias_1"."BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" = \'ProductName1\'', + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, "root".prodFk as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, null as prodFk_2, "root".prodFk as prodFk_3 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= DATE\'2018-08-26\' and "root".thru_z > DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= DATE\'2015-08-25\' and "root".out_z > DATE\'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".name as "BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" from BiTemporalProductTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id or "unionBase".prodFk_2 = "unionalias_1".id or "unionBase".prodFk_3 = "unionalias_1".id) and (("unionalias_1"."in_z_2" <= DATE\'2015-08-25\' and "unionalias_1"."out_z_2" > DATE\'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= DATE\'2018-08-26\' and "unionalias_1"."thru_z_0" > DATE\'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = DATE\'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) where "unionalias_1"."BiTemporalProductTableWithBusinessMilestoningname_BiTemporalProductTableWithBusinessSnapshotMilestoningname_BiTemporalProductTableWithProcessingMilestoningname_BiTemporalProductTableWithNoMilestoningname" = \'ProductName1\'', + $result->sqlRemoveFormatting() + ); assertEquals([1, 1, 1, 1, 1, 1, 1, 1], $result.values.id); } @@ -51,7 +56,11 @@ function <> meta::relational::tests::milestoning::union::testHyb ): Boolean[1] { let result = execute(|Order.all()->filter(o|$o.biTemporalProduct(%2015-8-25, %2018-8-26).biTemporalClassification.description == 'STOCK DESC-V2'), hybridMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, "root".prodFk as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, null as prodFk_2, "root".prodFk as prodFk_3 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".type as type_0, null as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, null as type_0, "root".type as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".id as id, null as type_0, null as type_1, "root".type as type_2, null as type_3 from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, null as type_0, null as type_1, null as type_2, "root".type as type_3 from BiTemporalProductTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id or "unionBase".prodFk_2 = "unionalias_1".id or "unionBase".prodFk_3 = "unionalias_1".id) and (("unionalias_1"."in_z_2" <= \'2015-08-25\' and "unionalias_1"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= \'2018-08-26\' and "unionalias_1"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = \'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithNoMilestoning as "root") as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type or "unionalias_1".type_2 = "unionalias_2".type or "unionalias_1".type_3 = "unionalias_2".type) and (("unionalias_2"."in_z_2" <= \'2015-08-25\' and "unionalias_2"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_2"."in_z_2", "unionalias_2"."out_z_2") is null and (("unionalias_2"."from_z_0" <= \'2018-08-26\' and "unionalias_2"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."thru_z_0") is null) and ("unionalias_2"."snapshotDate_1" = \'2018-08-26\' or "unionalias_2"."snapshotDate_1" is null))) where "unionalias_2"."%s" = \'STOCK DESC-V2\''->format($tableNames), $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, "root".prodFk as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, null as prodFk_2, "root".prodFk as prodFk_3 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".type as type_0, null as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, null as type_0, "root".type as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".id as id, null as type_0, null as type_1, "root".type as type_2, null as type_3 from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, null as type_0, null as type_1, null as type_2, "root".type as type_3 from BiTemporalProductTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id or "unionBase".prodFk_2 = "unionalias_1".id or "unionBase".prodFk_3 = "unionalias_1".id) and (("unionalias_1"."in_z_2" <= \'2015-08-25\' and "unionalias_1"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= \'2018-08-26\' and "unionalias_1"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = \'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithNoMilestoning as "root") as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type or "unionalias_1".type_2 = "unionalias_2".type or "unionalias_1".type_3 = "unionalias_2".type) and (("unionalias_2"."in_z_2" <= \'2015-08-25\' and "unionalias_2"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_2"."in_z_2", "unionalias_2"."out_z_2") is null and (("unionalias_2"."from_z_0" <= \'2018-08-26\' and "unionalias_2"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."thru_z_0") is null) and ("unionalias_2"."snapshotDate_1" = \'2018-08-26\' or "unionalias_2"."snapshotDate_1" is null))) where "unionalias_2"."%s" = \'STOCK DESC-V2\''->format($tableNames), + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".prodFk as prodFk_0, null as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, "root".prodFk as prodFk_1, null as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, "root".prodFk as prodFk_2, null as prodFk_3 from OrderTable as "root" UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", null as prodFk_0, null as prodFk_1, null as prodFk_2, "root".prodFk as prodFk_3 from OrderTable as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, "root".type as type_0, null as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= DATE\'2018-08-26\' and "root".thru_z > DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, null as type_0, "root".type as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".id as id, null as type_0, null as type_1, "root".type as type_2, null as type_3 from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= DATE\'2015-08-25\' and "root".out_z > DATE\'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".id as id, null as type_0, null as type_1, null as type_2, "root".type as type_3 from BiTemporalProductTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".prodFk_0 = "unionalias_1".id or "unionBase".prodFk_1 = "unionalias_1".id or "unionBase".prodFk_2 = "unionalias_1".id or "unionBase".prodFk_3 = "unionalias_1".id) and (("unionalias_1"."in_z_2" <= DATE\'2015-08-25\' and "unionalias_1"."out_z_2" > DATE\'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= DATE\'2018-08-26\' and "unionalias_1"."thru_z_0" > DATE\'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = DATE\'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessMilestoning as "root" where "root".from_z <= DATE\'2018-08-26\' and "root".thru_z > DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithProcessingMilestoning as "root" where "root".in_z <= DATE\'2015-08-25\' and "root".out_z > DATE\'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithNoMilestoning as "root") as "unionalias_2" on (("unionalias_1".type_0 = "unionalias_2".type or "unionalias_1".type_1 = "unionalias_2".type or "unionalias_1".type_2 = "unionalias_2".type or "unionalias_1".type_3 = "unionalias_2".type) and (("unionalias_2"."in_z_2" <= DATE\'2015-08-25\' and "unionalias_2"."out_z_2" > DATE\'2015-08-25\') or coalesce("unionalias_2"."in_z_2", "unionalias_2"."out_z_2") is null and (("unionalias_2"."from_z_0" <= DATE\'2018-08-26\' and "unionalias_2"."thru_z_0" > DATE\'2018-08-26\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."thru_z_0") is null) and ("unionalias_2"."snapshotDate_1" = DATE\'2018-08-26\' or "unionalias_2"."snapshotDate_1" is null))) where "unionalias_2"."%s" = \'STOCK DESC-V2\''->format($tableNames), + $result->sqlRemoveFormatting() + ); assertEquals([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], $result.values.id); } @@ -74,7 +83,11 @@ function <> meta::relational::tests::milestoning::union::testHyb ): Boolean[1] { let result = execute(|BiTemporalProduct.all(%2015-8-25, %2018-8-26)->filter(p|$p.biTemporalClassification.description == 'STOCK DESC-V2'), hybridMilestoningUnionMap, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."snapshotDate_1" as "snapshotDate_1", "unionBase"."in_z_2" as "in_z_2", "unionBase"."out_z_2" as "out_z_2" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type_0, null as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", null as type_0, "root".type as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", null as type_0, null as type_1, "root".type as type_2, null as type_3 from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", null as type_0, null as type_1, null as type_2, "root".type as type_3 from BiTemporalProductTableWithNoMilestoning as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type or "unionBase".type_2 = "unionalias_1".type or "unionBase".type_3 = "unionalias_1".type) and (("unionalias_1"."in_z_2" <= \'2015-08-25\' and "unionalias_1"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= \'2018-08-26\' and "unionalias_1"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = \'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) where "unionalias_1"."%s" = \'STOCK DESC-V2\''->format($tableNames), $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."snapshotDate_1" as "snapshotDate_1", "unionBase"."in_z_2" as "in_z_2", "unionBase"."out_z_2" as "out_z_2" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type_0, null as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", null as type_0, "root".type as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", null as type_0, null as type_1, "root".type as type_2, null as type_3 from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", null as type_0, null as type_1, null as type_2, "root".type as type_3 from BiTemporalProductTableWithNoMilestoning as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessMilestoning as "root" where "root".from_z <= \'2018-08-26\' and "root".thru_z > \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithProcessingMilestoning as "root" where "root".in_z <= \'2015-08-25\' and "root".out_z > \'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type or "unionBase".type_2 = "unionalias_1".type or "unionBase".type_3 = "unionalias_1".type) and (("unionalias_1"."in_z_2" <= \'2015-08-25\' and "unionalias_1"."out_z_2" > \'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= \'2018-08-26\' and "unionalias_1"."thru_z_0" > \'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = \'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) where "unionalias_1"."%s" = \'STOCK DESC-V2\''->format($tableNames), + 'select "unionBase".u_type as u_type, "unionBase"."pk_0_0" as "pk_0_0", "unionBase"."pk_0_1" as "pk_0_1", "unionBase"."pk_0_2" as "pk_0_2", "unionBase"."pk_0_3" as "pk_0_3", "unionBase"."id" as "id", "unionBase"."name" as "name", "unionBase"."k_processingDate" as "k_processingDate", "unionBase"."k_businessDate" as "k_businessDate", "unionBase"."from_z_0" as "from_z_0", "unionBase"."thru_z_0" as "thru_z_0", "unionBase"."snapshotDate_1" as "snapshotDate_1", "unionBase"."in_z_2" as "in_z_2", "unionBase"."out_z_2" as "out_z_2" from (select \'0\' as u_type, "root".id as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type_0, null as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessMilestoning as "root" where "root".from_z <= DATE\'2018-08-26\' and "root".thru_z > DATE\'2018-08-26\' UNION ALL select \'1\' as u_type, null as "pk_0_0", "root".id as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", null as type_0, "root".type as type_1, null as type_2, null as type_3 from BiTemporalProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2018-08-26\' UNION ALL select \'2\' as u_type, null as "pk_0_0", null as "pk_0_1", "root".id as "pk_0_2", null as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", null as type_0, null as type_1, "root".type as type_2, null as type_3 from BiTemporalProductTableWithProcessingMilestoning as "root" where "root".in_z <= DATE\'2015-08-25\' and "root".out_z > DATE\'2015-08-25\' UNION ALL select \'3\' as u_type, null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".id as "pk_0_3", "root".id as "id", "root".name as "name", \'2015-08-25\' as "k_processingDate", \'2018-08-26\' as "k_businessDate", null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", null as type_0, null as type_1, null as type_2, "root".type as type_3 from BiTemporalProductTableWithNoMilestoning as "root") as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessMilestoning as "root" where "root".from_z <= DATE\'2018-08-26\' and "root".thru_z > DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".snapshotDate as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2018-08-26\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", "root".in_z as "in_z_2", "root".out_z as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithProcessingMilestoning as "root" where "root".in_z <= DATE\'2015-08-25\' and "root".out_z > DATE\'2015-08-25\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "snapshotDate_1", null as "in_z_2", null as "out_z_2", "root".type as type, "root".type_description as "%s" from BiTemporalProductClassificationTableWithNoMilestoning as "root") as "unionalias_1" on (("unionBase".type_0 = "unionalias_1".type or "unionBase".type_1 = "unionalias_1".type or "unionBase".type_2 = "unionalias_1".type or "unionBase".type_3 = "unionalias_1".type) and (("unionalias_1"."in_z_2" <= DATE\'2015-08-25\' and "unionalias_1"."out_z_2" > DATE\'2015-08-25\') or coalesce("unionalias_1"."in_z_2", "unionalias_1"."out_z_2") is null and (("unionalias_1"."from_z_0" <= DATE\'2018-08-26\' and "unionalias_1"."thru_z_0" > DATE\'2018-08-26\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."thru_z_0") is null) and ("unionalias_1"."snapshotDate_1" = DATE\'2018-08-26\' or "unionalias_1"."snapshotDate_1" is null))) where "unionalias_1"."%s" = \'STOCK DESC-V2\''->format($tableNames), + $result->sqlRemoveFormatting() + ); assertEquals([1, 1, 1, 1, 1, 1, 1, 1], $result.values.id); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/m2m2rShowcase.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/m2m2rShowcase.pure index 2ae6cea13e7..91d7dacdbce 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/m2m2rShowcase.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/modelToModelToRelational/m2m2rShowcase.pure @@ -1,3 +1,4 @@ +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::executionPlan::toString::*; import meta::pure::runtime::*; import meta::relational::runtime::*; @@ -52,7 +53,7 @@ function <> meta::relational::tests::m2m2r::tes meta::relational::tests::m2m2r::AxionToModelMapping, meta::relational::tests::m2m2r::runtime(), meta::relational::extension::relationalExtensions(), noDebug())->planToString( meta::relational::extension::relationalExtensions()); - let expected = + let expectedLegacyH2 = 'Relational\n' + '(\n' + ' type = TDS[(name, String, "", ""), (prop3, Number, "", "")]\n' + @@ -60,7 +61,15 @@ function <> meta::relational::tests::m2m2r::tes ' sql = select "root".name as "name", case when "sourceannouncement_0".basis = 0.0 then 0.0 else (((1.0 * "root".entitledQuantity) / "sourceannouncement_0".basis) * "sourceannouncement_0".grossRate) end as "prop3" from S.sourceEntitlement as "root" left outer join S.SourceAnnouncement as "sourceannouncement_0" on ("root".id = "sourceannouncement_0".id)\n' + ' connection = RelationalDatabaseConnection(type = "H2")\n' + ')\n' ; - assertEquals($expected, $result); + let expectedNewH2 = + 'Relational\n' + + '(\n' + + ' type = TDS[(name, String, "", ""), (prop3, Number, "", "")]\n' + + ' resultColumns = [("name", VARCHAR(200)), ("prop3", "")]\n' + + ' sql = select "root".name as "name", case when "sourceannouncement_0".basis = CAST(0.0 AS FLOAT) then CAST(0.0 AS FLOAT) else (((1.0 * "root".entitledQuantity) / "sourceannouncement_0".basis) * "sourceannouncement_0".grossRate) end as "prop3" from S.sourceEntitlement as "root" left outer join S.SourceAnnouncement as "sourceannouncement_0" on ("root".id = "sourceannouncement_0".id)\n' + + ' connection = RelationalDatabaseConnection(type = "H2")\n' + + ')\n' ; + assertEqualsH2Compatible($expectedLegacyH2, $expectedNewH2, $result); } function <> meta::relational::tests::m2m2r::testProp4():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/tests/testMergeRules.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/tests/testMergeRules.pure index 92531d6c9d1..d0e95d6ea90 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/tests/testMergeRules.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/pureToSQLQuery/tests/testMergeRules.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; import meta::relational::tests::model::simple::*; @@ -67,7 +68,11 @@ function <> meta::relational::tests::mergerules::m { let result = execute(|meta::relational::tests::milestoning::Product.all(%2015-10-16)->filter(p|$p.classification(%2015-10-16).type=='STOCK')->project([p|$p.name, p|$p.classification(%2015-10-16).type],['productName','productClassificationType']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['ProductName2~STOCK'], $result.values.rows->map(r|$r.getString('productName')+'~'+$r.getString('productClassificationType'))); - assertSameSQL('select "root".name as "productName", "productclassificationtable_0".type as "productClassificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "productName", "productclassificationtable_0".type as "productClassificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "productName", "productclassificationtable_0".type as "productClassificationType" from ProductTable as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where "productclassificationtable_0".type = \'STOCK\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 12. Milestoning not supported @@ -75,5 +80,9 @@ function <> meta::relational::tests::mergerules::m { let result = execute(|meta::relational::tests::milestoning::Product.all(%2015-10-16)->filter(p|$p.synonyms(%2015-10-16)->exists(s|$s.synonym=='GS-Mod-S1'))->project([p|$p.name, p|$p.synonyms(%2015-10-16).synonym],['productName','productSynonymsName']), milestoningmap, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['ProductName2~GS-Mod-S1', 'ProductName2~GS-Mod-S2'], $result.values.rows->map(r|$r.getString('productName')+'~'+$r.getString('productSynonymsName'))); - assertSameSQL('select "root".name as "productName", "productsynonymtable_2".synonym as "productSynonymsName" from ProductTable as "root" left outer join (select distinct "productsynonymtable_1".name from ProductSynonymTable as "productsynonymtable_1" where "productsynonymtable_1".from_z <= \'2015-10-16\' and "productsynonymtable_1".thru_z > \'2015-10-16\' and "productsynonymtable_1".synonym = \'GS-Mod-S1\') as "productsynonymtable_0" on ("root".name = "productsynonymtable_0".name) left outer join ProductSynonymTable as "productsynonymtable_2" on ("root".name = "productsynonymtable_2".name and "productsynonymtable_2".from_z <= \'2015-10-16\' and "productsynonymtable_2".thru_z > \'2015-10-16\') where "productsynonymtable_0".name is not null and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result); + assertEqualsH2Compatible( + 'select "root".name as "productName", "productsynonymtable_2".synonym as "productSynonymsName" from ProductTable as "root" left outer join (select distinct "productsynonymtable_1".name from ProductSynonymTable as "productsynonymtable_1" where "productsynonymtable_1".from_z <= \'2015-10-16\' and "productsynonymtable_1".thru_z > \'2015-10-16\' and "productsynonymtable_1".synonym = \'GS-Mod-S1\') as "productsynonymtable_0" on ("root".name = "productsynonymtable_0".name) left outer join ProductSynonymTable as "productsynonymtable_2" on ("root".name = "productsynonymtable_2".name and "productsynonymtable_2".from_z <= \'2015-10-16\' and "productsynonymtable_2".thru_z > \'2015-10-16\') where "productsynonymtable_0".name is not null and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "productName", "productsynonymtable_2".synonym as "productSynonymsName" from ProductTable as "root" left outer join (select distinct "productsynonymtable_1".name from ProductSynonymTable as "productsynonymtable_1" where "productsynonymtable_1".from_z <= DATE\'2015-10-16\' and "productsynonymtable_1".thru_z > DATE\'2015-10-16\' and "productsynonymtable_1".synonym = \'GS-Mod-S1\') as "productsynonymtable_0" on ("root".name = "productsynonymtable_0".name) left outer join ProductSynonymTable as "productsynonymtable_2" on ("root".name = "productsynonymtable_2".name and "productsynonymtable_2".from_z <= DATE\'2015-10-16\' and "productsynonymtable_2".thru_z > DATE\'2015-10-16\') where "productsynonymtable_0".name is not null and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension.pure index 78eeb02995a..d3c5f215231 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension.pure @@ -11,9 +11,7 @@ function <> meta::relational::functions::sqlQueryToString::h function <> meta::relational::functions::sqlQueryToString::h2::createDbExtensionForH2():DbExtension[1] { - let conn = ^TestDatabaseConnection(element=emptyDb, type=DatabaseType.H2); - let results = executeInDb('SELECT H2VERSION();', $conn); - let h2Versions = $results.rows.values; + let h2Versions = getH2Versions(); assertEquals(1, size($h2Versions), 'More than one H2 version found when loading extension'); if($h2Versions->toOne()->eq('1.4.200'), @@ -22,6 +20,29 @@ function <> meta::relational::functions::sqlQueryToString::h2::c ); } +function meta::relational::functions::sqlQueryToString::h2::assertEqualsH2Compatible( + legacyExpected: Any[1], + upgradedExpected: Any[1], + actual: Any[1] +): Boolean[1] +{ + let h2Versions = getH2Versions(); + assertEquals(1, size($h2Versions), 'More than one H2 version found asserting test outputs'); + + if($h2Versions->toOne()->eq('1.4.200'), + | assertEquals($legacyExpected, $actual), + | assertEquals($upgradedExpected, $actual) + ); +} + +function <> meta::relational::functions::sqlQueryToString::h2::getH2Versions(): Any[*] +{ + let conn = ^TestDatabaseConnection(element=emptyDb, type=DatabaseType.H2); + let results = executeInDb('SELECT H2VERSION();', $conn); + $results.rows.values; +} + + ###Relational // Database needed just to get the H2 connection version Database meta::relational::functions::sqlQueryToString::h2::emptyDb() \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension2_1_214.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension2_1_214.pure index bcef6849dfd..77d572eaee2 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension2_1_214.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/sqlQueryToString/dbSpecific/h2/h2Extension2_1_214.pure @@ -47,25 +47,118 @@ function <> meta::relational::functions::sqlQueryToString::h2::v function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::translateCreateTableStatementForH2(c:CreateTableSQL[1], dbConfig: DbConfig[1]): String[1] { - if($c.isTempTable->isTrue(),| 'CREATE LOCAL TEMPORARY TABLE ' + $c.table->tableToString($dbConfig) + '('+ $c.table.columns->map(r|$r->match([c:Column[1]| $c.name->processColumnName($dbConfig) + ' ' + getColumnTypeSqlTextDefault($c.type), - r:RelationalOperationElement[1]| fail('Only \'Column\' types are supported when creating temporary tables, found: '+$r->type()->toOne()->elementToPath());'';]))->joinStrings(',') + ');' - ,| $c->meta::relational::functions::sqlQueryToString::default::translateCreateTableStatementDefault($dbConfig)) + if($c.isTempTable->isTrue(), + | 'CREATE LOCAL TEMPORARY TABLE ' + $c.table->tableToString($dbConfig) + + '(' + + $c.table.columns->map(r| $r->match([ + c: Column[1] | $c.name->processColumnName($dbConfig) + ' ' + getColumnTypeSqlTextH2($c.type), + r: RelationalOperationElement[1] | fail('Only \'Column\' types are supported when creating temporary tables, found: '+$r->type()->toOne()->elementToPath());''; + ]))->joinStrings(',') + + ');', + | $c->translateCreateTableStatementH2($dbConfig) + ) +} +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::getColumnTypeSqlTextH2(columnType: meta::relational::metamodel::datatype::DataType[1]): String[1] +{ + $columnType->match([ + s : meta::relational::metamodel::datatype::SemiStructured[1] | 'VARCHAR(4000)', + a : Any[*] | dataTypeToSqlTextH2($columnType) + ]) +} + +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::translateCreateTableStatementH2(createTableSQL:CreateTableSQL[1], dbConfig:DbConfig[1]): String[1] +{ + let t= $createTableSQL.table; + let applyConstraints = $createTableSQL.applyConstraints; + 'Create Table '+if($t.schema.name == 'default',|'',|$t.schema.name+'.')+$t.name+ + + '(' + + $t.columns->cast(@meta::relational::metamodel::Column) + ->map(c | $c.name->processColumnName($dbConfig) + ' ' + getColumnTypeSqlTextH2($c.type) + if($c.nullable->isEmpty() || $applyConstraints == false, | '', | if($c.nullable == true , | ' NULL', | ' NOT NULL'))) + ->joinStrings(',') + + if ($t.primaryKey->isEmpty() || $applyConstraints == false, | '', | ', PRIMARY KEY(' + $t.primaryKey->map(c | $c.name)->joinStrings(',') + ')') + +');'; } function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::loadValuesToDbTableForH2(l:LoadTableSQL[1], dbConfig: DbConfig[1]): String[*] { - if($l.absolutePathToFile->isNotEmpty(),| 'INSERT INTO ' + $l.table->tableToString($dbConfig) + ' SELECT * FROM CSVREAD(\''+$l.absolutePathToFile->toOne()->processOperation($dbConfig.dbType, []) + '\');' - ,| $l->meta::relational::functions::sqlQueryToString::default::loadValuesToDbTableDefault($dbConfig)) + if($l.absolutePathToFile->isNotEmpty(), + | 'INSERT INTO ' + $l.table->tableToString($dbConfig) + ' SELECT * FROM CSVREAD(\''+$l.absolutePathToFile->toOne()->processOperation($dbConfig.dbType, []) + '\');', + | $l->meta::relational::functions::sqlQueryToString::h2::v2_1_214::loadValuesToDbTableH2($dbConfig) + ) +} + +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::loadValuesToDbTableH2(loadTableSQL: LoadTableSQL[1], dbConfig: DbConfig[1]): String[*] +{ + $loadTableSQL.parsedData.values->map(row| let sql = + 'insert into ' + if($loadTableSQL.table.schema.name == 'default', | '' , | $loadTableSQL.table.schema.name + '.') + $loadTableSQL.table.name + + ' (' + + $loadTableSQL.columnsToLoad.name->map(colName | $colName->processColumnName($dbConfig))->joinStrings(',') + +') ' + + 'values (' + + $row.values->meta::relational::functions::sqlQueryToString::h2::v2_1_214::convertValuesToCsvH2($loadTableSQL.columnsToLoad.type) + + ');'; + ); +} + +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::convertValuesToCsvH2(str: String[*], types: Any[*]): String[1] +{ + let stringToken = map(range($types->size()), {x| if($str->at($x) == '' || $str->at($x) == '---null---', |'null', |$types->at($x)->match([ + s: meta::relational::metamodel::datatype::Varchar[*] | '\'' + $str->at($x)->replace('\'', '\'\'') + '\'', + s: meta::relational::metamodel::datatype::SemiStructured[*] | '\'' + $str->at($x)->replace('\'', '\'\'') + '\'', + s: meta::relational::metamodel::datatype::Char[*] | '\'' + $str->at($x)->replace('\'', '\'\'') + '\'', + d: meta::relational::metamodel::datatype::Date[*] | '\'' + $str->at($x) + '\'', + t: meta::relational::metamodel::datatype::Timestamp[*] | '\'' + if($str->at($x)->length() > 10, |$str->at($x), |$str->at($x)) + '\'', + b: meta::relational::metamodel::datatype::Bit[1] | bitValueFromString($str->at($x)), + a: Any[*] | $str->at($x) + ]))})->joinStrings(','); +} + +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::bitValueFromString(s: String[1]): String[1] +{ + let truesList = ['y', '1', 'true']; + let falsesList = ['n', '0', 'false']; + let bitStr = $s->trim()->toLower(); + + println('hello'); + + let bitVal = if($bitStr->in($truesList), + | 'true', + | if($bitStr->in($falsesList), + | 'false', + | $s + ) + ); + + $bitVal; } function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::getLiteralProcessorsForH2():Map[1] { newMap([ - pair(Boolean, ^LiteralProcessor(format = '%s', transform = toString_Any_1__String_1_->literalTransform())) + pair(Boolean, ^LiteralProcessor(format = '%s', transform = toString_Any_1__String_1_->literalTransform())), + pair(Float, ^LiteralProcessor(format = 'CAST(%s AS FLOAT)', transform = toString_Any_1__String_1_->literalTransform())), + pair(StrictDate, ^LiteralProcessor(format = 'DATE\'%s\'', transform = {d:StrictDate[1], dbTimeZone:String[0..1] | $d->convertDateToSqlString($dbTimeZone)})), + pair(DateTime, ^LiteralProcessor(format = 'TIMESTAMP\'%s\'', transform = {d:DateTime[1], dbTimeZone:String[0..1] | $d->convertDateToSqlString($dbTimeZone)})), + pair(Date, ^LiteralProcessor(format = 'TIMESTAMP\'%s\'', transform = {d:Date[1], dbTimeZone:String[0..1] | $d->convertDateToSqlString($dbTimeZone)})) ]); } +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::dataTypeToSqlTextH2(type: meta::relational::metamodel::datatype::DataType[1]):String[1] +{ + let MAX_CHAR_LENGTH = 1000000000; + let MIN_CHAR_LENGTH = 1; + let MIN_PRECISION = 1; + + $type->match([ + v : meta::relational::metamodel::datatype::Varchar[1] | format('VARCHAR(%d)', max([$MIN_CHAR_LENGTH, min([$v.size, $MAX_CHAR_LENGTH])])), + c : meta::relational::metamodel::datatype::Char[1] | format('CHAR(%d)', max([$MIN_CHAR_LENGTH, min([$c.size, $MAX_CHAR_LENGTH])])), // H2 now pads characters to hit stated size + //b : meta::relational::metamodel::datatype::Bit[1] | 'TINYINT', // allows comparisons to Booleans with new H2 + n : meta::relational::metamodel::datatype::Numeric[1] | format('NUMERIC(%d, %d)', [max([$n.precision, $MIN_PRECISION]), $n.scale]), + d : meta::relational::metamodel::datatype::DataType[1] | getColumnTypeSqlTextDefault($d) + ]); +} + // words found in ParserUtil.KEYWORDS of h2database EXCEPT for anything listed explicitly as NON_KEYWORD for compatibility function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::h2ReservedWords():String[*] { @@ -109,10 +202,10 @@ function <> meta::relational::functions::sqlQueryToString::h2::v dynaFnToSql('firstDayOfThisYear', $allStates, ^ToSql(format='dateadd(DAY, -(dayofyear(current_date()) - 1), current_date())')), dynaFnToSql('firstDayOfWeek', $allStates, ^ToSql(format='dateadd(DAY, -(mod(dayofweek(%s)+5, 7)), %s)', transform={p:String[1] | $p->repeat(2)})), dynaFnToSql('firstDayOfYear', $allStates, ^ToSql(format='dateadd(DAY, -(dayofyear(%s) - 1), %s)', transform={p:String[1] | $p->repeat(2)})), - dynaFnToSql('firstHourOfDay', $allStates, ^ToSql(format='date_trunc(\'day\', timestamp %s)')), - dynaFnToSql('firstMillisecondOfSecond', $allStates, ^ToSql(format='date_trunc(\'second\', timestamp %s)')), - dynaFnToSql('firstMinuteOfHour', $allStates, ^ToSql(format='date_trunc(\'hour\', timestamp %s)')), - dynaFnToSql('firstSecondOfMinute', $allStates, ^ToSql(format='date_trunc(\'minute\', timestamp %s)')), + dynaFnToSql('firstHourOfDay', $allStates, ^ToSql(format='date_trunc(\'day\', %s)')), + dynaFnToSql('firstMillisecondOfSecond', $allStates, ^ToSql(format='date_trunc(\'second\', %s)')), + dynaFnToSql('firstMinuteOfHour', $allStates, ^ToSql(format='date_trunc(\'hour\', %s)')), + dynaFnToSql('firstSecondOfMinute', $allStates, ^ToSql(format='date_trunc(\'minute\', %s)')), dynaFnToSql('hour', $allStates, ^ToSql(format='hour(%s)')), dynaFnToSql('indexOf', $allStates, ^ToSql(format='LOCATE(%s)', transform={p:String[2] | $p->at(1) + ', ' + $p->at(0)})), dynaFnToSql('isNumeric', $allStates, ^ToSql(format='(lower(%s) = upper(%s))')), @@ -377,7 +470,7 @@ function <> meta::relational::functions::sqlQueryToString::h2::v ); $format.separator + 'select ' + processTop($s, $format, $dbConfig, $extensions) + if($s.distinct == true,|'distinct ',|'') + - processSelectColumns($s.columns, $dbConfig, $format->indent(), true, $extensions) + + processSelectColumnsH2($s.columns, $dbConfig, $format->indent(), true, $extensions) + if($s.data == [],|'',| ' ' + $format.separator + 'from ' + $s.data->toOne()->processJoinTreeNodeH2([], $dbConfig, $format->indent(), [], $extensions)) + if (eq($opStr, ''), |'', | ' ' + $format.separator + 'where ' + $opStr) + if ($s.groupBy->isEmpty(),|'',| ' ' + $format.separator + 'group by '+$s.groupBy->processGroupByColumns($dbConfig, $format->indent(), true, $extensions)->makeString(','))+ @@ -386,10 +479,37 @@ function <> meta::relational::functions::sqlQueryToString::h2::v + processLimit($s, $dbConfig, $format, $extensions, [], processSliceOrDropForH2_SelectSQLQuery_1__Format_1__DbConfig_1__Extension_MANY__Any_1__String_1_); } -/* +/* +* ifs in column creation gets translated to cases and so should also be candidates for wrapping +*/ +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::processSelectColumnsH2( + s: RelationalOperationElement[*], + dbConfig: DbConfig[1], + format: Format[1], + conditionalExprAllowed: Boolean[1], + extensions: Extension[*] +): String[1] +{ + if($s->size() == 0, + |'*', + | $format.separator + $s->map(r| $r->match([ + a: Alias[1] | + let shouldWrapWithCase = $a.relationalElement->isBooleanOperation($extensions) && !$conditionalExprAllowed; + if($shouldWrapWithCase, + | 'case when (' + + $a.relationalElement->wrapH2Boolean($extensions)->processOperation($dbConfig, $format, ^GenerationState(generationSide = GenerationSide.Select, withinWhenClause = true), $extensions) + + ') then \'true\' else \'false\' end as ' + $a.name, + | $r->wrapH2Boolean($extensions)->processOperation($dbConfig, $format, ^GenerationState(generationSide = GenerationSide.Select, withinWhenClause = false), $extensions) + );, + + z: RelationalOperationElement[1] | $z->wrapH2Boolean($extensions)->processOperation($dbConfig, $format, ^GenerationState(generationSide = GenerationSide.Select, withinWhenClause = false), $extensions) + ]))->joinStrings(', ' + $format.separator); + ); +} + +/* TODO: -1. remove the access comment when done testing -2. what to do with freemarker placeholder operations? They are also RelationalOpElements +- what to do with freemarker placeholder operations? They are also RelationalOpElements */ // To be used to wrap filter conditions and their arguments to compare boolean to boolean function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::wrapH2Boolean( @@ -399,9 +519,9 @@ function <> meta::relational::functions::sqlQueryToString::h2::v // Base case: at an equals sign whose children are case and a booleanExpr OR we are a solitary case node // Tail recurse: if we are at oneOf ['and', 'or', 'not', 'group'] or a optional placeholder, then recurse left and right $op->match([ - d: DynaFunction[1] | if(isCaseDyna($d), + d: DynaFunction[1] | if(isCastableDyna($d), | ^DynaFunction(name='castBoolean', parameters=[$d]), - | if(isEqualComparingCaseAndBoolean($d), + | if(isEqualComparingCastableDynaAndBoolean($d), | ^$d(parameters=$d.parameters->map(p| ^DynaFunction(name='castBoolean', parameters=[$p]))), | if(atRecursibleOperation($d), | ^$d(parameters=$d.parameters->map(p| $p->wrapH2Boolean($extensions))), @@ -409,6 +529,8 @@ function <> meta::relational::functions::sqlQueryToString::h2::v ) ) ), + // Casting alias is required for wrapping logic within projections + a: Alias[1] | ^$a(relationalElement = wrapH2Boolean($a.relationalElement, $extensions)), f: FreeMarkerOperationHolder[1] | if($f.name->in(['optionalVarPlaceHolderOpSelector']), | ^$f(parameters=$f.parameters->map(p| $p->wrapH2Boolean($extensions))), | $f @@ -417,19 +539,20 @@ function <> meta::relational::functions::sqlQueryToString::h2::v ]); } -function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::isEqualComparingCaseAndBoolean( +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::isEqualComparingCastableDynaAndBoolean( d: DynaFunction[1] ): Boolean[1] { - $d.name == 'equal' && $d.parameters->at(0)->isCaseDyna() && $d.parameters->at(1)->isBooleanExpr(); + $d.name == 'equal' && $d.parameters->at(0)->isCastableDyna() && $d.parameters->at(1)->isBooleanExpr(); } -function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::isCaseDyna( +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::isCastableDyna( op: RelationalOperationElement[1] ): Boolean[1] { - $op->instanceOf(DynaFunction) - && cast($op, @DynaFunction).name == 'case' + // if and case both get converted to case in SQL + $op->instanceOf(DynaFunction) && + (cast($op, @DynaFunction).name->in(['case', 'if'])) && cast($op, @DynaFunction).parameters->slice(1,3)->filter(x| $x->isTrueFalseString())->isNotEmpty() } @@ -437,14 +560,17 @@ function <> meta::relational::functions::sqlQueryToString::h2::v op: RelationalOperationElement[1] ): Boolean[1] { - $op->instanceOf(Literal) && cast($op, @Literal).value->in(['false','true']) + $op->instanceOf(Literal) && cast($op, @Literal).value->match([ + s: String[1] | $s->toLower()->in(['false','true']), + o: Any[1] | false + ]) } function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::atRecursibleOperation( op: DynaFunction[1] ): Boolean[1] { - $op.name->in(['and', 'or', 'not', 'group']) + $op.name->in(['and', 'or', 'not', 'group', 'if']) } function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::isBooleanExpr(op: RelationalOperationElement[1]): Boolean[1] @@ -500,6 +626,99 @@ function <> meta::relational::functions::sqlQueryToString::h2::v } +/* Test: + "root".RG_FUNCTION_ID = 2 + and ((case when "root".MEMBERSHIP_SOURCE = 'CUSTOM' then 'true' else 'false' end = true and + case when "root".IS_CATCH_ALL_GROUP = 1 then 'true' else 'false' end = false) and "root".STATUS = 'A') + and "root".IN_Z <= DATE '8888-01-01' + and "root".OUT_Z > DATE '8888-01-01' +*/ + +function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::testSomeAST_thenIsWrapped(): Boolean[1] +{ + let inner = ^DynaFunction(name='group', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='group', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='equal', parameters=[ + ^DynaFunction(name='if', parameters=[ + ^DynaFunction(name='equal', parameters=[^Literal(value='CUSTOM'), ^Literal(value='CUSTOM')]), + ^Literal(value='true'), + ^Literal(value='false') + ]), + ^Literal(value=true) + ]), + ^DynaFunction(name='equal', parameters=[ + ^DynaFunction(name='if', parameters=[ + ^DynaFunction(name='equal', parameters=[^Literal(value=1), ^Literal(value=2)]), + ^Literal(value='true'), + ^Literal(value='false') + ]), + ^Literal(value=false) + ]) + ]) + ]), + ^DynaFunction(name='equal', parameters=[^Literal(value='A'), ^Literal(value='A')]) + ]) + ]); + + let op = ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='equal', parameters=[^Literal(value=2), ^Literal(value=2)]), + $inner + ]), + ^DynaFunction(name='lessThanEqual', parameters=[^Literal(value='8888-01-01'), ^Literal(value='8888-01-01')]) + ]), + ^DynaFunction(name='greaterThan', parameters=[^Literal(value='8888-01-02'), ^Literal(value='8888-01-01')]) + ]); + + let castedInner = ^DynaFunction(name='group', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='group', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='equal', parameters=[ + ^DynaFunction(name='castBoolean', parameters=[ + ^DynaFunction(name='if', parameters=[ + ^DynaFunction(name='equal', parameters=[^Literal(value='CUSTOM'), ^Literal(value='CUSTOM')]), + ^Literal(value='true'), + ^Literal(value='false') + ]) + ]), + ^DynaFunction(name='castBoolean', parameters=[^Literal(value=true)]) + ]), + ^DynaFunction(name='equal', parameters=[ + ^DynaFunction(name='castBoolean', parameters=[ + ^DynaFunction(name='if', parameters=[ + ^DynaFunction(name='equal', parameters=[^Literal(value=1), ^Literal(value=2)]), + ^Literal(value='true'), + ^Literal(value='false') + ]) + ]), + ^DynaFunction(name='castBoolean', parameters=[^Literal(value=false)]) + ]) + ]) + ]), + ^DynaFunction(name='equal', parameters=[^Literal(value='A'), ^Literal(value='A')]) + ]) + ]); + + let expected = ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='and', parameters=[ + ^DynaFunction(name='equal', parameters=[^Literal(value=2), ^Literal(value=2)]), + $castedInner + ]), + ^DynaFunction(name='lessThanEqual', parameters=[^Literal(value='8888-01-01'), ^Literal(value='8888-01-01')]) + ]), + ^DynaFunction(name='greaterThan', parameters=[^Literal(value='8888-01-02'), ^Literal(value='8888-01-01')]) + ]); + + let wrappedOp = wrapH2Boolean($op, []); + print($wrappedOp); + assertEquals($expected, $wrappedOp); +} + function <> meta::relational::functions::sqlQueryToString::h2::v2_1_214::testWhenJustCase_thenIsWrapped(): Boolean[1] { let op = ^DynaFunction( diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testGroupBy.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testGroupBy.pure index 2708c52fda4..6d27c153a1b 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testGroupBy.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testGroupBy.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::mapping::*; import meta::relational::runtime::*; import meta::relational::validation::*; @@ -291,7 +292,11 @@ function <> meta::relational::tests::tds::groupBy::GroupByWithIfInMap assertEquals(['Firm C', 176.0], $tds.rows->at(1).values); assertEquals(['Firm A', 66.0], $tds.rows->at(2).values); assertEquals([^TDSNull(), 5.0], $tds.rows->at(3).values); - assertEquals('select "producttable_0".NAME as "prodName", sum(case when "root".quantity > 2.0 then "root".quantity else ((1.0 * "root".quantity) / 2) end) as "sum" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "producttable_0".NAME as "prodName", sum(case when "root".quantity > 2.0 then "root".quantity else ((1.0 * "root".quantity) / 2) end) as "sum" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', + 'select "producttable_0".NAME as "prodName", sum(case when "root".quantity > CAST(2.0 AS FLOAT) then "root".quantity else ((1.0 * "root".quantity) / 2) end) as "sum" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::tds::groupBy::simpleGroupByWithJoinStrings():Boolean[1] @@ -426,7 +431,7 @@ function <> meta::relational::tests::tds::groupBy::te ->groupBy('prodName', [agg('p1', x|$x.getFloat('quantity')+2, y|$y->percentile(0.9)->toOne()), agg('p2', x|$x.getFloat('quantity')+2, y|$y->percentile(0.5, false, false)->toOne()), agg('p3', x|$x.getFloat('quantity')+2, y|$y->percentile(0.75, true, true)->toOne())]) ->sort(desc('prodName')), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['Firm X|292.5|322.0|248.25', 'Firm C|46.6|40.0|46.0', 'Firm A|32.2|25.0|29.5', 'TDSNull|7.0|7.0|7.0'], $result.values.rows->map(r|$r.values->makeString('|'))); - meta::relational::functions::asserts::assertSameSQL('select "producttable_0".NAME as "prodName", percentile_cont(0.9) within group (order by ("root".quantity + 2) asc) as "p1", percentile_disc(0.5) within group (order by ("root".quantity + 2) desc) as "p2", percentile_cont(0.75) within group (order by ("root".quantity + 2) asc) as "p3" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', $result); + meta::relational::functions::asserts::assertSameSQL('select "producttable_0".NAME as "prodName", percentile_cont(CAST(0.9 AS FLOAT)) within group (order by ("root".quantity + 2) asc) as "p1", percentile_disc(CAST(0.5 AS FLOAT)) within group (order by ("root".quantity + 2) desc) as "p2", percentile_cont(CAST(0.75 AS FLOAT)) within group (order by ("root".quantity + 2) asc) as "p3" from tradeTable as "root" left outer join productSchema.productTable as "producttable_0" on ("root".prodId = "producttable_0".ID) group by "prodName" order by "prodName" desc', $result); } function <> meta::relational::tests::tds::groupBy::testTDSGroupByIsDistinct():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSExtend.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSExtend.pure index ddce7a88769..f64adfa0864 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSExtend.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSExtend.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::model::simple::*; import meta::pure::executionPlan::toString::*; import meta::pure::executionPlan::*; @@ -207,8 +208,11 @@ function <> meta::relational::tests::tds::tdsExtend::testDateLiteral( assertEquals('Peter|2016-08-10,John|2016-08-10,John|2016-08-10,Anthony|2016-08-10,Fabrice|2016-08-10,Oliver|2016-08-10,David|2016-08-10', $tds.rows->map(r|$r.values->makeString('|'))->makeString(',')); - assertEquals('select "root".FIRSTNAME as "firstName", \'2016-08-10\' as "dateLiteral" from personTable as "root"', - $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".FIRSTNAME as "firstName", \'2016-08-10\' as "dateLiteral" from personTable as "root"', + 'select "root".FIRSTNAME as "firstName", DATE\'2016-08-10\' as "dateLiteral" from personTable as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::tds::tdsExtend::testNoopFunctions():Boolean[1] @@ -444,5 +448,5 @@ function <> meta::relational::tests::tds::tdsExtend::testExtendsWithI simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions(), noDebug()); - assertEquals('select "root".FIRSTNAME as "firstName", "root".AGE as "age", \'2021-01-01\' as "dt", ("root".AGE is not null and "root".AGE > 50) as "ageGreaterThan50", "root".FIRSTNAME in (\'Peter\') as "stringExtends1", "root".FIRSTNAME in (\'Peter\', \'John\') as "stringExtends2", "root".AGE in (22, 23) as "numberExtends", \'2021-01-01\' in (\'2021-01-01\', \'2021-01-02\') as "dateExtends", ("root".AGE is not null and "root".AGE > 50) in (true, false) as "booleanExtends" from personTable as "root"', $result->sqlRemoveFormatting()); + assertEquals('select "root".FIRSTNAME as "firstName", "root".AGE as "age", DATE\'2021-01-01\' as "dt", ("root".AGE is not null and "root".AGE > 50) as "ageGreaterThan50", "root".FIRSTNAME in (\'Peter\') as "stringExtends1", "root".FIRSTNAME in (\'Peter\', \'John\') as "stringExtends2", "root".AGE in (22, 23) as "numberExtends", DATE\'2021-01-01\' in (DATE\'2021-01-01\', DATE\'2021-01-02\') as "dateExtends", ("root".AGE is not null and "root".AGE > 50) in (true, false) as "booleanExtends" from personTable as "root"', $result->sqlRemoveFormatting()); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSProject.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSProject.pure index bc3edd102ee..e6b4c32e21a 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSProject.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSProject.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::csv::*; import meta::relational::tests::model::simple::*; import meta::relational::mapping::*; @@ -207,8 +208,11 @@ function <> meta::relational::tests::tds::tdsProject::testDateLiteral assertEquals('Peter|2016-08-10,John|2016-08-10,John|2016-08-10,Anthony|2016-08-10,Fabrice|2016-08-10,Oliver|2016-08-10,David|2016-08-10', $tds.rows->map(r|$r.values->makeString('|'))->makeString(',')); - assertEquals('select "root".FIRSTNAME as "firstName", \'2016-08-10\' as "dateLiteral" from personTable as "root"', - $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".FIRSTNAME as "firstName", \'2016-08-10\' as "dateLiteral" from personTable as "root"', + 'select "root".FIRSTNAME as "firstName", DATE\'2016-08-10\' as "dateLiteral" from personTable as "root"', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 10. Tricky usage of variables @@ -294,8 +298,11 @@ function <> meta::relational::tests::tds::tdsProject::testHourFunctio assertEquals('Peter|8,John|8,John|8,Anthony|8,Fabrice|8,Oliver|8,David|8', $tds.rows->map(r|$r.values->makeString('|'))->makeString(',')); - assertEquals('select "root".FIRSTNAME as "firstName", hour(\'2016-08-10 08:55:00.0\') as "hour" from personTable as "root"', - $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".FIRSTNAME as "firstName", hour(\'2016-08-10 08:55:00.0\') as "hour" from personTable as "root"', + 'select "root".FIRSTNAME as "firstName", hour(TIMESTAMP\'2016-08-10 08:55:00.0\') as "hour" from personTable as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::tds::tdsProject::testProjectEnumFromOpenVariable():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSWindowColumn.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSWindowColumn.pure index c41e82f9a8e..8bee604814c 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSWindowColumn.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tds/tests/testTDSWindowColumn.pure @@ -30,7 +30,7 @@ meta::relational::tests::tds::tdsWindow::testPercentileWindowFunction():Boolean[ simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions() ); assertSize($result1.values.rows, 7); - meta::relational::functions::asserts::assertSameSQL('select "root".FIRSTNAME as "firstName", "root".LASTNAME as "lastName", "root".AGE as "age", percentile_cont(0.9) within group (order by "root".AGE asc) OVER (Partition By "root".FIRSTNAME ) as "testCol1" from personTable as "root"', $result1); + meta::relational::functions::asserts::assertSameSQL('select "root".FIRSTNAME as "firstName", "root".LASTNAME as "lastName", "root".AGE as "age", percentile_cont(CAST(0.9 AS FLOAT)) within group (order by "root".AGE asc) OVER (Partition By "root".FIRSTNAME ) as "testCol1" from personTable as "root"', $result1); assertSameElements(['Anthony|Allen|22|22.0', 'David|Harris|35|35.0', 'Fabrice|Roberts|34|34.0', 'John|Hill|12|21.0', 'John|Johnson|22|21.0', 'Oliver|Hill|32|32.0', 'Peter|Smith|23|23.0'], $result1.values.rows->map(r|$r.values->makeString('|'))); let result2 = execute( @@ -42,7 +42,7 @@ meta::relational::tests::tds::tdsWindow::testPercentileWindowFunction():Boolean[ simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions() ); assertSize($result2.values.rows, 7); - meta::relational::functions::asserts::assertSameSQL('select "root".FIRSTNAME as "firstName", "root".LASTNAME as "lastName", "root".AGE as "age", percentile_cont(0.9) within group (order by "root".AGE desc) OVER (Partition By "root".FIRSTNAME ) as "testCol1" from personTable as "root"', $result2); + meta::relational::functions::asserts::assertSameSQL('select "root".FIRSTNAME as "firstName", "root".LASTNAME as "lastName", "root".AGE as "age", percentile_cont(CAST(0.9 AS FLOAT)) within group (order by "root".AGE desc) OVER (Partition By "root".FIRSTNAME ) as "testCol1" from personTable as "root"', $result2); assertSameElements(['Anthony|Allen|22|22.0', 'David|Harris|35|35.0', 'Fabrice|Roberts|34|34.0', 'John|Hill|12|13.0', 'John|Johnson|22|13.0', 'Oliver|Hill|32|32.0', 'Peter|Smith|23|23.0'], $result2.values.rows->map(r|$r.values->makeString('|'))); @@ -55,6 +55,6 @@ meta::relational::tests::tds::tdsWindow::testPercentileWindowFunction():Boolean[ simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions() ); assertSize($result3.values.rows, 7); - meta::relational::functions::asserts::assertSameSQL('select "root".FIRSTNAME as "firstName", "root".LASTNAME as "lastName", "root".AGE as "age", percentile_disc(0.9) within group (order by "root".AGE desc) OVER (Partition By "root".FIRSTNAME ) as "testCol1" from personTable as "root"', $result3); + meta::relational::functions::asserts::assertSameSQL('select "root".FIRSTNAME as "firstName", "root".LASTNAME as "lastName", "root".AGE as "age", percentile_disc(CAST(0.9 AS FLOAT)) within group (order by "root".AGE desc) OVER (Partition By "root".FIRSTNAME ) as "testCol1" from personTable as "root"', $result3); assertSameElements(['Anthony|Allen|22|22.0', 'David|Harris|35|35.0', 'Fabrice|Roberts|34|34.0', 'John|Hill|12|12.0', 'John|Johnson|22|12.0', 'Oliver|Hill|32|32.0', 'Peter|Smith|23|23.0'], $result3.values.rows->map(r|$r.values->makeString('|'))); } \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/testDataGeneration/tests/testDataGeneration.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/testDataGeneration/tests/testDataGeneration.pure index 78272353768..78d228977b0 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/testDataGeneration/tests/testDataGeneration.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/testDataGeneration/tests/testDataGeneration.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::metamodel::execute::*; import meta::pure::functions::lang::tests::cast::*; import meta::relational::metamodel::join::*; @@ -319,11 +320,19 @@ function <> meta::relational::testDataGeneratio let testData = generateTestData($query, $mapping, $runtime, $tableRowIdentifiers, meta::relational::extension::relationalExtensions())->toOne(); assertSize($testData.sqls, 3); - assertSqlEquals('\n' + - 'select top 20 \n' + - ' "root".ID, "root".prodId \n' + - 'from tradeTable as "root" \n' + - 'where "root".tradeDate = \'2014-12-04\' or "root".prodId = 2', $testData.sqls->at(0)); + assertEqualsH2Compatible( + sqlRemoveFormatting('\n' + + 'select top 20 \n' + + ' "root".ID, "root".prodId \n' + + 'from tradeTable as "root" \n' + + 'where "root".tradeDate = \'2014-12-04\' or "root".prodId = 2'), + sqlRemoveFormatting('\n' + + 'select top 20 \n' + + ' "root".ID, "root".prodId \n' + + 'from tradeTable as "root" \n' + + 'where "root".tradeDate = DATE\'2014-12-04\' or "root".prodId = 2'), + $testData.sqls->at(0)->sqlRemoveFormatting() + ); assertSqlEquals('\n' + 'select top 20 \n' + ' "producttable_0".ID, "producttable_0".NAME \n' + @@ -1814,6 +1823,7 @@ function <> meta::relational::testDataGeneration::tests::loadAnd /*** Execution Plan + Alloy Tests ***/ ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::executionPlan::profiles::*; import meta::relational::metamodel::join::*; import meta::relational::functions::database::*; @@ -2558,7 +2568,7 @@ function <> meta::relational::testDataGeneratio ]; let milestoningDates = createTemporalMilestoningDates(%9999-12-30, [], []); let plan = meta::relational::testDataGeneration::executionPlan::planTestDataGeneration($query, $mapping, $runtime, ^ExecutionContext(), $tableRowIdentifiers, false, $milestoningDates, meta::relational::extension::relationalExtensions()); - assertEquals( + assertEqualsH2Compatible( 'MultiResultSequence\n' + '(\n' + ' type = meta::pure::metamodel::type::Any\n' + @@ -2598,7 +2608,49 @@ function <> meta::relational::testDataGeneratio ' )\n' + ' )\n' + ' )\n' + - ')\n', $plan->meta::pure::executionPlan::toString::planToString(meta::relational::extension::relationalExtensions())); + ')\n', + 'MultiResultSequence\n' + + '(\n' + + ' type = meta::pure::metamodel::type::Any\n' + + ' (\n' + + ' Allocation\n' + + ' (\n' + + ' type = Relation[name=ProductTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("from_z",DATE), ("id",INT), ("name",VARCHAR(200)), ("thru_z",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' name = res_c0\n' + + ' value = \n' + + ' (\n' + + ' Relational\n' + + ' (\n' + + ' type = Relation[name=ProductTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("from_z",DATE), ("id",INT), ("name",VARCHAR(200)), ("thru_z",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' resultColumns = [("from_z", DATE), ("id", INT), ("name", VARCHAR(200)), ("thru_z", DATE), ("type", VARCHAR(200))]\n' + + ' sql = select top 20 "root".from_z as "from_z", "root".id as "id", "root".name as "name", "root".thru_z as "thru_z", "root".type as "type" from ProductTable as "root" where "root".from_z <= DATE\'9999-12-30\' and "root".thru_z > DATE\'9999-12-30\' and ("root".id = 3 or "root".id = 2)\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Allocation\n' + + ' (\n' + + ' type = Relation[name=ProductClassificationTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("from_z",DATE), ("thru_z",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' name = res_c0_c0\n' + + ' value = \n' + + ' (\n' + + ' Relational\n' + + ' (\n' + + ' type = Relation[name=ProductClassificationTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("from_z",DATE), ("thru_z",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' resultColumns = [("from_z", DATE), ("thru_z", DATE), ("type", VARCHAR(200))]\n' + + ' sql = select top 20 "productclassificationtable_0".from_z as "from_z", "productclassificationtable_0".thru_z as "thru_z", "productclassificationtable_0".type as "type" from (select * from (${res_c0}) as "root") as "root" inner join ProductClassificationTable as "productclassificationtable_0" on ("root"."type" = "productclassificationtable_0".type) where "productclassificationtable_0".from_z <= DATE\'9999-12-30\' and "productclassificationtable_0".thru_z > DATE\'9999-12-30\'\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ')\n', + $plan->meta::pure::executionPlan::toString::planToString(meta::relational::extension::relationalExtensions()) + ); } function <> meta::relational::testDataGeneration::tests::alloy::testDataGenerationWithBiTemporalMilestoning_WithMilestoningDates_Alloy():Boolean[1] @@ -2616,7 +2668,7 @@ function <> meta::relational::testDataGeneratio ]; let milestoningDates = createTemporalMilestoningDates(%9999-12-01, %9999-12-30, []); let plan = meta::relational::testDataGeneration::executionPlan::planTestDataGeneration($query, $mapping, $runtime, ^ExecutionContext(), $tableRowIdentifiers, false, $milestoningDates, meta::relational::extension::relationalExtensions()); - assertEquals( + assertEqualsH2Compatible( 'MultiResultSequence\n' + '(\n' + ' type = meta::pure::metamodel::type::Any\n' + @@ -2656,7 +2708,49 @@ function <> meta::relational::testDataGeneratio ' )\n' + ' )\n' + ' )\n' + - ')\n', $plan->meta::pure::executionPlan::toString::planToString(meta::relational::extension::relationalExtensions())); + ')\n', + 'MultiResultSequence\n' + + '(\n' + + ' type = meta::pure::metamodel::type::Any\n' + + ' (\n' + + ' Allocation\n' + + ' (\n' + + ' type = Relation[name=TraderTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("in_z",DATE), ("kerberos",VARCHAR(20)), ("out_z",DATE)]]\n' + + ' resultSizeRange = *\n' + + ' name = res_c0\n' + + ' value = \n' + + ' (\n' + + ' Relational\n' + + ' (\n' + + ' type = Relation[name=TraderTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("in_z",DATE), ("kerberos",VARCHAR(20)), ("out_z",DATE)]]\n' + + ' resultSizeRange = *\n' + + ' resultColumns = [("in_z", DATE), ("kerberos", VARCHAR(20)), ("out_z", DATE)]\n' + + ' sql = select top 20 "root".in_z as "in_z", "root".kerberos as "kerberos", "root".out_z as "out_z" from TraderTable as "root" where "root".in_z <= DATE\'9999-12-30\' and "root".out_z > DATE\'9999-12-30\' and "root".kerberos = \'ggekko\'\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Allocation\n' + + ' (\n' + + ' type = Relation[name=BiTemporalLocationTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("ID",INT), ("PLACE",VARCHAR(200)), ("from_z",DATE), ("in_z",DATE), ("kerberos",VARCHAR(20)), ("out_z",DATE), ("thru_z",DATE)]]\n' + + ' resultSizeRange = *\n' + + ' name = res_c0_c0\n' + + ' value = \n' + + ' (\n' + + ' Relational\n' + + ' (\n' + + ' type = Relation[name=BiTemporalLocationTable, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("ID",INT), ("PLACE",VARCHAR(200)), ("from_z",DATE), ("in_z",DATE), ("kerberos",VARCHAR(20)), ("out_z",DATE), ("thru_z",DATE)]]\n' + + ' resultSizeRange = *\n' + + ' resultColumns = [("ID", INT), ("PLACE", VARCHAR(200)), ("from_z", DATE), ("in_z", DATE), ("kerberos", VARCHAR(20)), ("out_z", DATE), ("thru_z", DATE)]\n' + + ' sql = select top 20 "bitemporallocationtable_0".ID as "ID", "bitemporallocationtable_0".PLACE as "PLACE", "bitemporallocationtable_0".from_z as "from_z", "bitemporallocationtable_0".in_z as "in_z", "bitemporallocationtable_0".kerberos as "kerberos", "bitemporallocationtable_0".out_z as "out_z", "bitemporallocationtable_0".thru_z as "thru_z" from (select * from (${res_c0}) as "root") as "root" inner join BiTemporalLocationTable as "bitemporallocationtable_0" on ("root"."kerberos" = "bitemporallocationtable_0".kerberos) where "bitemporallocationtable_0".in_z <= DATE\'9999-12-30\' and "bitemporallocationtable_0".out_z > DATE\'9999-12-30\' and "bitemporallocationtable_0".from_z <= DATE\'9999-12-01\' and "bitemporallocationtable_0".thru_z > DATE\'9999-12-01\'\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ')\n', + $plan->meta::pure::executionPlan::toString::planToString(meta::relational::extension::relationalExtensions()) + ); } function <> meta::relational::testDataGeneration::tests::alloy::testDataGenerationWithSnapshotMilestoning_WithMilestoningDates_Alloy():Boolean[1] @@ -2675,7 +2769,7 @@ function <> meta::relational::testDataGeneratio ]; let milestoningDates = createTemporalMilestoningDates([], [], %2015-8-26); let plan = meta::relational::testDataGeneration::executionPlan::planTestDataGeneration($query, $mapping, $runtime, ^ExecutionContext(), $tableRowIdentifiers, false, $milestoningDates, meta::relational::extension::relationalExtensions()); - assertEquals( + assertEqualsH2Compatible( 'MultiResultSequence\n' + '(\n' + ' type = meta::pure::metamodel::type::Any\n' + @@ -2715,7 +2809,49 @@ function <> meta::relational::testDataGeneratio ' )\n' + ' )\n' + ' )\n' + - ')\n', $plan->meta::pure::executionPlan::toString::planToString(meta::relational::extension::relationalExtensions())); + ')\n', + 'MultiResultSequence\n' + + '(\n' + + ' type = meta::pure::metamodel::type::Any\n' + + ' (\n' + + ' Allocation\n' + + ' (\n' + + ' type = Relation[name=ProductTableWithBusinessSnapshotMilestoning, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("id",INT), ("name",VARCHAR(200)), ("snapshotDate",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' name = res_c0\n' + + ' value = \n' + + ' (\n' + + ' Relational\n' + + ' (\n' + + ' type = Relation[name=ProductTableWithBusinessSnapshotMilestoning, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("id",INT), ("name",VARCHAR(200)), ("snapshotDate",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' resultColumns = [("id", INT), ("name", VARCHAR(200)), ("snapshotDate", DATE), ("type", VARCHAR(200))]\n' + + ' sql = select top 20 "root".id as "id", "root".name as "name", "root".snapshotDate as "snapshotDate", "root".type as "type" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2015-08-26\' and ("root".id = \'3\' or "root".id = \'2\')\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' Allocation\n' + + ' (\n' + + ' type = Relation[name=ProductClassificationTableWithBusinessSnapshotMilestoning, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("snapshotDate",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' name = res_c0_c0\n' + + ' value = \n' + + ' (\n' + + ' Relational\n' + + ' (\n' + + ' type = Relation[name=ProductClassificationTableWithBusinessSnapshotMilestoning, type=TABLE, schema=default, database=meta::relational::tests::milestoning::db, columns=[("snapshotDate",DATE), ("type",VARCHAR(200))]]\n' + + ' resultSizeRange = *\n' + + ' resultColumns = [("snapshotDate", DATE), ("type", VARCHAR(200))]\n' + + ' sql = select top 20 "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate as "snapshotDate", "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "type" from (select * from (${res_c0}) as "root") as "root" inner join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root"."type" = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2015-08-26\'\n' + + ' connection = TestDatabaseConnection(type = "H2")\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ' )\n' + + ')\n', + $plan->meta::pure::executionPlan::toString::planToString(meta::relational::extension::relationalExtensions()) + ); } function <> {serverVersion.start='V1_5_0'} meta::relational::testDataGeneration::tests::alloy::testTableToTDSSimple():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testContractMoneyScenario.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testContractMoneyScenario.pure index d6e8b104d63..18a2fe0f01c 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testContractMoneyScenario.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testContractMoneyScenario.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::model::simple::*; import meta::relational::tests::advanced::contractmoneyscenario::*; import meta::relational::runtime::*; @@ -41,7 +42,11 @@ function <> meta::relational::tests::advanced::contractmoneyscenario: ] ), ContractMoney, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".id as "id", "root".price as "amount", "fx_0".rate as "rate", case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end as "value" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1))', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id", "root".price as "amount", "fx_0".rate as "rate", case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end as "value" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1))', + 'select "root".id as "id", "root".price as "amount", "fx_0".rate as "rate", case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end as "value" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = DATE\'2003-10-10\' and "fx_0".tenor = 1))', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::advanced::contractmoneyscenario::test2():Boolean[1] @@ -61,7 +66,11 @@ function <> meta::relational::tests::advanced::contractmoneyscenario: ] ), ContractMoney, testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root".id as "id", "root".price as "amount", "fx_0".rate as "rate", case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end as "value" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1))', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "id", "root".price as "amount", "fx_0".rate as "rate", case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end as "value" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = \'2003-10-10\' and "fx_0".tenor = 1))', + 'select "root".id as "id", "root".price as "amount", "fx_0".rate as "rate", case when "currency_0".value = \'USD\' then "root".price else ("root".price * "fx_0".rate) end as "value" from Contract as "root" left outer join Currency as "currency_0" on ("root".id = "currency_0".contractId) left outer join FX as "fx_0" on ("root".currency = "fx_0".currency and ("fx_0".date = DATE\'2003-10-10\' and "fx_0".tenor = 1))', + $result->sqlRemoveFormatting() + ); } function meta::relational::tests::advanced::contractmoneyscenario::createDatabase():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testForcedMilestoning.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testForcedMilestoning.pure index d2acfda81c7..b4e158e9b74 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testForcedMilestoning.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/advanced/testForcedMilestoning.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::pure::runtime::*; import meta::relational::mapping::*; @@ -25,13 +26,21 @@ import meta::pure::mapping::*; function <> meta::relational::tests::advanced::forced::milestoning::testMilestoningQueryWithSimpleProjectWithMilestoneFilterForcedCorrelated():Boolean[1] { let result = meta::relational::tests::advanced::forced::milestoning::testMilestoningQueryWithSimpleProjectWithMilestoneFilter(IsolationStrategy.BuildCorrelatedSubQuery); - assertEquals('select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2015-10-17\' and "productexchangetable_1".thru_z > \'2015-10-17\') as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name) left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= \'2015-10-17\' and "productexchangetable_1".thru_z > \'2015-10-17\') as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name) left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= \'2015-10-16\' and "productclassificationtable_1".thru_z > \'2015-10-16\') as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join (select "productexchangetable_1".name as name from ProductExchangeTable as "productexchangetable_1" where "productexchangetable_1".from_z <= DATE\'2015-10-17\' and "productexchangetable_1".thru_z > DATE\'2015-10-17\') as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name) left outer join (select "productclassificationtable_1".type as type, "productclassificationtable_1".type_description as type_description from ProductClassificationTable as "productclassificationtable_1" where "productclassificationtable_1".from_z <= DATE\'2015-10-16\' and "productclassificationtable_1".thru_z > DATE\'2015-10-16\') as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type) where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::advanced::forced::milestoning::testMilestoningQueryWithSimpleProjectWithMilestoneFilterForcedOnClause():Boolean[1] { let result = meta::relational::tests::advanced::forced::milestoning::testMilestoningQueryWithSimpleProjectWithMilestoneFilter(IsolationStrategy.MoveFilterInOnClause); - assertEquals('select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-17\' and "productexchangetable_0".thru_z > \'2015-10-17\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\'', + 'select "root".name as "name", "productclassificationtable_0".type_description as "classificationDescription" from ProductTable as "root" left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-17\' and "productexchangetable_0".thru_z > DATE\'2015-10-17\') left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\') and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\'', + $result->sqlRemoveFormatting() + ); } function meta::relational::tests::advanced::forced::milestoning::testMilestoningQueryWithSimpleProjectWithMilestoneFilter(isolation:IsolationStrategy[1]):Result[1] @@ -49,13 +58,21 @@ function meta::relational::tests::advanced::forced::milestoning::testMilestoning function <> meta::relational::tests::advanced::forced::milestoning::testNonMilestoningQueryWithMilestoneFilterProjectForcedCorrelated():Boolean[1] { let result = meta::relational::tests::advanced::forced::milestoning::testNonMilestoningQueryWithMilestoneFilterProject(IsolationStrategy.BuildCorrelatedSubQuery); - assertSameSQL('select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from (select "producttable_1".id as id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\') as "producttable_1" where "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join (select "producttable_1".id as id, "producttable_1".name as name from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\') as "producttable_2" on ("root".prodFk = "producttable_2".id) where "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from (select "producttable_1".id as id from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\') as "producttable_1" where "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join (select "producttable_1".id as id, "producttable_1".name as name from ProductTable as "producttable_1" where "producttable_1".from_z <= \'2015-10-15\' and "producttable_1".thru_z > \'2015-10-15\') as "producttable_2" on ("root".prodFk = "producttable_2".id) where "producttable_0".id is not null', + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id from (select "producttable_1".id as id from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-10-15\' and "producttable_1".thru_z > DATE\'2015-10-15\') as "producttable_1" where "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id) left outer join (select "producttable_1".id as id, "producttable_1".name as name from ProductTable as "producttable_1" where "producttable_1".from_z <= DATE\'2015-10-15\' and "producttable_1".thru_z > DATE\'2015-10-15\') as "producttable_2" on ("root".prodFk = "producttable_2".id) where "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::advanced::forced::milestoning::testNonMilestoningQueryWithMilestoneFilterProjectForcedOnClause():Boolean[1] { let result = meta::relational::tests::advanced::forced::milestoning::testNonMilestoningQueryWithMilestoneFilterProject(IsolationStrategy.MoveFilterInOnClause); - assertSameSQL('select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id, "producttable_1".from_z, "producttable_1".thru_z from ProductTable as "producttable_1" where "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-15\' and "producttable_0".thru_z > \'2015-10-15\') left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= \'2015-10-15\' and "producttable_2".thru_z > \'2015-10-15\') where "producttable_0".thru_z is not null and "producttable_0".from_z is not null and "producttable_0".id is not null', $result); + assertEqualsH2Compatible( + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id, "producttable_1".from_z, "producttable_1".thru_z from ProductTable as "producttable_1" where "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= \'2015-10-15\' and "producttable_0".thru_z > \'2015-10-15\') left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= \'2015-10-15\' and "producttable_2".thru_z > \'2015-10-15\') where "producttable_0".thru_z is not null and "producttable_0".from_z is not null and "producttable_0".id is not null', + 'select "root".id as "orderId", "producttable_2".name as "productName" from OrderTable as "root" left outer join (select distinct "producttable_1".id, "producttable_1".from_z, "producttable_1".thru_z from ProductTable as "producttable_1" where "producttable_1".id = 2) as "producttable_0" on ("root".prodFk = "producttable_0".id and "producttable_0".from_z <= DATE\'2015-10-15\' and "producttable_0".thru_z > DATE\'2015-10-15\') left outer join ProductTable as "producttable_2" on ("root".prodFk = "producttable_2".id and "producttable_2".from_z <= DATE\'2015-10-15\' and "producttable_2".thru_z > DATE\'2015-10-15\') where "producttable_0".thru_z is not null and "producttable_0".from_z is not null and "producttable_0".id is not null', + $result->sqlRemoveFormatting() + ); } function meta::relational::tests::advanced::forced::milestoning::testNonMilestoningQueryWithMilestoneFilterProject(isolation:IsolationStrategy[1]):Result[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/classMappingFilterWithInnerJoin/testClassMappingFilterWithInnerJoin.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/classMappingFilterWithInnerJoin/testClassMappingFilterWithInnerJoin.pure index 1424381d13b..50c63b8c3d4 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/classMappingFilterWithInnerJoin/testClassMappingFilterWithInnerJoin.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/classMappingFilterWithInnerJoin/testClassMappingFilterWithInnerJoin.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::model::simple::*; import meta::relational::mapping::*; import meta::relational::tests::mapping::classMappingFilterWithInnerJoin::mapping::*; @@ -114,14 +115,22 @@ function <> meta::relational::tests::mapping::classMappingFilterWithI { let result = execute(|meta::relational::tests::milestoning::Product.all(%2015-10-26), milestoningmapWithInnerJoin, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['ProductName2'], $result.values.name); - assertEquals('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-26\' as "k_businessDate" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "root"', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-26\' as "k_businessDate" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "root"', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-26\' as "k_businessDate" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= DATE\'2015-10-26\' and "root".thru_z > DATE\'2015-10-26\') as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::classMappingFilterWithInnerJoin::testPropertyQueryWithInnerJoinClassMappingWithMilestoningTableFilter():Boolean[1] { let result = execute(|meta::relational::tests::milestoning::Product.all(%2015-10-26)->project([p|$p.name], ['name']), milestoningmapWithInnerJoin, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals(['ProductName2'], $result.values.rows.values); - assertEquals( 'select "root".name as "name" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "root"', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".name as "name" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "root"', + 'select "root".name as "name" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= DATE\'2015-10-26\' and "root".thru_z > DATE\'2015-10-26\') as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::classMappingFilterWithInnerJoin::testPropertyProjectionQueryWithInnerJoinClassMappingWithMilestoningTableFilter():Boolean[1] @@ -133,7 +142,11 @@ function <> meta::relational::tests::mapping::classMappingFilterWithI let products = $result.values; assertEquals(1, $products->size()); assertEquals('ProductName2', $products->at(0).name); - assertSameSQL('select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-16\' as "k_businessDate" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\') as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\')', $result); + assertEqualsH2Compatible( + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-16\' as "k_businessDate" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= \'2015-10-16\' and "root".thru_z > \'2015-10-16\') as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= \'2015-10-16\' and "productclassificationtable_0".thru_z > \'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= \'2015-10-16\' and "productexchangetable_0".thru_z > \'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\')', + 'select "root".id as "pk_0", "root".name as "pk_1", "root".id as "id", "root".name as "name", "root".type as "type", \'2015-10-16\' as "k_businessDate" from (select "root".id as id, "root".name as name, "root".type as type, "root".exchange as exchange, "root".classificationSystemId as classificationSystemId, "root".referenceSystemName as referenceSystemName, "root".externalReferenceSystemName as externalReferenceSystemName, "root".from_z as from_z, "root".thru_z as thru_z from ProductTable as "root" inner join OrderTable as "ordertable_0" on ("ordertable_0".prodFk = "root".id) where "ordertable_0".prodFk = \'2\' and "root".from_z <= DATE\'2015-10-16\' and "root".thru_z > DATE\'2015-10-16\') as "root" left outer join ProductClassificationTable as "productclassificationtable_0" on ("root".type = "productclassificationtable_0".type and "productclassificationtable_0".from_z <= DATE\'2015-10-16\' and "productclassificationtable_0".thru_z > DATE\'2015-10-16\') left outer join ProductExchangeTable as "productexchangetable_0" on ("root".exchange = "productexchangetable_0".name and "productexchangetable_0".from_z <= DATE\'2015-10-16\' and "productexchangetable_0".thru_z > DATE\'2015-10-16\') where ("productclassificationtable_0".type = \'STOCK\' and "productexchangetable_0".name = \'LNSE\')', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::classMappingFilterWithInnerJoin::testSubTypeProjectionQueryWithInnerJoinClassMappingTableFilter():Boolean[1] @@ -297,5 +310,9 @@ function <> meta::relational::tests::mapping::classMappingFilterWithI assertEquals('productName,productClassificationTypes,productClassificationDescriptions\n'+ 'ProductName2,STOCK,STOCK DESC-V4\n'+ 'ProductName3,,\n', $results.values->toCSV()); - assertEquals('select "root".name as "productName", "producttableview_0".type as "productClassificationTypes", "producttableview_0".type_description as "productClassificationDescriptions" from ProductTable as "root" left outer join (select "producttableview_1".id as id, "producttableview_1".name as name, "productclassificationtable_0".type as type, "productclassificationtable_0".type_description as type_description from (select "root".id as id, "root".name as name, "root".type as type, \'2015-10-26\' as "k_businessDate" from ProductTable as "root" where "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "producttableview_1" inner join (select "root".type as type, "root".type_description as type_description, "root".system as system, "root".exchange as exchange, "root".from_z as from_z, "root".thru_z as thru_z from ProductClassificationTable as "root" inner join ProductClassificationFilterTable as "productclassificationfiltertable_0" on ("root".type = "productclassificationfiltertable_0".type) where "productclassificationfiltertable_0".exchange is not null and "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "productclassificationtable_0" on ("producttableview_1".type = "productclassificationtable_0".type)) as "producttableview_0" on ("root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\' and "root".id = "producttableview_0".id and "root".name = "producttableview_0".name) where "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\'', $results->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".name as "productName", "producttableview_0".type as "productClassificationTypes", "producttableview_0".type_description as "productClassificationDescriptions" from ProductTable as "root" left outer join (select "producttableview_1".id as id, "producttableview_1".name as name, "productclassificationtable_0".type as type, "productclassificationtable_0".type_description as type_description from (select "root".id as id, "root".name as name, "root".type as type, \'2015-10-26\' as "k_businessDate" from ProductTable as "root" where "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "producttableview_1" inner join (select "root".type as type, "root".type_description as type_description, "root".system as system, "root".exchange as exchange, "root".from_z as from_z, "root".thru_z as thru_z from ProductClassificationTable as "root" inner join ProductClassificationFilterTable as "productclassificationfiltertable_0" on ("root".type = "productclassificationfiltertable_0".type) where "productclassificationfiltertable_0".exchange is not null and "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\') as "productclassificationtable_0" on ("producttableview_1".type = "productclassificationtable_0".type)) as "producttableview_0" on ("root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\' and "root".id = "producttableview_0".id and "root".name = "producttableview_0".name) where "root".from_z <= \'2015-10-26\' and "root".thru_z > \'2015-10-26\'', + 'select "root".name as "productName", "producttableview_0".type as "productClassificationTypes", "producttableview_0".type_description as "productClassificationDescriptions" from ProductTable as "root" left outer join (select "producttableview_1".id as id, "producttableview_1".name as name, "productclassificationtable_0".type as type, "productclassificationtable_0".type_description as type_description from (select "root".id as id, "root".name as name, "root".type as type, \'2015-10-26\' as "k_businessDate" from ProductTable as "root" where "root".from_z <= DATE\'2015-10-26\' and "root".thru_z > DATE\'2015-10-26\') as "producttableview_1" inner join (select "root".type as type, "root".type_description as type_description, "root".system as system, "root".exchange as exchange, "root".from_z as from_z, "root".thru_z as thru_z from ProductClassificationTable as "root" inner join ProductClassificationFilterTable as "productclassificationfiltertable_0" on ("root".type = "productclassificationfiltertable_0".type) where "productclassificationfiltertable_0".exchange is not null and "root".from_z <= DATE\'2015-10-26\' and "root".thru_z > DATE\'2015-10-26\') as "productclassificationtable_0" on ("producttableview_1".type = "productclassificationtable_0".type)) as "producttableview_0" on ("root".from_z <= DATE\'2015-10-26\' and "root".thru_z > DATE\'2015-10-26\' and "root".id = "producttableview_0".id and "root".name = "producttableview_0".name) where "root".from_z <= DATE\'2015-10-26\' and "root".thru_z > DATE\'2015-10-26\'', + $results->sqlRemoveFormatting() + ); } \ No newline at end of file diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedMapping.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedMapping.pure index e19766dc618..6aaa94c27d5 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedMapping.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedMapping.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::mapping::embedded::*; import meta::relational::functions::asserts::*; import meta::relational::runtime::*; @@ -131,7 +132,11 @@ function <> meta::relational::tests::mapping::embedded::testGroupByEm )->sort('Firm Name'), testMappingEmbedded, testDataTypeMappingRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('Firm Name,Count\n' + 'Firm A,0.0\n' + 'Firm X,1.0\n', $result.values->toOne()->toCSV()); - assertEquals('select "root".FIRM_LEGALNAME as "Firm Name", sum(case when ("root".PERSON_ADDRESS_NAME is not null and "root".PERSON_ADDRESS_NAME like \'1%\') then 1.0 else 0.0 end) as "Count" from PERSON_FIRM_DENORM as "root" group by "Firm Name" order by "Firm Name"', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".FIRM_LEGALNAME as "Firm Name", sum(case when ("root".PERSON_ADDRESS_NAME is not null and "root".PERSON_ADDRESS_NAME like \'1%\') then 1.0 else 0.0 end) as "Count" from PERSON_FIRM_DENORM as "root" group by "Firm Name" order by "Firm Name"', + 'select "root".FIRM_LEGALNAME as "Firm Name", sum(case when ("root".PERSON_ADDRESS_NAME is not null and "root".PERSON_ADDRESS_NAME like \'1%\') then CAST(1.0 AS FLOAT) else CAST(0.0 AS FLOAT) end) as "Count" from PERSON_FIRM_DENORM as "root" group by "Firm Name" order by "Firm Name"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::testProjectToEmbedded():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedOtherwiseMapping.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedOtherwiseMapping.pure index e32d4657e4b..438f497f8a0 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedOtherwiseMapping.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testEmbeddedOtherwiseMapping.pure @@ -13,6 +13,7 @@ // limitations under the License. ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; import meta::relational::tests::csv::*; @@ -94,8 +95,11 @@ function <> meta::relational::tests::mapping::embedded::advanced::oth ), testMappingEmbeddedOtherwise,testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('Bond Type,Profit\n' + '15 years,10.0\n' + '5 years,1.0\n', $result.values->toOne()->toCSV()); - assertSameSQL('select "bond_detail_0".TYPE as "Bond Type", sum(case when "root".MARKET_NAME = \'LSE\' then 5.0 else 1.0 end) as "Profit" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', $result); - + assertEqualsH2Compatible( + 'select "bond_detail_0".TYPE as "Bond Type", sum(case when "root".MARKET_NAME = \'LSE\' then 5.0 else 1.0 end) as "Profit" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', + 'select "bond_detail_0".TYPE as "Bond Type", sum(case when "root".MARKET_NAME = \'LSE\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "Profit" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::otherwiseTestGroupByComplexAgg():Boolean[1] @@ -108,8 +112,11 @@ function <> meta::relational::tests::mapping::embedded::advanced::oth ), testMappingEmbeddedOtherwise, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('Bond Type,sum\n' + '15 years,2.0\n' + '5 years,5.0\n', $result.values->toOne()->toCSV()); - assertSameSQL('select "bond_detail_0".TYPE as "Bond Type", sum(case when "bond_detail_0".TYPE like \'5%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', $result); - + assertEqualsH2Compatible( + 'select "bond_detail_0".TYPE as "Bond Type", sum(case when "bond_detail_0".TYPE like \'5%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', + 'select "bond_detail_0".TYPE as "Bond Type", sum(case when "bond_detail_0".TYPE like \'5%\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "sum" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::otherwiseTestGroupByComplexExpressionEmbeddedAndJoin():Boolean[1] @@ -122,7 +129,11 @@ function <> meta::relational::tests::mapping::embedded::advanced::oth ), testMappingEmbeddedOtherwise, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('Bond Type,sum\n' + 'Bond 1,1.0\n' + 'Bond 2,1.0\n'+ 'SuperBond 3 super,5.0\n', $result.values->toOne()->toCSV()); - assertSameSQL( 'select "root".BOND_DETAILS as "Bond Type", sum(case when "bond_detail_0".TYPE like \'5%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', $result); + assertEqualsH2Compatible( + 'select "root".BOND_DETAILS as "Bond Type", sum(case when "bond_detail_0".TYPE like \'5%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', + 'select "root".BOND_DETAILS as "Bond Type", sum(case when "bond_detail_0".TYPE like \'5%\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "sum" from PRODUCT_DENORM as "root" left outer join BOND_DETAIL as "bond_detail_0" on ("root".PRODUCT_ID = "bond_detail_0".BOND_ID) group by "Bond Type"', + $result->sqlRemoveFormatting() + ); } diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedMapping.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedMapping.pure index 93270702420..dcd303368f5 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedMapping.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedMapping.pure @@ -14,6 +14,7 @@ ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::runtime::*; import meta::relational::runtime::*; import meta::relational::metamodel::execute::*; @@ -78,8 +79,11 @@ function meta::relational::tests::mapping::embedded::advanced::testRuntime():Ru ), testMappingEmbedded,testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('Bond Type,Profit\n' + '5 years,10.0\n' + '7 weeks,1.0\n', $result.values->toOne()->toCSV()); - assertEquals( 'select "root".BOND_TYPE as "Bond Type", sum(case when "root".MARKET_NAME = \'LSE\' then 5.0 else 1.0 end) as "Profit" from PRODUCT_DENORM as "root" group by "Bond Type"', $result->sqlRemoveFormatting()); - + assertEqualsH2Compatible( + 'select "root".BOND_TYPE as "Bond Type", sum(case when "root".MARKET_NAME = \'LSE\' then 5.0 else 1.0 end) as "Profit" from PRODUCT_DENORM as "root" group by "Bond Type"', + 'select "root".BOND_TYPE as "Bond Type", sum(case when "root".MARKET_NAME = \'LSE\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "Profit" from PRODUCT_DENORM as "root" group by "Bond Type"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::testGroupByComplexAgg():Boolean[1] @@ -92,8 +96,11 @@ function meta::relational::tests::mapping::embedded::advanced::testRuntime():Ru ), testMappingEmbedded, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('Bond Type,sum\n' + '5 years,10.0\n' + '7 weeks,1.0\n', $result.values->toOne()->toCSV()); - assertEquals( 'select "root".BOND_TYPE as "Bond Type", sum(case when "root".BOND_TYPE like \'5%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" group by "Bond Type"', $result->sqlRemoveFormatting()); - + assertEqualsH2Compatible( + 'select "root".BOND_TYPE as "Bond Type", sum(case when "root".BOND_TYPE like \'5%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" group by "Bond Type"', + 'select "root".BOND_TYPE as "Bond Type", sum(case when "root".BOND_TYPE like \'5%\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "sum" from PRODUCT_DENORM as "root" group by "Bond Type"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::testQualifierProperty():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedNested.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedNested.pure index 766813119f6..036d45fdcb6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedNested.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedNested.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::graphFetch::execution::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; @@ -75,8 +76,11 @@ function <> meta::relational::tests::mapping::embedded::advanced::inl ), testMappingEmbeddedTargetIds,testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('c1,c2\n' + 'addressh1,10.0\n' + 'addressh3,1.0\n', $result.values->toOne()->toCSV()); - assertSameSQL( 'select "root".HOLDER_ADDRESS_NAME as "c1", sum(case when "root".BOND_TYPE = \'5 years\' then 5.0 else 1.0 end) as "c2" from PRODUCT_DENORM as "root" group by "c1"', $result); - + assertEqualsH2Compatible( + 'select "root".HOLDER_ADDRESS_NAME as "c1", sum(case when "root".BOND_TYPE = \'5 years\' then 5.0 else 1.0 end) as "c2" from PRODUCT_DENORM as "root" group by "c1"', + 'select "root".HOLDER_ADDRESS_NAME as "c1", sum(case when "root".BOND_TYPE = \'5 years\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "c2" from PRODUCT_DENORM as "root" group by "c1"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::inline::nested::testGroupByComplexAgg():Boolean[1] @@ -89,8 +93,11 @@ function <> meta::relational::tests::mapping::embedded::advanced::inl ), testMappingEmbeddedTargetIds, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('c1,sum\n' + 'addressh1,10.0\n' + 'addressh3,1.0\n', $result.values->toOne()->toCSV()); - assertSameSQL( 'select "root".HOLDER_ADDRESS_NAME as "c1", sum(case when "root".HOLDER_ADDRESS_NAME like \'addressh1%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" group by "c1"', $result); - + assertEqualsH2Compatible( + 'select "root".HOLDER_ADDRESS_NAME as "c1", sum(case when "root".HOLDER_ADDRESS_NAME like \'addressh1%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" group by "c1"', + 'select "root".HOLDER_ADDRESS_NAME as "c1", sum(case when "root".HOLDER_ADDRESS_NAME like \'addressh1%\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "sum" from PRODUCT_DENORM as "root" group by "c1"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::inline::nested::testQualifierProperty():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedTargetIds.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedTargetIds.pure index 84c2e4098c8..259b8b7f9f6 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedTargetIds.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/embedded/testInlineEmbeddedTargetIds.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; import meta::relational::tests::csv::*; @@ -95,8 +96,11 @@ function <> meta::relational::tests::mapping::embedded::advanced::inl ), testMappingEmbeddedTargetIds,testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('holder,Profit\n' + 'holder1,10.0\n' + 'holder3,1.0\n', $result.values->toOne()->toCSV()); - assertSameSQL('select "root".HOLDER as "holder", sum(case when "root".BOND_TYPE = \'5 years\' then 5.0 else 1.0 end) as "Profit" from PRODUCT_DENORM as "root" group by "holder"', $result); - + assertEqualsH2Compatible( + 'select "root".HOLDER as "holder", sum(case when "root".BOND_TYPE = \'5 years\' then 5.0 else 1.0 end) as "Profit" from PRODUCT_DENORM as "root" group by "holder"', + 'select "root".HOLDER as "holder", sum(case when "root".BOND_TYPE = \'5 years\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "Profit" from PRODUCT_DENORM as "root" group by "holder"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::inline::targetid::testGroupByComplexAgg():Boolean[1] @@ -109,8 +113,11 @@ function <> meta::relational::tests::mapping::embedded::advanced::inl ), testMappingEmbeddedTargetIds, testRuntime(), meta::relational::extension::relationalExtensions()); assertEquals('c1,sum\n' + 'holder1,2.0\n' + 'holder3,5.0\n', $result.values->toOne()->toCSV()); - assertSameSQL( 'select "root".HOLDER as "c1", sum(case when "root".HOLDER like \'holder3%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" group by "c1"', $result); - + assertEqualsH2Compatible( + 'select "root".HOLDER as "c1", sum(case when "root".HOLDER like \'holder3%\' then 5.0 else 1.0 end) as "sum" from PRODUCT_DENORM as "root" group by "c1"', + 'select "root".HOLDER as "c1", sum(case when "root".HOLDER like \'holder3%\' then CAST(5.0 AS FLOAT) else CAST(1.0 AS FLOAT) end) as "sum" from PRODUCT_DENORM as "root" group by "c1"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::embedded::advanced::inline::targetid::testQualifierProperty():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/sqlFunction/testSqlFunctionsInMapping.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/sqlFunction/testSqlFunctionsInMapping.pure index d428a227d37..513074d76fa 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/sqlFunction/testSqlFunctionsInMapping.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/sqlFunction/testSqlFunctionsInMapping.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::sqlstring::*; import meta::pure::executionPlan::profiles::*; import meta::relational::tests::mapping::sqlFunction::model::domain::*; @@ -247,7 +248,11 @@ function <> meta::relational::tests::mapping::sqlFunction::sin::testF { let result = execute(|SqlFunctionDemo.all()->filter(s | $s.floatSinResult > 0.9)->project([s | $s.floatSinResult], ['sin']), testMapping, testDataTypeMappingRuntime(), meta::relational::extension::relationalExtensions()); assertEquals([0.9738476308781951], $result.values->at(0).rows.values); - assertEquals('select sin("root".float1) as "sin" from dataTable as "root" where sin("root".float1) > 0.9',$result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select sin("root".float1) as "sin" from dataTable as "root" where sin("root".float1) > 0.9', + 'select sin("root".float1) as "sin" from dataTable as "root" where sin("root".float1) > CAST(0.9 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::sqlFunction::cos::testProject():Boolean[1] @@ -331,7 +336,11 @@ function <> meta::relational::tests::mapping::sqlFunction::atan2::tes { let result = execute(|SqlFunctionDemo.all()->filter(s | $s.floatATan2Result > 0.8)->project([s | $s.floatATan2Result], ['atan2']), testMapping, testDataTypeMappingRuntime(), meta::relational::extension::relationalExtensions()); assertEquals([0.8329812666744317], $result.values->at(0).rows.values); - assertEquals('select atan2("root".float1,"root".int1) as "atan2" from dataTable as "root" where atan2("root".float1,"root".int1) > 0.8',$result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select atan2("root".float1,"root".int1) as "atan2" from dataTable as "root" where atan2("root".float1,"root".int1) > 0.8', + 'select atan2("root".float1,"root".int1) as "atan2" from dataTable as "root" where atan2("root".float1,"root".int1) > CAST(0.8 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::sqlFunction::sqrt::testProject():Boolean[1] @@ -535,7 +544,11 @@ function <> meta::relational::tests::mapping::sqlFunction::pow::testF { let result = execute(|SqlFunctionDemo.all()->filter(s | $s.powerResult < 1.4)->project([s | $s.powerResult], ['power']), testMapping, testDataTypeMappingRuntime(), meta::relational::extension::relationalExtensions()); assertEquals([1.3310000000000004], $result.values->at(0).rows.values); - assertEquals('select power("root".float1, 3) as "power" from dataTable as "root" where power("root".float1, 3) < 1.4',$result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select power("root".float1, 3) as "power" from dataTable as "root" where power("root".float1, 3) < 1.4', + 'select power("root".float1, 3) as "power" from dataTable as "root" where power("root".float1, 3) < CAST(1.4 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::sqlFunction::exp::testProject():Boolean[1] @@ -563,7 +576,11 @@ function <> meta::relational::tests::mapping::sqlFunction::log::testF { let result = execute(|SqlFunctionDemo.all()->filter(s | $s.logResult < 0.1)->project([s | $s.logResult], ['log']), testMapping, testDataTypeMappingRuntime(), meta::relational::extension::relationalExtensions()); assertEquals([0.09531017980432493], $result.values->at(0).rows.values); - assertEquals('select ln("root".float1) as "log" from dataTable as "root" where ln("root".float1) < 0.1',$result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select ln("root".float1) as "log" from dataTable as "root" where ln("root".float1) < 0.1', + 'select ln("root".float1) as "log" from dataTable as "root" where ln("root".float1) < CAST(0.1 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::sqlFunction::indexOf::testProject():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/union/testUnionWithMultipleChainedJoins.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/union/testUnionWithMultipleChainedJoins.pure index 236c20ed440..3cbc6bf26cc 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/union/testUnionWithMultipleChainedJoins.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/mapping/union/testUnionWithMultipleChainedJoins.pure @@ -13,6 +13,8 @@ // limitations under the License. ###Pure +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::relational::tests::mapping::union::multipleChainedJoins::mapping::*; import meta::relational::tests::mapping::union::multipleChainedJoins::model::*; @@ -21,7 +23,11 @@ import meta::relational::tests::*; function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross2SetsV1():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross2SetsV1, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk" as "y_pk", "unionalias_3"."Z0pk_Z1pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') left outer join (select "unionalias_2".fk_1 as fk_1, "unionalias_2".fk_0 as fk_0, "unionalias_2"."Y0pk_Y1pk" as "Y0pk_Y1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Y0pk_Y1pk" from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Y0pk_Y1pk" from Y1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("a_0".fk1 = "unionalias_1".fk_1 or "unionBase".fk_0 = "unionalias_1".fk_0) left outer join (select "g_1".fk0 as fk0, "g_1".fk1 from G as "g_1" where "g_1".from_z <= \'2018-01-01\' and "g_1".thru_z > \'2018-01-01\') as "g_0" on ("unionalias_1".fk_1 = "g_0".fk0) left outer join (select "unionalias_4".fk_1 as fk_1, "unionalias_4".fk_0 as fk_0, "unionalias_4"."Z0pk_Z1pk" as "Z0pk_Z1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Z0pk_Z1pk" from Z0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Z0pk_Z1pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_4" where (coalesce("unionalias_4"."from_z_0", "unionalias_4"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_4"."thru_z_0", "unionalias_4"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_4"."from_z_0", "unionalias_4"."from_z_1", "unionalias_4"."thru_z_0", "unionalias_4"."thru_z_1") is null) as "unionalias_3" on ("g_0".fk1 = "unionalias_3".fk_1 or "unionalias_1".fk_0 = "unionalias_3".fk_0)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk" as "y_pk", "unionalias_3"."Z0pk_Z1pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') left outer join (select "unionalias_2".fk_1 as fk_1, "unionalias_2".fk_0 as fk_0, "unionalias_2"."Y0pk_Y1pk" as "Y0pk_Y1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Y0pk_Y1pk" from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Y0pk_Y1pk" from Y1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("a_0".fk1 = "unionalias_1".fk_1 or "unionBase".fk_0 = "unionalias_1".fk_0) left outer join (select "g_1".fk0 as fk0, "g_1".fk1 from G as "g_1" where "g_1".from_z <= \'2018-01-01\' and "g_1".thru_z > \'2018-01-01\') as "g_0" on ("unionalias_1".fk_1 = "g_0".fk0) left outer join (select "unionalias_4".fk_1 as fk_1, "unionalias_4".fk_0 as fk_0, "unionalias_4"."Z0pk_Z1pk" as "Z0pk_Z1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Z0pk_Z1pk" from Z0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Z0pk_Z1pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_4" where (coalesce("unionalias_4"."from_z_0", "unionalias_4"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_4"."thru_z_0", "unionalias_4"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_4"."from_z_0", "unionalias_4"."from_z_1", "unionalias_4"."thru_z_0", "unionalias_4"."thru_z_1") is null) as "unionalias_3" on ("g_0".fk1 = "unionalias_3".fk_1 or "unionalias_1".fk_0 = "unionalias_3".fk_0)', + 'select "unionBase"."X0pk_X1pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk" as "y_pk", "unionalias_3"."Z0pk_Z1pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') left outer join (select "unionalias_2".fk_1 as fk_1, "unionalias_2".fk_0 as fk_0, "unionalias_2"."Y0pk_Y1pk" as "Y0pk_Y1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Y0pk_Y1pk" from Y0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Y0pk_Y1pk" from Y1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= DATE\'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > DATE\'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("a_0".fk1 = "unionalias_1".fk_1 or "unionBase".fk_0 = "unionalias_1".fk_0) left outer join (select "g_1".fk0 as fk0, "g_1".fk1 from G as "g_1" where "g_1".from_z <= DATE\'2018-01-01\' and "g_1".thru_z > DATE\'2018-01-01\') as "g_0" on ("unionalias_1".fk_1 = "g_0".fk0) left outer join (select "unionalias_4".fk_1 as fk_1, "unionalias_4".fk_0 as fk_0, "unionalias_4"."Z0pk_Z1pk" as "Z0pk_Z1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Z0pk_Z1pk" from Z0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Z0pk_Z1pk" from Z1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_4" where (coalesce("unionalias_4"."from_z_0", "unionalias_4"."from_z_1") <= DATE\'2018-01-01\' and coalesce("unionalias_4"."thru_z_0", "unionalias_4"."thru_z_1") > DATE\'2018-01-01\') or coalesce("unionalias_4"."from_z_0", "unionalias_4"."from_z_1", "unionalias_4"."thru_z_0", "unionalias_4"."thru_z_1") is null) as "unionalias_3" on ("g_0".fk1 = "unionalias_3".fk_1 or "unionalias_1".fk_0 = "unionalias_3".fk_0)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11], $result.values.rows.get('x_pk')); assertEquals([20, 21], $result.values.rows.get('y_pk')); assertEquals([30, 31], $result.values.rows.get('z_pk')); @@ -30,7 +36,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross3SetsV1():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross3SetsV1, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk" as "y_pk", "unionalias_2"."Z0pk_Z1pk_Z2pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, null as fk1_2 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", "g_0".fk1 as fk1_1, null as fk1_2 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, "i_0".fk1 as fk1_2 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") is null)) left outer join (select "unionalias_3".fk_0 as fk_0, "unionalias_3".fk_1 as fk_1, "unionalias_3".fk_2 as fk_2, "unionalias_3"."Z0pk_Z1pk_Z2pk" as "Z0pk_Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_3" where (coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2") <= \'2018-01-01\' and coalesce("unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2") > \'2018-01-01\') or coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2") is null) as "unionalias_2" on ("unionalias_1".fk_0 = "unionalias_2".fk_0 or "unionalias_1".fk1_1 = "unionalias_2".fk_1 or "unionalias_1".fk1_2 = "unionalias_2".fk_2)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk" as "y_pk", "unionalias_2"."Z0pk_Z1pk_Z2pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, null as fk1_2 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", "g_0".fk1 as fk1_1, null as fk1_2 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, "i_0".fk1 as fk1_2 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") is null)) left outer join (select "unionalias_3".fk_0 as fk_0, "unionalias_3".fk_1 as fk_1, "unionalias_3".fk_2 as fk_2, "unionalias_3"."Z0pk_Z1pk_Z2pk" as "Z0pk_Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_3" where (coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2") <= \'2018-01-01\' and coalesce("unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2") > \'2018-01-01\') or coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2") is null) as "unionalias_2" on ("unionalias_1".fk_0 = "unionalias_2".fk_0 or "unionalias_1".fk1_1 = "unionalias_2".fk_1 or "unionalias_1".fk1_2 = "unionalias_2".fk_2)', + 'select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk" as "y_pk", "unionalias_2"."Z0pk_Z1pk_Z2pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= DATE\'2018-01-01\' and "b_0".thru_z > DATE\'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= DATE\'2018-01-01\' and "c_1".thru_z > DATE\'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, null as fk1_2 from Y0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", "g_0".fk1 as fk1_1, null as fk1_2 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= DATE\'2018-01-01\' and "g_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, "i_0".fk1 as fk1_2 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= DATE\'2018-01-01\' and "h_0".thru_z > DATE\'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= DATE\'2018-01-01\' and "i_1".thru_z > DATE\'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2") <= DATE\'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") > DATE\'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") is null)) left outer join (select "unionalias_3".fk_0 as fk_0, "unionalias_3".fk_1 as fk_1, "unionalias_3".fk_2 as fk_2, "unionalias_3"."Z0pk_Z1pk_Z2pk" as "Z0pk_Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Z0pk_Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_3" where (coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2") <= DATE\'2018-01-01\' and coalesce("unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2") > DATE\'2018-01-01\') or coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2") is null) as "unionalias_2" on ("unionalias_1".fk_0 = "unionalias_2".fk_0 or "unionalias_1".fk1_1 = "unionalias_2".fk_1 or "unionalias_1".fk1_2 = "unionalias_2".fk_2)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11, 12], $result.values.rows.get('x_pk')); assertEquals([20, 21, 22], $result.values.rows.get('y_pk')); assertEquals([30, 31, 32], $result.values.rows.get('z_pk')); @@ -39,7 +49,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross4SetsV1():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross4SetsV1, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk_Y3pk" as "y_pk", "unionalias_2"."Z0pk_Z1pk_Z2pk_Z3pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= \'2018-01-01\' and "d_0".thru_z > \'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= \'2018-01-01\' and "e_1".thru_z > \'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= \'2018-01-01\' and "f_1".thru_z > \'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, null as fk1_3 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", "g_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, "i_0".fk1 as fk1_2, null as fk1_3 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, "l_0".fk1 as fk1_3 from Y3 as "root" left outer join J as "j_0" on ("root".fk = "j_0".fk0 and "j_0".from_z <= \'2018-01-01\' and "j_0".thru_z > \'2018-01-01\') left outer join (select "k_1".fk0 as fk0, "k_1".fk1 from K as "k_1" where "k_1".from_z <= \'2018-01-01\' and "k_1".thru_z > \'2018-01-01\') as "k_0" on ("j_0".fk1 = "k_0".fk0) left outer join (select "l_1".fk1 as fk1, "l_1".fk0 as fk0 from L as "l_1" where "l_1".from_z <= \'2018-01-01\' and "l_1".thru_z > \'2018-01-01\') as "l_0" on ("k_0".fk1 = "l_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2 or "unionBase".fk1_3 = "unionalias_1".fk_3) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") is null)) left outer join (select "unionalias_3".fk_0 as fk_0, "unionalias_3".fk_1 as fk_1, "unionalias_3".fk_2 as fk_2, "unionalias_3".fk_3 as fk_3, "unionalias_3"."Z0pk_Z1pk_Z2pk_Z3pk" as "Z0pk_Z1pk_Z2pk_Z3pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z3 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_3" where (coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."from_z_3") <= \'2018-01-01\' and coalesce("unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2", "unionalias_3"."thru_z_3") > \'2018-01-01\') or coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."from_z_3", "unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2", "unionalias_3"."thru_z_3") is null) as "unionalias_2" on ("unionalias_1".fk_0 = "unionalias_2".fk_0 or "unionalias_1".fk1_1 = "unionalias_2".fk_1 or "unionalias_1".fk1_2 = "unionalias_2".fk_2 or "unionalias_1".fk1_3 = "unionalias_2".fk_3)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk_Y3pk" as "y_pk", "unionalias_2"."Z0pk_Z1pk_Z2pk_Z3pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= \'2018-01-01\' and "d_0".thru_z > \'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= \'2018-01-01\' and "e_1".thru_z > \'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= \'2018-01-01\' and "f_1".thru_z > \'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, null as fk1_3 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", "g_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, "i_0".fk1 as fk1_2, null as fk1_3 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, "l_0".fk1 as fk1_3 from Y3 as "root" left outer join J as "j_0" on ("root".fk = "j_0".fk0 and "j_0".from_z <= \'2018-01-01\' and "j_0".thru_z > \'2018-01-01\') left outer join (select "k_1".fk0 as fk0, "k_1".fk1 from K as "k_1" where "k_1".from_z <= \'2018-01-01\' and "k_1".thru_z > \'2018-01-01\') as "k_0" on ("j_0".fk1 = "k_0".fk0) left outer join (select "l_1".fk1 as fk1, "l_1".fk0 as fk0 from L as "l_1" where "l_1".from_z <= \'2018-01-01\' and "l_1".thru_z > \'2018-01-01\') as "l_0" on ("k_0".fk1 = "l_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2 or "unionBase".fk1_3 = "unionalias_1".fk_3) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") is null)) left outer join (select "unionalias_3".fk_0 as fk_0, "unionalias_3".fk_1 as fk_1, "unionalias_3".fk_2 as fk_2, "unionalias_3".fk_3 as fk_3, "unionalias_3"."Z0pk_Z1pk_Z2pk_Z3pk" as "Z0pk_Z1pk_Z2pk_Z3pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z3 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_3" where (coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."from_z_3") <= \'2018-01-01\' and coalesce("unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2", "unionalias_3"."thru_z_3") > \'2018-01-01\') or coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."from_z_3", "unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2", "unionalias_3"."thru_z_3") is null) as "unionalias_2" on ("unionalias_1".fk_0 = "unionalias_2".fk_0 or "unionalias_1".fk1_1 = "unionalias_2".fk_1 or "unionalias_1".fk1_2 = "unionalias_2".fk_2 or "unionalias_1".fk1_3 = "unionalias_2".fk_3)', + 'select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk_Y3pk" as "y_pk", "unionalias_2"."Z0pk_Z1pk_Z2pk_Z3pk" as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= DATE\'2018-01-01\' and "b_0".thru_z > DATE\'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= DATE\'2018-01-01\' and "c_1".thru_z > DATE\'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= DATE\'2018-01-01\' and "d_0".thru_z > DATE\'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= DATE\'2018-01-01\' and "e_1".thru_z > DATE\'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= DATE\'2018-01-01\' and "f_1".thru_z > DATE\'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, null as fk1_3 from Y0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", "g_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= DATE\'2018-01-01\' and "g_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, "i_0".fk1 as fk1_2, null as fk1_3 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= DATE\'2018-01-01\' and "h_0".thru_z > DATE\'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= DATE\'2018-01-01\' and "i_1".thru_z > DATE\'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, "l_0".fk1 as fk1_3 from Y3 as "root" left outer join J as "j_0" on ("root".fk = "j_0".fk0 and "j_0".from_z <= DATE\'2018-01-01\' and "j_0".thru_z > DATE\'2018-01-01\') left outer join (select "k_1".fk0 as fk0, "k_1".fk1 from K as "k_1" where "k_1".from_z <= DATE\'2018-01-01\' and "k_1".thru_z > DATE\'2018-01-01\') as "k_0" on ("j_0".fk1 = "k_0".fk0) left outer join (select "l_1".fk1 as fk1, "l_1".fk0 as fk0 from L as "l_1" where "l_1".from_z <= DATE\'2018-01-01\' and "l_1".thru_z > DATE\'2018-01-01\') as "l_0" on ("k_0".fk1 = "l_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2 or "unionBase".fk1_3 = "unionalias_1".fk_3) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3") <= DATE\'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") > DATE\'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") is null)) left outer join (select "unionalias_3".fk_0 as fk_0, "unionalias_3".fk_1 as fk_1, "unionalias_3".fk_2 as fk_2, "unionalias_3".fk_3 as fk_3, "unionalias_3"."Z0pk_Z1pk_Z2pk_Z3pk" as "Z0pk_Z1pk_Z2pk_Z3pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z2 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Z0pk_Z1pk_Z2pk_Z3pk" from Z3 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_3" where (coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."from_z_3") <= DATE\'2018-01-01\' and coalesce("unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2", "unionalias_3"."thru_z_3") > DATE\'2018-01-01\') or coalesce("unionalias_3"."from_z_0", "unionalias_3"."from_z_1", "unionalias_3"."from_z_2", "unionalias_3"."from_z_3", "unionalias_3"."thru_z_0", "unionalias_3"."thru_z_1", "unionalias_3"."thru_z_2", "unionalias_3"."thru_z_3") is null) as "unionalias_2" on ("unionalias_1".fk_0 = "unionalias_2".fk_0 or "unionalias_1".fk1_1 = "unionalias_2".fk_1 or "unionalias_1".fk1_2 = "unionalias_2".fk_2 or "unionalias_1".fk1_3 = "unionalias_2".fk_3)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11, 12, 13], $result.values.rows.get('x_pk')); assertEquals([20, 21, 22, 23], $result.values.rows.get('y_pk')); assertEquals([30, 31, 32, 33], $result.values.rows.get('z_pk')); @@ -48,7 +62,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross2SetsV2():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross2SetsV2, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') left outer join (select "unionalias_2".fk_1 as fk_1, "unionalias_2".fk_0 as fk_0, "unionalias_2"."Y0pk_Y1pk" as "Y0pk_Y1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Y0pk_Y1pk" from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Y0pk_Y1pk" from Y1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("a_0".fk1 = "unionalias_1".fk_1 or "unionBase".fk_0 = "unionalias_1".fk_0) left outer join (select "g_1".fk0 as fk0, "g_1".fk1 from G as "g_1" where "g_1".from_z <= \'2018-01-01\' and "g_1".thru_z > \'2018-01-01\') as "g_0" on ("unionalias_1".fk_1 = "g_0".fk0) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("g_0".fk1 = "z0_0".fk or "unionalias_1".fk_0 = "z0_0".fk)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') left outer join (select "unionalias_2".fk_1 as fk_1, "unionalias_2".fk_0 as fk_0, "unionalias_2"."Y0pk_Y1pk" as "Y0pk_Y1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Y0pk_Y1pk" from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Y0pk_Y1pk" from Y1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("a_0".fk1 = "unionalias_1".fk_1 or "unionBase".fk_0 = "unionalias_1".fk_0) left outer join (select "g_1".fk0 as fk0, "g_1".fk1 from G as "g_1" where "g_1".from_z <= \'2018-01-01\' and "g_1".thru_z > \'2018-01-01\') as "g_0" on ("unionalias_1".fk_1 = "g_0".fk0) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("g_0".fk1 = "z0_0".fk or "unionalias_1".fk_0 = "z0_0".fk)', + 'select "unionBase"."X0pk_X1pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') left outer join (select "unionalias_2".fk_1 as fk_1, "unionalias_2".fk_0 as fk_0, "unionalias_2"."Y0pk_Y1pk" as "Y0pk_Y1pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".fk as fk_0, null as fk_1, "root".pk as "Y0pk_Y1pk" from Y0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as fk_0, "root".fk as fk_1, "root".pk as "Y0pk_Y1pk" from Y1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= DATE\'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > DATE\'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("a_0".fk1 = "unionalias_1".fk_1 or "unionBase".fk_0 = "unionalias_1".fk_0) left outer join (select "g_1".fk0 as fk0, "g_1".fk1 from G as "g_1" where "g_1".from_z <= DATE\'2018-01-01\' and "g_1".thru_z > DATE\'2018-01-01\') as "g_0" on ("unionalias_1".fk_1 = "g_0".fk0) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= DATE\'2018-01-01\' and "z0_1".thru_z > DATE\'2018-01-01\') as "z0_0" on ("g_0".fk1 = "z0_0".fk or "unionalias_1".fk_0 = "z0_0".fk)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11], $result.values.rows.get('x_pk')); assertEquals([20, 21], $result.values.rows.get('y_pk')); assertEquals([30, 30], $result.values.rows.get('z_pk')); @@ -57,7 +75,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross3SetsV2():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross3SetsV2, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, null as fk1_2 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", "g_0".fk1 as fk1_1, null as fk1_2 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, "i_0".fk1 as fk1_2 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") is null)) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("unionalias_1".fk_0 = "z0_0".fk or "unionalias_1".fk1_1 = "z0_0".fk or "unionalias_1".fk1_2 = "z0_0".fk)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, null as fk1_2 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", "g_0".fk1 as fk1_1, null as fk1_2 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, "i_0".fk1 as fk1_2 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") is null)) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("unionalias_1".fk_0 = "z0_0".fk or "unionalias_1".fk1_1 = "z0_0".fk or "unionalias_1".fk1_2 = "z0_0".fk)', + 'select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= DATE\'2018-01-01\' and "b_0".thru_z > DATE\'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= DATE\'2018-01-01\' and "c_1".thru_z > DATE\'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".fk as fk_0, null as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, null as fk1_2 from Y0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as fk_0, "root".fk as fk_1, null as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", "g_0".fk1 as fk1_1, null as fk1_2 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= DATE\'2018-01-01\' and "g_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as fk_0, null as fk_1, "root".fk as fk_2, "root".pk as "Y0pk_Y1pk_Y2pk", null as fk1_1, "i_0".fk1 as fk1_2 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= DATE\'2018-01-01\' and "h_0".thru_z > DATE\'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= DATE\'2018-01-01\' and "i_1".thru_z > DATE\'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2") <= DATE\'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") > DATE\'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2") is null)) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= DATE\'2018-01-01\' and "z0_1".thru_z > DATE\'2018-01-01\') as "z0_0" on ("unionalias_1".fk_0 = "z0_0".fk or "unionalias_1".fk1_1 = "z0_0".fk or "unionalias_1".fk1_2 = "z0_0".fk)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11, 12], $result.values.rows.get('x_pk')); assertEquals([20, 21, 22], $result.values.rows.get('y_pk')); assertEquals([30, 30, 30], $result.values.rows.get('z_pk')); @@ -66,7 +88,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross4SetsV2():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross4SetsV2, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk_Y3pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= \'2018-01-01\' and "d_0".thru_z > \'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= \'2018-01-01\' and "e_1".thru_z > \'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= \'2018-01-01\' and "f_1".thru_z > \'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, null as fk1_3 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", "g_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, "i_0".fk1 as fk1_2, null as fk1_3 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, "l_0".fk1 as fk1_3 from Y3 as "root" left outer join J as "j_0" on ("root".fk = "j_0".fk0 and "j_0".from_z <= \'2018-01-01\' and "j_0".thru_z > \'2018-01-01\') left outer join (select "k_1".fk0 as fk0, "k_1".fk1 from K as "k_1" where "k_1".from_z <= \'2018-01-01\' and "k_1".thru_z > \'2018-01-01\') as "k_0" on ("j_0".fk1 = "k_0".fk0) left outer join (select "l_1".fk1 as fk1, "l_1".fk0 as fk0 from L as "l_1" where "l_1".from_z <= \'2018-01-01\' and "l_1".thru_z > \'2018-01-01\') as "l_0" on ("k_0".fk1 = "l_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2 or "unionBase".fk1_3 = "unionalias_1".fk_3) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") is null)) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("unionalias_1".fk_0 = "z0_0".fk or "unionalias_1".fk1_1 = "z0_0".fk or "unionalias_1".fk1_2 = "z0_0".fk or "unionalias_1".fk1_3 = "z0_0".fk)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk_Y3pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= \'2018-01-01\' and "d_0".thru_z > \'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= \'2018-01-01\' and "e_1".thru_z > \'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= \'2018-01-01\' and "f_1".thru_z > \'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, null as fk1_3 from Y0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", "g_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= \'2018-01-01\' and "g_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, "i_0".fk1 as fk1_2, null as fk1_3 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= \'2018-01-01\' and "h_0".thru_z > \'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= \'2018-01-01\' and "i_1".thru_z > \'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, "l_0".fk1 as fk1_3 from Y3 as "root" left outer join J as "j_0" on ("root".fk = "j_0".fk0 and "j_0".from_z <= \'2018-01-01\' and "j_0".thru_z > \'2018-01-01\') left outer join (select "k_1".fk0 as fk0, "k_1".fk1 from K as "k_1" where "k_1".from_z <= \'2018-01-01\' and "k_1".thru_z > \'2018-01-01\') as "k_0" on ("j_0".fk1 = "k_0".fk0) left outer join (select "l_1".fk1 as fk1, "l_1".fk0 as fk0 from L as "l_1" where "l_1".from_z <= \'2018-01-01\' and "l_1".thru_z > \'2018-01-01\') as "l_0" on ("k_0".fk1 = "l_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2 or "unionBase".fk1_3 = "unionalias_1".fk_3) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") is null)) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("unionalias_1".fk_0 = "z0_0".fk or "unionalias_1".fk1_1 = "z0_0".fk or "unionalias_1".fk1_2 = "z0_0".fk or "unionalias_1".fk1_3 = "z0_0".fk)', + 'select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "unionalias_1"."Y0pk_Y1pk_Y2pk_Y3pk" as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= DATE\'2018-01-01\' and "b_0".thru_z > DATE\'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= DATE\'2018-01-01\' and "c_1".thru_z > DATE\'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= DATE\'2018-01-01\' and "d_0".thru_z > DATE\'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= DATE\'2018-01-01\' and "e_1".thru_z > DATE\'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= DATE\'2018-01-01\' and "f_1".thru_z > DATE\'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, null as fk1_3 from Y0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", "g_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from Y1 as "root" left outer join G as "g_0" on ("root".fk = "g_0".fk0 and "g_0".from_z <= DATE\'2018-01-01\' and "g_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, "i_0".fk1 as fk1_2, null as fk1_3 from Y2 as "root" left outer join H as "h_0" on ("root".fk = "h_0".fk0 and "h_0".from_z <= DATE\'2018-01-01\' and "h_0".thru_z > DATE\'2018-01-01\') left outer join (select "i_1".fk1 as fk1, "i_1".fk0 as fk0 from I as "i_1" where "i_1".from_z <= DATE\'2018-01-01\' and "i_1".thru_z > DATE\'2018-01-01\') as "i_0" on ("h_0".fk1 = "i_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, "root".pk as "Y0pk_Y1pk_Y2pk_Y3pk", null as fk1_1, null as fk1_2, "l_0".fk1 as fk1_3 from Y3 as "root" left outer join J as "j_0" on ("root".fk = "j_0".fk0 and "j_0".from_z <= DATE\'2018-01-01\' and "j_0".thru_z > DATE\'2018-01-01\') left outer join (select "k_1".fk0 as fk0, "k_1".fk1 from K as "k_1" where "k_1".from_z <= DATE\'2018-01-01\' and "k_1".thru_z > DATE\'2018-01-01\') as "k_0" on ("j_0".fk1 = "k_0".fk0) left outer join (select "l_1".fk1 as fk1, "l_1".fk0 as fk0 from L as "l_1" where "l_1".from_z <= DATE\'2018-01-01\' and "l_1".thru_z > DATE\'2018-01-01\') as "l_0" on ("k_0".fk1 = "l_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_1" on (("unionBase".fk_0 = "unionalias_1".fk_0 or "unionBase".fk1_1 = "unionalias_1".fk_1 or "unionBase".fk1_2 = "unionalias_1".fk_2 or "unionBase".fk1_3 = "unionalias_1".fk_3) and ((coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3") <= DATE\'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") > DATE\'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."from_z_2", "unionalias_1"."from_z_3", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1", "unionalias_1"."thru_z_2", "unionalias_1"."thru_z_3") is null)) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= DATE\'2018-01-01\' and "z0_1".thru_z > DATE\'2018-01-01\') as "z0_0" on ("unionalias_1".fk_0 = "z0_0".fk or "unionalias_1".fk1_1 = "z0_0".fk or "unionalias_1".fk1_2 = "z0_0".fk or "unionalias_1".fk1_3 = "z0_0".fk)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11, 12, 13], $result.values.rows.get('x_pk')); assertEquals([20, 21, 22, 23], $result.values.rows.get('y_pk')); assertEquals([30, 30, 30, 30], $result.values.rows.get('z_pk')); @@ -75,7 +101,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross2SetsV3():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross2SetsV3, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') left outer join (select "y0_1".fk as fk, "y0_1".pk as pk from Y0 as "y0_1" where "y0_1".from_z <= \'2018-01-01\' and "y0_1".thru_z > \'2018-01-01\') as "y0_0" on ("a_0".fk1 = "y0_0".fk or "unionBase".fk_0 = "y0_0".fk) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') left outer join (select "y0_1".fk as fk, "y0_1".pk as pk from Y0 as "y0_1" where "y0_1".from_z <= \'2018-01-01\' and "y0_1".thru_z > \'2018-01-01\') as "y0_0" on ("a_0".fk1 = "y0_0".fk or "unionBase".fk_0 = "y0_0".fk) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', + 'select "unionBase"."X0pk_X1pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as "pk_0_0", null as "pk_0_1", "root".pk as "X0pk_X1pk", "root".fk as fk_0, null as fk_1 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "pk_0_0", "root".pk as "pk_0_1", "root".pk as "X0pk_X1pk", null as fk_0, "root".fk as fk_1 from X1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join A as "a_0" on ("unionBase".fk_1 = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') left outer join (select "y0_1".fk as fk, "y0_1".pk as pk from Y0 as "y0_1" where "y0_1".from_z <= DATE\'2018-01-01\' and "y0_1".thru_z > DATE\'2018-01-01\') as "y0_0" on ("a_0".fk1 = "y0_0".fk or "unionBase".fk_0 = "y0_0".fk) left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= DATE\'2018-01-01\' and "z0_1".thru_z > DATE\'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11], $result.values.rows.get('x_pk')); assertEquals([20, 20], $result.values.rows.get('y_pk')); assertEquals([30, 30], $result.values.rows.get('z_pk')); @@ -84,7 +114,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross3SetsV3():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross3SetsV3, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join Y0 as "y0_0" on (("unionBase".fk_0 = "y0_0".fk or "unionBase".fk1_1 = "y0_0".fk or "unionBase".fk1_2 = "y0_0".fk) and "y0_0".from_z <= \'2018-01-01\' and "y0_0".thru_z > \'2018-01-01\') left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join Y0 as "y0_0" on (("unionBase".fk_0 = "y0_0".fk or "unionBase".fk1_1 = "y0_0".fk or "unionBase".fk1_2 = "y0_0".fk) and "y0_0".from_z <= \'2018-01-01\' and "y0_0".thru_z > \'2018-01-01\') left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', + 'select "unionBase"."X0pk_X1pk_X2pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk1_1, null as fk1_2 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, "root".fk as fk_1, null as fk_2, "a_0".fk1 as fk1_1, null as fk1_2 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", "root".pk as "X0pk_X1pk_X2pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk1_1, "c_0".fk1 as fk1_2 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= DATE\'2018-01-01\' and "b_0".thru_z > DATE\'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= DATE\'2018-01-01\' and "c_1".thru_z > DATE\'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join Y0 as "y0_0" on (("unionBase".fk_0 = "y0_0".fk or "unionBase".fk1_1 = "y0_0".fk or "unionBase".fk1_2 = "y0_0".fk) and "y0_0".from_z <= DATE\'2018-01-01\' and "y0_0".thru_z > DATE\'2018-01-01\') left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= DATE\'2018-01-01\' and "z0_1".thru_z > DATE\'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11, 12], $result.values.rows.get('x_pk')); assertEquals([20, 20, 20], $result.values.rows.get('y_pk')); assertEquals([30, 30, 30], $result.values.rows.get('z_pk')); @@ -93,7 +127,11 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionWithChainedJoinsAcross4SetsV3():Boolean[1] { let result = execute(|X.all(%2018-1-1)->project([x|$x.pk, x|$x.y.pk, x|$x.y.z.pk],['x_pk', 'y_pk', 'z_pk']), multipleChainedJoinsMappingWithUnionAcross4SetsV3, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= \'2018-01-01\' and "d_0".thru_z > \'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= \'2018-01-01\' and "e_1".thru_z > \'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= \'2018-01-01\' and "f_1".thru_z > \'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join Y0 as "y0_0" on (("unionBase".fk_0 = "y0_0".fk or "unionBase".fk1_1 = "y0_0".fk or "unionBase".fk1_2 = "y0_0".fk or "unionBase".fk1_3 = "y0_0".fk) and "y0_0".from_z <= \'2018-01-01\' and "y0_0".thru_z > \'2018-01-01\') left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', $result); + assertEqualsH2Compatible( + 'select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= \'2018-01-01\' and "a_0".thru_z > \'2018-01-01\') where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= \'2018-01-01\' and "b_0".thru_z > \'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= \'2018-01-01\' and "c_1".thru_z > \'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= \'2018-01-01\' and "d_0".thru_z > \'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= \'2018-01-01\' and "e_1".thru_z > \'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= \'2018-01-01\' and "f_1".thru_z > \'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionBase" left outer join Y0 as "y0_0" on (("unionBase".fk_0 = "y0_0".fk or "unionBase".fk1_1 = "y0_0".fk or "unionBase".fk1_2 = "y0_0".fk or "unionBase".fk1_3 = "y0_0".fk) and "y0_0".from_z <= \'2018-01-01\' and "y0_0".thru_z > \'2018-01-01\') left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= \'2018-01-01\' and "z0_1".thru_z > \'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', + 'select "unionBase"."X0pk_X1pk_X2pk_X3pk" as "x_pk", "y0_0".pk as "y_pk", "z0_0".pk as "z_pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", "root".pk as "pk_0_0", null as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", "root".fk as fk_0, null as fk_1, null as fk_2, null as fk_3, null as fk1_1, null as fk1_2, null as fk1_3 from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", null as "from_z_2", null as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", "root".pk as "pk_0_1", null as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, "root".fk as fk_1, null as fk_2, null as fk_3, "a_0".fk1 as fk1_1, null as fk1_2, null as fk1_3 from X1 as "root" left outer join A as "a_0" on ("root".fk = "a_0".fk0 and "a_0".from_z <= DATE\'2018-01-01\' and "a_0".thru_z > DATE\'2018-01-01\') where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".from_z as "from_z_2", "root".thru_z as "thru_z_2", null as "from_z_3", null as "thru_z_3", null as "pk_0_0", null as "pk_0_1", "root".pk as "pk_0_2", null as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, "root".fk as fk_2, null as fk_3, null as fk1_1, "c_0".fk1 as fk1_2, null as fk1_3 from X2 as "root" left outer join B as "b_0" on ("root".fk = "b_0".fk0 and "b_0".from_z <= DATE\'2018-01-01\' and "b_0".thru_z > DATE\'2018-01-01\') left outer join (select "c_1".fk1 as fk1, "c_1".fk0 as fk0 from C as "c_1" where "c_1".from_z <= DATE\'2018-01-01\' and "c_1".thru_z > DATE\'2018-01-01\') as "c_0" on ("b_0".fk1 = "c_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", null as "from_z_1", null as "thru_z_1", null as "from_z_2", null as "thru_z_2", "root".from_z as "from_z_3", "root".thru_z as "thru_z_3", null as "pk_0_0", null as "pk_0_1", null as "pk_0_2", "root".pk as "pk_0_3", "root".pk as "X0pk_X1pk_X2pk_X3pk", null as fk_0, null as fk_1, null as fk_2, "root".fk as fk_3, null as fk1_1, null as fk1_2, "f_0".fk1 as fk1_3 from X3 as "root" left outer join D as "d_0" on ("root".fk = "d_0".fk0 and "d_0".from_z <= DATE\'2018-01-01\' and "d_0".thru_z > DATE\'2018-01-01\') left outer join (select "e_1".fk0 as fk0, "e_1".fk1 from E as "e_1" where "e_1".from_z <= DATE\'2018-01-01\' and "e_1".thru_z > DATE\'2018-01-01\') as "e_0" on ("d_0".fk1 = "e_0".fk0) left outer join (select "f_1".fk1 as fk1, "f_1".fk0 as fk0 from F as "f_1" where "f_1".from_z <= DATE\'2018-01-01\' and "f_1".thru_z > DATE\'2018-01-01\') as "f_0" on ("e_0".fk1 = "f_0".fk0) where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionBase" left outer join Y0 as "y0_0" on (("unionBase".fk_0 = "y0_0".fk or "unionBase".fk1_1 = "y0_0".fk or "unionBase".fk1_2 = "y0_0".fk or "unionBase".fk1_3 = "y0_0".fk) and "y0_0".from_z <= DATE\'2018-01-01\' and "y0_0".thru_z > DATE\'2018-01-01\') left outer join (select "z0_1".fk as fk, "z0_1".pk as pk from Z0 as "z0_1" where "z0_1".from_z <= DATE\'2018-01-01\' and "z0_1".thru_z > DATE\'2018-01-01\') as "z0_0" on ("y0_0".fk = "z0_0".fk)', + $result->sqlRemoveFormatting() + ); assertEquals([10, 11, 12, 13], $result.values.rows.get('x_pk')); assertEquals([20, 20, 20, 20], $result.values.rows.get('y_pk')); assertEquals([30, 30, 30, 30], $result.values.rows.get('z_pk')); @@ -103,13 +141,21 @@ function <> meta::relational::tests::mapping::union::multipleChainedJ function <> meta::relational::tests::mapping::union::multipleChainedJoins::testViewToViewToUnion():Boolean[1] { let result = execute(|Y.all(%2018-1-1)->project(y|$y.z.pk,'z'), viewToViewToUnion, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."Z1pk_Z2pk" as "z" from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "root" left outer join (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "vx2_0" on ("root".fk = "vx2_0".pk) left outer join (select "unionalias_1".pk as pk, "unionalias_1"."Z1pk_Z2pk" as "Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" where (coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1") is null) as "unionalias_0" on ("vx2_0".fk = "unionalias_0".pk)', $result); + assertEqualsH2Compatible( + 'select "unionalias_0"."Z1pk_Z2pk" as "z" from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "root" left outer join (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "vx2_0" on ("root".fk = "vx2_0".pk) left outer join (select "unionalias_1".pk as pk, "unionalias_1"."Z1pk_Z2pk" as "Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_1" where (coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1") is null) as "unionalias_0" on ("vx2_0".fk = "unionalias_0".pk)', + 'select "unionalias_0"."Z1pk_Z2pk" as "z" from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "root" left outer join (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "vx2_0" on ("root".fk = "vx2_0".pk) left outer join (select "unionalias_1".pk as pk, "unionalias_1"."Z1pk_Z2pk" as "Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_1" where (coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1") <= DATE\'2018-01-01\' and coalesce("unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1") > DATE\'2018-01-01\') or coalesce("unionalias_1"."from_z_0", "unionalias_1"."from_z_1", "unionalias_1"."thru_z_0", "unionalias_1"."thru_z_1") is null) as "unionalias_0" on ("vx2_0".fk = "unionalias_0".pk)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::mapping::union::multipleChainedJoins::testUnionedViewsToViewToUnion():Boolean[1] { let result = execute(|Y.all(%2018-1-1)->project(y|$y.z.pk,'z'), unionOfViewsToViewToUnion, testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_1"."Z1pk_Z2pk" as "z" from (select "root".pk as "pk_0_0", null as "pk_0_1", "root".fk as fk_0, null as fk_1 from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "root" UNION ALL select null as "pk_0_0", "root".pk as "pk_0_1", null as fk_0, "root".fk as fk_1 from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "root") as "unionBase" left outer join (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "vx2_0" on ("unionBase".fk_0 = "vx2_0".pk or "unionBase".fk_1 = "vx2_0".pk) left outer join (select "unionalias_2".pk as pk, "unionalias_2"."Z1pk_Z2pk" as "Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("vx2_0".fk = "unionalias_1".pk)', $result); + assertEqualsH2Compatible( + 'select "unionalias_1"."Z1pk_Z2pk" as "z" from (select "root".pk as "pk_0_0", null as "pk_0_1", "root".fk as fk_0, null as fk_1 from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "root" UNION ALL select null as "pk_0_0", "root".pk as "pk_0_1", null as fk_0, "root".fk as fk_1 from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "root") as "unionBase" left outer join (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "vx2_0" on ("unionBase".fk_0 = "vx2_0".pk or "unionBase".fk_1 = "vx2_0".pk) left outer join (select "unionalias_2".pk as pk, "unionalias_2"."Z1pk_Z2pk" as "Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= \'2018-01-01\' and "root".thru_z > \'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= \'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > \'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("vx2_0".fk = "unionalias_1".pk)', + 'select "unionalias_1"."Z1pk_Z2pk" as "z" from (select "root".pk as "pk_0_0", null as "pk_0_1", "root".fk as fk_0, null as fk_1 from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "root" UNION ALL select null as "pk_0_0", "root".pk as "pk_0_1", null as fk_0, "root".fk as fk_1 from (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "root") as "unionBase" left outer join (select "root".pk as pk, "root".fk as fk, \'2018-01-01\' as "k_businessDate" from X0 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "vx2_0" on ("unionBase".fk_0 = "vx2_0".pk or "unionBase".fk_1 = "vx2_0".pk) left outer join (select "unionalias_2".pk as pk, "unionalias_2"."Z1pk_Z2pk" as "Z1pk_Z2pk" from (select "root".from_z as "from_z_0", "root".thru_z as "thru_z_0", null as "from_z_1", null as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z1 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\' UNION ALL select null as "from_z_0", null as "thru_z_0", "root".from_z as "from_z_1", "root".thru_z as "thru_z_1", "root".pk as pk, "root".pk as "Z1pk_Z2pk" from Z2 as "root" where "root".from_z <= DATE\'2018-01-01\' and "root".thru_z > DATE\'2018-01-01\') as "unionalias_2" where (coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1") <= DATE\'2018-01-01\' and coalesce("unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") > DATE\'2018-01-01\') or coalesce("unionalias_2"."from_z_0", "unionalias_2"."from_z_1", "unionalias_2"."thru_z_0", "unionalias_2"."thru_z_1") is null) as "unionalias_1" on ("vx2_0".fk = "unionalias_1".pk)', + $result->sqlRemoveFormatting() + ); } ###Pure diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/datePeriods.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/datePeriods.pure index ca5c4803d9a..a8680f62cbf 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/datePeriods.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/datePeriods.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::tests::groupBy::datePeriods::domain::*; import meta::relational::tests::groupBy::datePeriods::mapping::*; import meta::relational::tests::groupBy::datePeriods::store::*; @@ -58,18 +59,28 @@ function <> meta::relational::tests::groupBy::date 'OrgName2,1001,300000.0,0.0\n' + 'OrgName1,1002,200000.0,0.0\n', $tds->toCSV()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', - $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc',$result->sqlRemoveFormatting(1)); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + $result->sqlRemoveFormatting(1) + ); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', - meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); } -function <> meta::relational::tests::groupBy::datePeriods::testGroupBy_noDatePath():Boolean[1] +// Duplicate tests: plan generation static analysis cannot infer that reportEndDate.date will be a strictdate +function <> meta::relational::tests::groupBy::datePeriods::testInFlowGroupBy_noDatePath():Boolean[1] { - let fn = {| let startDate = getReportingStartDate(); let endDate = getReportingEndDate(); @@ -91,7 +102,6 @@ function <> meta::relational::tests::groupBy::datePeriods::testGroupB ->sort([desc('Sales Division'), desc('Income Function')]); }; - let result = execute($fn,myMapping,testRuntime(), meta::relational::extension::relationalExtensions()); let tds = $result.values; @@ -100,13 +110,74 @@ function <> meta::relational::tests::groupBy::datePeriods::testGroupB 'OrgName2,1001,300000.0,0.0\n' + 'OrgName1,1002,200000.0,0.0\n', $tds->toCSV()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', - $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); + + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + $result->sqlRemoveFormatting(1) + ); + + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); +} + +function <> meta::relational::tests::groupBy::datePeriods::testPlanGroupBy_noDatePath():Boolean[1] +{ + let fn = {| + let startDate = getReportingStartDate(); + let endDate = getReportingEndDate(); + let reportEndDate = FiscalCalendarDate.all()->filter(d | $d.date == $endDate)->toOne(); + + SalesCredit.all() + ->filter(gc | $gc.tradeDate.date > $startDate && ($gc.tradeDate.date <= $reportEndDate.date)) + ->groupBy([ + #/SalesCredit/salesDivision/name#, + #/SalesCredit/incomeFunction/code# + ], + [ + agg(s| ytd($s, #/SalesCredit/grossValue#, #/SalesCredit/tradeDate#, $reportEndDate), r|$r->sum()), + agg(s| wtd($s, #/SalesCredit/grossValue#, #/SalesCredit/tradeDate#, $reportEndDate), r|$r->sum()) + ] + , + ['Sales Division', 'Income Function', 'YTD Gross Credits', 'WTD Gross Credits'] + ) + ->sort([desc('Sales Division'), desc('Income Function')]); + }; + + let result = execute($fn,myMapping,testRuntime(), meta::relational::extension::relationalExtensions()); + let tds = $result.values; - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc',$result->sqlRemoveFormatting(1)); + assertEquals('Sales Division,Income Function,YTD Gross Credits,WTD Gross Credits\n' + + 'OrgName2,1002,100000.0,100000.0\n' + + 'OrgName2,1001,300000.0,0.0\n' + + 'OrgName1,1002,200000.0,0.0\n', $tds->toCSV()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', - meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()));} + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); + + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= TIMESTAMP\'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + $result->sqlRemoveFormatting(1) + ); + + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); +} function <> meta::relational::tests::groupBy::datePeriods::testGroupByWithFilterFunction_noDatePath():Boolean[1] { @@ -141,14 +212,23 @@ function <> meta::relational::tests::groupBy::datePeriods::testGroupB 'OrgName2,1001,300000.0,0.0\n' + 'OrgName1,1002,200000.0,0.0\n', $tds->toCSV()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', - $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', - $result->sqlRemoveFormatting(1)); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + $result->sqlRemoveFormatting(1) + ); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', - meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); } // Alloy exclusion reason: 15. Variables types should be inferred Encoding doesn't currently support generics (issue if the variable if of type Path for example) @@ -187,14 +267,23 @@ function <> meta::relational::tests::groupBy::date 'OrgName2,1001,300000.0,0.0\n' + 'OrgName1,1002,200000.0,0.0\n', $tds->toCSV()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', - $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', - $result->sqlRemoveFormatting(1)); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + $result->sqlRemoveFormatting(1) + ); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', - meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); } function meta::relational::tests::groupBy::datePeriods::dateFilter(gc:SalesCredit[1], startDate:Date[1], endDate:Date[1]):Boolean[1] @@ -231,13 +320,23 @@ function <> meta::relational::tests::groupBy::date let result = execute($fn,myMapping,testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', - $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function"', $result->sqlRemoveFormatting(1)); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function"', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function"', + $result->sqlRemoveFormatting(1) + ); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', - meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); } // Alloy exclusion reason: 16. Alloy doesn't support platform functions @@ -267,13 +366,23 @@ function <> meta::relational::tests::groupBy::date let result = execute($fn,myMapping,testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', - $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function"', $result->sqlRemoveFormatting(1)); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function"', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function"', + $result->sqlRemoveFormatting(1) + ); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', - meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); } // Alloy exclusion reason: 15. Variables types should be inferred Encoding doesn't currently support generics (issue if the variable if of type Path for example) @@ -306,14 +415,23 @@ function <> meta::relational::tests::groupBy::date let result = execute($fn,myMapping,testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', - $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'', + $result->sqlRemoveFormatting(0) + ); - - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function"',$result->sqlRemoveFormatting(1)); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else 0.0 end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else 0.0 end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function"', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum(case when "calendar_0"."fiscal day" <= 37 then "root".credits else CAST(0.0 AS FLOAT) end) as "YTD Gross Credits", sum(case when ("calendar_0"."fiscal week" = 9 and "calendar_0"."fiscal day of week" <= 3) then "root".credits else CAST(0.0 AS FLOAT) end) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function"', + $result->sqlRemoveFormatting(1) + ); - assertEquals('select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', - meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions())); + assertEqualsH2Compatible( + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = \'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + 'select "root"."date" as "pk_0", "root"."calendar name" as "pk_1", "root"."date" as "date", "root"."fiscal week start" as "weekStart", "root"."fiscal week end" as "weekEnd", "root"."fiscal day" as "day", "root"."fiscal week" as "week", "root"."fiscal day of week" as "dayOfWeekNumber", "root"."fiscal year end" as "yearEnd", "root"."fiscal year start" as "yearStart" from calendar as "root" where "root"."date" = DATE\'2015-02-25\'\nWarning: Results only shown for first relational query. Other SQL statements could not be computed because they require results from the execution of the previous expression.', + meta::relational::functions::sqlstring::toSQLString($fn, myMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()) + ); } function meta::relational::tests::groupBy::datePeriods::filterReportDates(x:T[1], start:Date[1], end:Date[1], path:Function<{T[1]->Date[0..1]}>[1]):Boolean[1] @@ -358,12 +476,16 @@ function <> meta::relational::tests::groupBy::date 'OrgName2,1001,300000.0,0.0\n' + 'OrgName1,1002,200000.0,0.0\n', $tds->toCSV()); - assertEquals('select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum((case when "calendar_0"."fiscal day" <= 37 then 1.0 else 0.0 end * "root".credits)) as "YTD Gross Credits", sum((case when (week("calendar_0"."date") = week(\'2015-02-25\') and DAY_OF_WEEK("calendar_0"."date") <= DAY_OF_WEEK(\'2015-02-25\')) then 1.0 else 0.0 end * "root".credits)) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc',$result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum((case when "calendar_0"."fiscal day" <= 37 then 1.0 else 0.0 end * "root".credits)) as "YTD Gross Credits", sum((case when (week("calendar_0"."date") = week(\'2015-02-25\') and DAY_OF_WEEK("calendar_0"."date") <= DAY_OF_WEEK(\'2015-02-25\')) then 1.0 else 0.0 end * "root".credits)) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > \'2015-02-01\' and "calendar_0"."date" <= \'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + 'select "org_chart_entity_0".name as "Sales Division", "income_function_0".code as "Income Function", sum((case when "calendar_0"."fiscal day" <= 37 then CAST(1.0 AS FLOAT) else CAST(0.0 AS FLOAT) end * "root".credits)) as "YTD Gross Credits", sum((case when (week("calendar_0"."date") = week(DATE\'2015-02-25\') and DAY_OF_WEEK("calendar_0"."date") <= DAY_OF_WEEK(DATE\'2015-02-25\')) then CAST(1.0 AS FLOAT) else CAST(0.0 AS FLOAT) end * "root".credits)) as "WTD Gross Credits" from SALES_GCS as "root" left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) left outer join INCOME_FUNCTION as "income_function_0" on ("root".if_code = "income_function_0".code) left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") where ("calendar_0"."date" > DATE\'2015-02-01\' and "calendar_0"."date" <= DATE\'2015-02-25\') group by "Sales Division","Income Function" order by "Sales Division" desc,"Income Function" desc', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::groupBy::datePeriods::testDayOfWeek(): Boolean[1] { - let result = execute(| let startDate = mostRecentDayOfWeek(%2022-02-25, DayOfWeek.Monday); + let result = execute(| let startDate = mostRecentDayOfWeek(%2022-02-25, DayOfWeek.Monday)->cast(@StrictDate); let endDate = %2022-03-25; let datePath = #/meta::relational::tests::groupBy::datePeriods::domain::SalesCredit/tradeDate/date#; meta::relational::tests::groupBy::datePeriods::domain::SalesCredit.all() @@ -373,7 +495,11 @@ function <> meta::relational::tests::groupBy::datePeriods::testDayOfW testRuntime(), meta::relational::extension::relationalExtensions()); - assertEquals('select "org_chart_entity_0".name as "name" from SALES_GCS as "root" left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) where ("calendar_0"."date" > \'2022-02-21\' and "calendar_0"."date" <= \'2022-03-25\')', $result->sqlRemoveFormatting(0)); + assertEqualsH2Compatible( + 'select "org_chart_entity_0".name as "name" from SALES_GCS as "root" left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) where ("calendar_0"."date" > \'2022-02-21\' and "calendar_0"."date" <= \'2022-03-25\')', + 'select "org_chart_entity_0".name as "name" from SALES_GCS as "root" left outer join calendar as "calendar_0" on ("root".tradeDate = "calendar_0"."date") left outer join ORG_CHART_ENTITY as "org_chart_entity_0" on ("root".division_id = "org_chart_entity_0".oe_id) where ("calendar_0"."date" > DATE\'2022-02-21\' and "calendar_0"."date" <= DATE\'2022-03-25\')', + $result->sqlRemoveFormatting(0) + ); } function meta::relational::tests::groupBy::datePeriods::ytd(value:Float[1], reportEndDate:FiscalCalendarDate[1], elementBusinessDate:FiscalCalendarDate[1]):Float[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testQualifier.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testQualifier.pure index 62a0724285c..ab53c69731d 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testQualifier.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testQualifier.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; import meta::relational::tests::model::simple::*; @@ -63,7 +64,11 @@ function <> meta::relational::tests::query::qualifier::testExistsWith { let result = execute(|Trade.all()->filter(t|$t.eventsByDate(%2014-12-02)->exists(e|$e.eventType == 'New')), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result.values, 0); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) left outer join (select distinct "tradeeventtable_2".trade_id from tradeEventTable as "tradeeventtable_2" where "tradeeventtable_2".eventDate = \'2014-12-02\' and "tradeeventtable_2".eventType = \'New\') as "tradeeventtable_1" on ("root".ID = "tradeeventtable_1".trade_id) where "tradeeventtable_1".trade_id is not null', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) left outer join (select distinct "tradeeventtable_2".trade_id from tradeEventTable as "tradeeventtable_2" where "tradeeventtable_2".eventDate = \'2014-12-02\' and "tradeeventtable_2".eventType = \'New\') as "tradeeventtable_1" on ("root".ID = "tradeeventtable_1".trade_id) where "tradeeventtable_1".trade_id is not null', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) left outer join (select distinct "tradeeventtable_2".trade_id from tradeEventTable as "tradeeventtable_2" where "tradeeventtable_2".eventDate = DATE\'2014-12-02\' and "tradeeventtable_2".eventType = \'New\') as "tradeeventtable_1" on ("root".ID = "tradeeventtable_1".trade_id) where "tradeeventtable_1".trade_id is not null', + $result->sqlRemoveFormatting() + ); let result2 = execute(|Trade.all()->filter(t|$t.eventsByDate(%2014-12-01)->exists(e|$e.eventType == 'New')), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSize($result2.values, 1); diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testView.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testView.pure index 39c413cf630..a54a34a8ddd 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testView.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testView.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::tests::query::view::*; import meta::relational::metamodel::execute::*; @@ -51,7 +52,11 @@ function <> meta::relational::tests::query::view::testAllWithJoinToVi { let result = execute(|Order.all(), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements(['1,false', '2,false', '3,false','4,false'], $result.values->map(o|[$o.id, $o.zeroPnl]->makeString(','))); - assertEquals('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID)', $result->sqlRemoveFormatting()); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID)', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".orderDate as "date", "root".settlementDateTime as "settlementDateTime", "orderpnlview_0".pnl as "pnl", cast(case when "orderpnlview_0".pnl = 0 then \'true\' else \'false\' end as boolean) as "zeroPnl" from orderTable as "root" left outer join (select distinct "root".ORDER_ID as ORDER_ID, "root".pnl as pnl, "accounttable_0".ID as accountId, "salespersontable_0".NAME as supportContact, "salespersontable_0".PERSON_ID as supportContactId from orderPnlTable as "root" left outer join orderTable as "ordertable_1" on ("root".ORDER_ID = "ordertable_1".ID) left outer join accountTable as "accounttable_0" on ("ordertable_1".accountID = "accounttable_0".ID) left outer join salesPersonTable as "salespersontable_0" on ("ordertable_1".accountID = "salespersontable_0".ACCOUNT_ID) where "root".pnl > 0) as "orderpnlview_0" on ("orderpnlview_0".ORDER_ID = "root".ID)', + $result->sqlRemoveFormatting() + ); } // Alloy exclusion reason: 4. Use getter relational protocol diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testWithFunction.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testWithFunction.pure index 4ba7b3a2f94..5f5044a308d 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testWithFunction.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/tests/query/testWithFunction.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::relational::functions::asserts::*; import meta::relational::mapping::*; import meta::relational::runtime::*; @@ -296,7 +297,11 @@ function <> meta::relational::tests::query::function::exp::testFilter { let result = execute(|Trade.all()->filter(t | $t.id->exp() < 2.719), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([1], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where exp("root".ID) < 2.719', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where exp("root".ID) < 2.719', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where exp("root".ID) < CAST(2.719 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::log::testFilterUsingLogFunction():Boolean[1] @@ -317,42 +322,66 @@ function <> meta::relational::tests::query::function::sin::testFilter { let result = execute(|Trade.all()->filter(t | $t.id->sin() < 0.5), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([3, 4, 5, 6, 9, 10, 11], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where sin("root".ID) < 0.5', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where sin("root".ID) < 0.5', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where sin("root".ID) < CAST(0.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::cos::testFilterUsingCosFunction():Boolean[1] { let result = execute(|Trade.all()->filter(t | $t.id->cos() < 0.5), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([2, 3, 4, 5, 8, 9, 10, 11], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where cos("root".ID) < 0.5', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where cos("root".ID) < 0.5', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where cos("root".ID) < CAST(0.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::cos::testFilterUsingCotFunction():Boolean[1] { let result = execute(|Trade.all()->filter(t | $t.id->cot() < 0.5), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([2, 3, 5, 6, 8, 9, 11], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where cot("root".ID) < 0.5', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where cot("root".ID) < 0.5', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where cot("root".ID) < CAST(0.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::tan::testFilterUsingTanFunction():Boolean[1] { let result = execute(|Trade.all()->filter(t | $t.id->tan() < 0.5), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([2, 3, 5, 6, 8, 9, 11], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where tan("root".ID) < 0.5', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where tan("root".ID) < 0.5', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where tan("root".ID) < CAST(0.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::asin::testFilterUsingArcSinFunction():Boolean[1] { let result = execute(|Trade.all()->filter(t | $t.id->divide(10)->asin() < 0.5), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([1, 2, 3, 4], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where asin(((1.0 * "root".ID) / 10)) < 0.5', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where asin(((1.0 * "root".ID) / 10)) < 0.5', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where asin(((1.0 * "root".ID) / 10)) < CAST(0.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::acos::testFilterUsingArcCosFunction():Boolean[1] { let result = execute(|Trade.all()->filter(t | $t.id->divide(10)->acos() < 0.5), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([9, 10], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where acos(((1.0 * "root".ID) / 10)) < 0.5', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where acos(((1.0 * "root".ID) / 10)) < 0.5', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where acos(((1.0 * "root".ID) / 10)) < CAST(0.5 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::atan::testFilterUsingArcTanFunction():Boolean[1] @@ -366,7 +395,11 @@ function <> meta::relational::tests::query::function::atan2::testFilt { let result = execute(|Trade.all()->filter(t | atan2($t.id, $t.quantity) < 0.2), simpleRelationalMapping, testRuntime(), meta::relational::extension::relationalExtensions()); assertSameElements([1, 2, 4, 5, 7, 9], $result.values.id); - assertSameSQL('select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where atan2("root".ID,"root".quantity) < 0.2', $result); + assertEqualsH2Compatible( + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where atan2("root".ID,"root".quantity) < 0.2', + 'select "root".ID as "pk_0", "root".ID as "id", "root".quantity as "quantity", "root".tradeDate as "date", "root".settlementDateTime as "settlementDateTime", "tradeeventviewmaxtradeeventdate_0".maxTradeEventDate as "latestEventDate" from tradeTable as "root" left outer join (select "root".trade_id as trade_id, max("root".eventDate) as maxTradeEventDate from tradeEventTable as "root" group by "root".trade_id) as "tradeeventviewmaxtradeeventdate_0" on ("root".ID = "tradeeventviewmaxtradeeventdate_0".trade_id) where atan2("root".ID,"root".quantity) < CAST(0.2 AS FLOAT)', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::query::function::sqrt::testFilterUsingSqrtFunction():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/transform/fromPure/tests/testToSQLString.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/transform/fromPure/tests/testToSQLString.pure index 9561c6f25bb..d34d7f081bb 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/transform/fromPure/tests/testToSQLString.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/transform/fromPure/tests/testToSQLString.pure @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; import meta::pure::functions::hash::*; import meta::relational::tests::functions::sqlstring::*; import meta::pure::mapping::*; @@ -163,7 +164,11 @@ function <> meta::relational::tests::functions::sqlstring::testToSQLS ->project([t|$t.account.name, t|$t.quantity], ['accountName', 'quantity']); }; let s = toSQLString($fn, meta::relational::tests::simpleRelationalMapping, meta::relational::runtime::DatabaseType.H2, meta::relational::extension::relationalExtensions()); - assertEquals('select "accountTable_d#4_d_m1".name as "accountName", "root".quantity as "quantity" from tradeTable as "root" left outer join accountTable as "accountTable_d#4_d_m1" on ("root".accountID = "accountTable_d#4_d_m1".ID) where "root".tradeDate <= \'2015-02-01\'', $s); + assertEqualsH2Compatible( + 'select "accountTable_d#4_d_m1".name as "accountName", "root".quantity as "quantity" from tradeTable as "root" left outer join accountTable as "accountTable_d#4_d_m1" on ("root".accountID = "accountTable_d#4_d_m1".ID) where "root".tradeDate <= \'2015-02-01\'', + 'select "accountTable_d#4_d_m1".name as "accountName", "root".quantity as "quantity" from tradeTable as "root" left outer join accountTable as "accountTable_d#4_d_m1" on ("root".accountID = "accountTable_d#4_d_m1".ID) where "root".tradeDate <= DATE\'2015-02-01\'', + $s->sqlRemoveFormatting() + ); } function meta::relational::tests::functions::sqlstring::filterReportDates(x:T[1], end:Date[1], path:Function<{T[1]->Date[0..1]}>[1]):Boolean[1] @@ -428,7 +433,11 @@ function <> meta::relational::tests::functions::sqlstring::testSqlGen ], ['a']), simpleRelationalMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()); - assertEquals('select dateadd(SECOND, 86400, \'2011-12-30\') as "a" from personTable as "root"', $result); + assertEqualsH2Compatible( + 'select dateadd(SECOND, 86400, \'2011-12-30\') as "a" from personTable as "root"', + 'select dateadd(SECOND, 86400, DATE\'2011-12-30\') as "a" from personTable as "root"', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::functions::sqlstring::testSqlGenerationForAdjustStrictDateUsageInFiltersForH2():Boolean[1] @@ -438,7 +447,11 @@ function <> meta::relational::tests::functions::sqlstring::testSqlGen ], ['a']), simpleRelationalMapping, DatabaseType.H2, meta::relational::extension::relationalExtensions()); - assertEquals('select \'a\' as "a" from tradeTable as "root" where dateadd(SECOND, 86400, \'2011-12-30\') > \'2011-12-30\'', $result); + assertEqualsH2Compatible( + 'select \'a\' as "a" from tradeTable as "root" where dateadd(SECOND, 86400, \'2011-12-30\') > \'2011-12-30\'', + 'select \'a\' as "a" from tradeTable as "root" where dateadd(SECOND, 86400, DATE\'2011-12-30\') > DATE\'2011-12-30\'', + $result->sqlRemoveFormatting() + ); } function <> meta::relational::tests::functions::sqlstring::testSqlGenerationForDatePartForH2():Boolean[1] diff --git a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/validation/tests/testValidationWithMilestoning.pure b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/validation/tests/testValidationWithMilestoning.pure index b58431c81ff..bf63e11c9d1 100644 --- a/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/validation/tests/testValidationWithMilestoning.pure +++ b/legend-engine-xts-relationalStore/legend-engine-xt-relationalStore-generation/legend-engine-xt-relationalStore-pure/src/main/resources/core_relational/relational/validation/tests/testValidationWithMilestoning.pure @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +import meta::relational::functions::sqlQueryToString::h2::*; +import meta::relational::mapping::*; import meta::relational::functions::asserts::*; import meta::pure::runtime::*; import meta::relational::validation::tests::milestoning::*; @@ -51,38 +53,62 @@ function <> meta::relational::validation::tests::milestoning function <> meta::relational::validation::tests::milestoning::testAggregationOnRootClass():Boolean[1] { let validation = validate({|meta::relational::validation::tests::milestoning::ProductClassification.all(%2019-09-09)},MilestoneMappingWithDynaFunction,meta::relational::tests::testRuntime(),['joinStringsConstraint'], meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'joinStringsConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".type as "type" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where not (char_length("root".type) + char_length("root".type_description)) > 10 and "root".snapshotDate = \'2019-09-09\'', $validation); + assertEqualsH2Compatible( + 'select \'joinStringsConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".type as "type" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where not (char_length("root".type) + char_length("root".type_description)) > 10 and "root".snapshotDate = \'2019-09-09\'', + 'select \'joinStringsConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".type as "type" from ProductClassificationTableWithBusinessSnapshotMilestoning as "root" where not (char_length("root".type) + char_length("root".type_description)) > 10 and "root".snapshotDate = DATE\'2019-09-09\'', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryWithMilestoningAndAggregationAll():Boolean[1] { let validation = validate({|OrderWithAggregationConstraint.all()}, MilestoneMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum("producttablewithbusinesssnapshotmilestoning_0".id) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_0".id > 100 or "producttablewithbusinesssnapshotmilestoning_0".id = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum("producttablewithbusinesssnapshotmilestoning_1".id) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_1".id < 100 or "producttablewithbusinesssnapshotmilestoning_1".id = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1 UNION ALL select \'aggConstraint2\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_6".id as id, count(*) as aggCol from OrderTable as "ordertable_6" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_2" on ("ordertable_6".prodFk = "producttablewithbusinesssnapshotmilestoning_2".id and "producttablewithbusinesssnapshotmilestoning_2".snapshotDate = \'2018-09-09\') group by "ordertable_6".id) as "ordertable_5" on ("root".id = "ordertable_5".id) where not "ordertable_5".aggCol > 1) as "unionalias_0"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum("producttablewithbusinesssnapshotmilestoning_0".id) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_0".id > 100 or "producttablewithbusinesssnapshotmilestoning_0".id = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum("producttablewithbusinesssnapshotmilestoning_1".id) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_1".id < 100 or "producttablewithbusinesssnapshotmilestoning_1".id = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1 UNION ALL select \'aggConstraint2\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_6".id as id, count(*) as aggCol from OrderTable as "ordertable_6" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_2" on ("ordertable_6".prodFk = "producttablewithbusinesssnapshotmilestoning_2".id and "producttablewithbusinesssnapshotmilestoning_2".snapshotDate = \'2018-09-09\') group by "ordertable_6".id) as "ordertable_5" on ("root".id = "ordertable_5".id) where not "ordertable_5".aggCol > 1) as "unionalias_0"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum("producttablewithbusinesssnapshotmilestoning_0".id) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_0".id > 100 or "producttablewithbusinesssnapshotmilestoning_0".id = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum("producttablewithbusinesssnapshotmilestoning_1".id) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = DATE\'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_1".id < 100 or "producttablewithbusinesssnapshotmilestoning_1".id = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1 UNION ALL select \'aggConstraint2\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_6".id as id, count(*) as aggCol from OrderTable as "ordertable_6" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_2" on ("ordertable_6".prodFk = "producttablewithbusinesssnapshotmilestoning_2".id and "producttablewithbusinesssnapshotmilestoning_2".snapshotDate = DATE\'2018-09-09\') group by "ordertable_6".id) as "ordertable_5" on ("root".id = "ordertable_5".id) where not "ordertable_5".aggCol > 1) as "unionalias_0"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryWithMilestoningAndAggregationSingle():Boolean[1] { let validation = validate({|OrderWithAggregationConstraint.all()}, MilestoneMapping, meta::relational::tests::testRuntime(),['aggConstraint'], meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum("producttablewithbusinesssnapshotmilestoning_0".id) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_0".id > 100 or "producttablewithbusinesssnapshotmilestoning_0".id = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum("producttablewithbusinesssnapshotmilestoning_1".id) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_1".id < 100 or "producttablewithbusinesssnapshotmilestoning_1".id = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1', $validation); + assertEqualsH2Compatible( + 'select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum("producttablewithbusinesssnapshotmilestoning_0".id) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_0".id > 100 or "producttablewithbusinesssnapshotmilestoning_0".id = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum("producttablewithbusinesssnapshotmilestoning_1".id) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_1".id < 100 or "producttablewithbusinesssnapshotmilestoning_1".id = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1', + 'select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum("producttablewithbusinesssnapshotmilestoning_0".id) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_0".id > 100 or "producttablewithbusinesssnapshotmilestoning_0".id = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum("producttablewithbusinesssnapshotmilestoning_1".id) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = DATE\'2018-09-09\' and ("producttablewithbusinesssnapshotmilestoning_1".id < 100 or "producttablewithbusinesssnapshotmilestoning_1".id = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryWithMilestoningAndAggregationSingleAndNestedDynaFunction():Boolean[1] { let validation = validate({|OrderWithAggregationConstraint.all()}, MilestoneMappingWithDynaFunction, meta::relational::tests::testRuntime(),['aggConstraint'], meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum(("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id)) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2018-09-09\' and (("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id) > 100 or ("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id) = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum(("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id)) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2018-09-09\' and (("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id) < 100 or ("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id) = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1', $validation); + assertEqualsH2Compatible( + 'select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum(("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id)) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2018-09-09\' and (("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id) > 100 or ("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id) = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum(("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id)) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2018-09-09\' and (("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id) < 100 or ("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id) = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1', + 'select \'aggConstraint\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from OrderTable as "root" left outer join (select "ordertable_2".id as id, sum(("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id)) as aggCol from OrderTable as "ordertable_2" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_0" on ("ordertable_2".prodFk = "producttablewithbusinesssnapshotmilestoning_0".id and "producttablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2018-09-09\' and (("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id) > 100 or ("producttablewithbusinesssnapshotmilestoning_0".id + "producttablewithbusinesssnapshotmilestoning_0".id) = -1)) group by "ordertable_2".id) as "ordertable_1" on ("root".id = "ordertable_1".id) left outer join (select "ordertable_4".id as id, sum(("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id)) as aggCol from OrderTable as "ordertable_4" left outer join ProductTableWithBusinessSnapshotMilestoning as "producttablewithbusinesssnapshotmilestoning_1" on ("ordertable_4".prodFk = "producttablewithbusinesssnapshotmilestoning_1".id and "producttablewithbusinesssnapshotmilestoning_1".snapshotDate = DATE\'2018-09-09\' and (("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id) < 100 or ("producttablewithbusinesssnapshotmilestoning_1".id + "producttablewithbusinesssnapshotmilestoning_1".id) = -10)) group by "ordertable_4".id) as "ordertable_3" on ("root".id = "ordertable_3".id) where not abs(("ordertable_1".aggCol - "ordertable_3".aggCol)) > 1', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryWithMilestoning():Boolean[1] { let validation = validate({|Product.all(%2010-10-10)}, MilestoneMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = DATE\'2010-10-10\') as "unionalias_0"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryWithMilestoningWithVariable():Boolean[1] { let date = %2010-10-10; let validation = validate({|Product.all($date)}, MilestoneMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = DATE\'2010-10-10\') as "unionalias_0"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryWithMilestoningWithMultipleVariables():Boolean[1] @@ -90,7 +116,11 @@ function <> meta::relational::validation::tests::milestoning::testVal let date = %2010-10-10; let id = 45; let validation = validate({|Product.all($date)->filter(i | $i.id == $id)}, MilestoneMapping, meta::relational::tests::testRuntime(), meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".id = 45 and "root".snapshotDate = \'2010-10-10\' and not "root".id > 0 UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "root".id = 45 and "root".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\') as "unionalias_0"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".id = 45 and "root".snapshotDate = \'2010-10-10\' and not "root".id > 0 UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "root".id = 45 and "root".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\') as "unionalias_0"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".id = 45 and "root".snapshotDate = DATE\'2010-10-10\' and not "root".id > 0 UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-10\' and "root".id = 45 and "root".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\') as "unionalias_0"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryOpenVariableInCol():Boolean[1] @@ -98,7 +128,11 @@ function <> meta::relational::validation::tests::milestoning::testVal let date = %2010-10-10; let batch = 1; let validation = validate({|Product.all($date)}, [col(x|$x.id, 'id')], {t|$t->extend(col(x:TDSRow[1] | $batch->toOne(), 'Batch_ID'))}, MilestoneMapping, meta::relational::tests::testRuntime(), ^meta::relational::runtime::RelationalExecutionContext(), [], [], meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = DATE\'2010-10-10\') as "unionalias_0"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryOpenVariableInKeyExpression():Boolean[1] @@ -106,7 +140,11 @@ function <> meta::relational::validation::tests::milestoning::testVal let date = %2010-10-10; let batch = 1; let validation = validate({|Product.all($date)}, [col(x|$x.id, 'id')], {t|$t->extend(^BasicColumnSpecification(func=x:TDSRow[1] | $batch->toOne(), name='Batch_ID'))}, MilestoneMapping, meta::relational::tests::testRuntime(), ^meta::relational::runtime::RelationalExecutionContext(), [], [], meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = DATE\'2010-10-10\') as "unionalias_0"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryOpenVariableInAgg():Boolean[1] @@ -114,7 +152,11 @@ function <> meta::relational::validation::tests::milestoning::testVal let date = %2010-10-10; let count = 3; let validation = validate({|Product.all($date)}, [col(x|$x.id, 'id')], {t|$t->groupBy(['CONSTRAINT_ID'], agg('Sum', x|$x.getInteger('id') + $count, y|$y->sum()))}, MilestoneMapping, meta::relational::tests::testRuntime(), ^meta::relational::runtime::RelationalExecutionContext(), [], [], meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", sum(("unionalias_0"."id" + 3)) as "Sum" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0" group by "CONSTRAINT_ID"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", sum(("unionalias_0"."id" + 3)) as "Sum" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0" group by "CONSTRAINT_ID"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", sum(("unionalias_0"."id" + 3)) as "Sum" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = DATE\'2010-10-10\') as "unionalias_0" group by "CONSTRAINT_ID"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryOpenVariableInColAndAgg():Boolean[1] @@ -123,7 +165,11 @@ function <> meta::relational::validation::tests::milestoning::testVal let batch = 1; let count = 3; let validation = validate({|Product.all($date)}, [col(x|$x.id, 'id')], {t|$t->extend(col(x:TDSRow[1] | $batch->toOne() + $batch->toOne(), 'Batch_ID'))->groupBy(['CONSTRAINT_ID', 'Batch_ID'], agg('Sum', x|$x.getInteger('id') + $count, y|$y->sum()))}, MilestoneMapping, meta::relational::tests::testRuntime(), ^meta::relational::runtime::RelationalExecutionContext(), [], [], meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", (1 + 1) as "Batch_ID", sum(("unionalias_0"."id" + 3)) as "Sum" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0" group by "CONSTRAINT_ID","Batch_ID"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", (1 + 1) as "Batch_ID", sum(("unionalias_0"."id" + 3)) as "Sum" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0" group by "CONSTRAINT_ID","Batch_ID"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", (1 + 1) as "Batch_ID", sum(("unionalias_0"."id" + 3)) as "Sum" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" where not "root".id > 0 and "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type) where "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_0".type = \'\' and "root".snapshotDate = DATE\'2010-10-10\') as "unionalias_0" group by "CONSTRAINT_ID","Batch_ID"', + $validation->sqlRemoveFormatting() + ); } @@ -133,7 +179,11 @@ function <> meta::relational::validation::tests::milestoning::testVal let date2 = %2010-10-11; let batch = 1; let validation = validate({|Product.all($date)}, [col(x|$x.id, 'id'), col(x|$x.classification($date2).type, 'class')], {t|$t->extend(col(x:TDSRow[1] | $batch->toOne(), 'Batch_ID'))}, MilestoneMapping, meta::relational::tests::testRuntime(), ^meta::relational::runtime::RelationalExecutionContext(), [], [], meta::relational::extension::relationalExtensions()); - assertSameSQL('select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", "unionalias_0"."class" as "class", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id", "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "class" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-11\') where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id", "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "class" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_1" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_1".type) left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-11\') where "productclassificationtablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_1".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', $validation); + assertEqualsH2Compatible( + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", "unionalias_0"."class" as "class", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id", "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "class" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-11\') where not "root".id > 0 and "root".snapshotDate = \'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id", "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "class" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_1" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_1".type) left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = \'2010-10-11\') where "productclassificationtablewithbusinesssnapshotmilestoning_1".snapshotDate = \'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_1".type = \'\' and "root".snapshotDate = \'2010-10-10\') as "unionalias_0"', + 'select "unionalias_0"."CONSTRAINT_ID" as "CONSTRAINT_ID", "unionalias_0"."ENFORCEMENT_LEVEL" as "ENFORCEMENT_LEVEL", "unionalias_0"."MESSAGE" as "MESSAGE", "unionalias_0"."id" as "id", "unionalias_0"."class" as "class", 1 as "Batch_ID" from (select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id", "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "class" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-11\') where not "root".id > 0 and "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select \'classificationTypeStrNotEMpty\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "root".id as "id", "productclassificationtablewithbusinesssnapshotmilestoning_0".type as "class" from ProductTableWithBusinessSnapshotMilestoning as "root" left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_1" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_1".type) left outer join ProductClassificationTableWithBusinessSnapshotMilestoning as "productclassificationtablewithbusinesssnapshotmilestoning_0" on ("root".type = "productclassificationtablewithbusinesssnapshotmilestoning_0".type and "productclassificationtablewithbusinesssnapshotmilestoning_0".snapshotDate = DATE\'2010-10-11\') where "productclassificationtablewithbusinesssnapshotmilestoning_1".snapshotDate = DATE\'2010-10-10\' and "productclassificationtablewithbusinesssnapshotmilestoning_1".type = \'\' and "root".snapshotDate = DATE\'2010-10-10\') as "unionalias_0"', + $validation->sqlRemoveFormatting() + ); } function <> meta::relational::validation::tests::milestoning::testValidateQueryWithUnion():Boolean[1] @@ -142,7 +192,11 @@ function <> meta::relational::validation::tests::milestoning::testVal let date2 = %2010-10-11; let batch = 1; let validation = validate({|Product.all($date)}, [col(x|$x.id, 'id')], {t|$t->extend(col(x:TDSRow[1] | $batch->toOne(), 'Batch_ID'))}, MilestoneUnionMapping, meta::relational::tests::testRuntime(), ^meta::relational::runtime::RelationalExecutionContext(), ['idNotNegative'], [], meta::relational::extension::relationalExtensions()); - assertSameSQL('select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id", 1 as "Batch_ID" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid", "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2010-10-10\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid", null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2010-10-10\') as "unionBase" where not "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" > 0', $validation); + assertEqualsH2Compatible( + 'select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id", 1 as "Batch_ID" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid", "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2010-10-10\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid", null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = \'2010-10-10\') as "unionBase" where not "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" > 0', + 'select \'idNotNegative\' as "CONSTRAINT_ID", \'Error\' as "ENFORCEMENT_LEVEL", \'\' as "MESSAGE", "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" as "id", 1 as "Batch_ID" from (select "root".snapshotDate as "snapshotDate_0", null as "snapshotDate_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid", "root".id as "pk_0_0", null as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2010-10-10\' UNION ALL select null as "snapshotDate_0", "root".snapshotDate as "snapshotDate_1", "root".id as "ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid", null as "pk_0_0", "root".id as "pk_0_1" from ProductTableWithBusinessSnapshotMilestoning as "root" where "root".snapshotDate = DATE\'2010-10-10\') as "unionBase" where not "unionBase"."ProductTableWithBusinessSnapshotMilestoningid_ProductTableWithBusinessSnapshotMilestoningid" > 0', + $validation->sqlRemoveFormatting() + ); } ###Mapping