Search in sources :

Example 1 with Property

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Property in project legend-engine by finos.

the class TestRelationalExecutor method testPlanWitGMTTimeZoneConversionForDateTimeQueryConstant.

@Test
public void testPlanWitGMTTimeZoneConversionForDateTimeQueryConstant() throws IOException {
    String planWithTz = getTemplatePlanWithNoTz().replace("%timeZone%", ",\"timeZone\": \"GMT\"").replace("%templateFunctions%", getFreeMarkerAlloyDateFunction());
    String plan = planWithTz.replace("%dateTimeParam%", "testDateTime = '2014-12-04 15:22:23.123456789'");
    SingleExecutionPlan executionPlan = objectMapper.readValue(plan, SingleExecutionPlan.class);
    RelationalResult result = (RelationalResult) executionPlan.rootExecutionNode.accept(new ExecutionNodeExecutor(null, new ExecutionState(Maps.mutable.empty(), Lists.mutable.withAll(executionPlan.templateFunctions), Lists.mutable.with(new RelationalStoreExecutionState(new RelationalStoreState(serverPort))))));
    Assert.assertEquals("{\"builder\": {\"_type\":\"classBuilder\",\"mapping\":\"meta::relational::tests::milestoning::milestoningmap\",\"classMappings\":[{\"setImplementationId\":\"meta_relational_tests_milestoning_ProductSynonym\",\"properties\":[{\"property\":\"synonym\",\"type\":\"String\"},{\"property\":\"type\",\"type\":\"String\"},{\"property\":\"testDate\",\"type\":\"Date\"},{\"property\":\"testDateTime\",\"type\":\"DateTime\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}, \"activities\": [{\"_type\":\"relational\",\"sql\":\"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\\\".testDate as \\\"testDate\\\", \\\"root\\\".testDateTime as \\\"testDateTime\\\", \\\"root\\\".from_z as \\\"k_businessDate\\\" from ProductSynonymTable as \\\"root\\\" where \\\"root\\\".testDateTime = '2014-12-04 15:22:23.123456789'\"}], \"result\" : {\"columns\" : [\"pk_0\",\"pk_1\",\"pk_2\",\"synonym\",\"type\",\"testDate\",\"testDateTime\",\"k_businessDate\"], \"rows\" : [{\"values\": [\"GS-ModA\",\"GS-Mod-S1\",\"STOCK\",\"GS-Mod-S1\",\"STOCK\",\"2015-06-26\",\"2014-12-04T15:22:23.123456789+0000\",\"2015-08-26T00:00:00.000000000+0000\"]}]}}", result.flush(new RelationalResultToJsonDefaultSerializer(result)));
}
Also used : ExecutionState(org.finos.legend.engine.plan.execution.nodes.state.ExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) RelationalResultToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.stores.relational.serialization.RelationalResultToJsonDefaultSerializer) ExecutionNodeExecutor(org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor) RelationalStoreState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreState) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) Test(org.junit.Test)

Example 2 with Property

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Property in project legend-engine by finos.

the class TestRelationalExecutor method testPlanTimeZoneConversionForDateTimeQueryConstant.

@Test
public void testPlanTimeZoneConversionForDateTimeQueryConstant() throws IOException {
    String planWithTz = getTemplatePlanWithNoTz().replace("%timeZone%", ",\"timeZone\": \"US/Arizona\"").replace("%templateFunctions%", getFreeMarkerAlloyDateFunction());
    String plan = planWithTz.replace("%dateTimeParam%", "testDateTime = '2014-12-04 15:22:23.123456789'");
    SingleExecutionPlan executionPlan = objectMapper.readValue(plan, SingleExecutionPlan.class);
    RelationalResult result = (RelationalResult) executionPlan.rootExecutionNode.accept(new ExecutionNodeExecutor(null, new ExecutionState(Maps.mutable.empty(), Lists.mutable.withAll(executionPlan.templateFunctions), Lists.mutable.with(new RelationalStoreExecutionState(new RelationalStoreState(serverPort))))));
    Assert.assertEquals("{\"builder\": {\"_type\":\"classBuilder\",\"mapping\":\"meta::relational::tests::milestoning::milestoningmap\",\"classMappings\":[{\"setImplementationId\":\"meta_relational_tests_milestoning_ProductSynonym\",\"properties\":[{\"property\":\"synonym\",\"type\":\"String\"},{\"property\":\"type\",\"type\":\"String\"},{\"property\":\"testDate\",\"type\":\"Date\"},{\"property\":\"testDateTime\",\"type\":\"DateTime\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}, \"activities\": [{\"_type\":\"relational\",\"sql\":\"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\\\".testDate as \\\"testDate\\\", \\\"root\\\".testDateTime as \\\"testDateTime\\\", \\\"root\\\".from_z as \\\"k_businessDate\\\" from ProductSynonymTable as \\\"root\\\" where \\\"root\\\".testDateTime = '2014-12-04 15:22:23.123456789'\"}], \"result\" : {\"columns\" : [\"pk_0\",\"pk_1\",\"pk_2\",\"synonym\",\"type\",\"testDate\",\"testDateTime\",\"k_businessDate\"], \"rows\" : [{\"values\": [\"GS-ModA\",\"GS-Mod-S1\",\"STOCK\",\"GS-Mod-S1\",\"STOCK\",\"2015-06-26\",\"2014-12-04T22:22:23.123456789+0000\",\"2015-08-26T07:00:00.000000000+0000\"]}]}}", result.flush(new RelationalResultToJsonDefaultSerializer(result)));
}
Also used : ExecutionState(org.finos.legend.engine.plan.execution.nodes.state.ExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) RelationalResultToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.stores.relational.serialization.RelationalResultToJsonDefaultSerializer) ExecutionNodeExecutor(org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor) RelationalStoreState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreState) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) Test(org.junit.Test)

Example 3 with Property

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Property in project legend-engine by finos.

the class TestRelationalExecutor method testESTTimeZonePlanWithDateTimeAndMillisecondStringParameter.

@Test
public void testESTTimeZonePlanWithDateTimeAndMillisecondStringParameter() throws IOException {
    String connectionTimeZone = "US/Arizona";
    Assert.assertFalse("Expect " + connectionTimeZone + " never to be in DST", ZoneId.of(connectionTimeZone).getRules().isDaylightSavings(Instant.now()));
    MutableMap<String, Result> vars = Maps.mutable.empty();
    String gmtTestDateTimeParam = "2014-12-04T15:22:23.123";
    vars.put("dt", new ConstantResult(gmtTestDateTimeParam));
    String planWithTz = getTemplatePlanWithNoTz().replace("%timeZone%", ",\"timeZone\": \"" + connectionTimeZone + "\"").replace("%templateFunctions%", getFreeMarkerAlloyDateFunction()).replace("%dateTimeParam%", "testDateTime = '${GMTtoTZ( \\\"[" + connectionTimeZone + "]\\\" dt )}'");
    SingleExecutionPlan executionPlan = objectMapper.readValue(planWithTz, SingleExecutionPlan.class);
    RelationalResult result = (RelationalResult) executionPlan.rootExecutionNode.accept(new ExecutionNodeExecutor(null, new ExecutionState(vars, Lists.mutable.withAll(executionPlan.templateFunctions), Lists.mutable.with(new RelationalStoreExecutionState(new RelationalStoreState(serverPort))))));
    Assert.assertEquals("{\"builder\": {\"_type\":\"classBuilder\",\"mapping\":\"meta::relational::tests::milestoning::milestoningmap\",\"classMappings\":[{\"setImplementationId\":\"meta_relational_tests_milestoning_ProductSynonym\",\"properties\":[{\"property\":\"synonym\",\"type\":\"String\"},{\"property\":\"type\",\"type\":\"String\"},{\"property\":\"testDate\",\"type\":\"Date\"},{\"property\":\"testDateTime\",\"type\":\"DateTime\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}, \"activities\": [{\"_type\":\"relational\",\"sql\":\"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\\\".testDate as \\\"testDate\\\", \\\"root\\\".testDateTime as \\\"testDateTime\\\", \\\"root\\\".from_z as \\\"k_businessDate\\\" from ProductSynonymTable as \\\"root\\\" where \\\"root\\\".testDateTime = '2014-12-04T08:22:23.123'\"}], \"result\" : {\"columns\" : [\"pk_0\",\"pk_1\",\"pk_2\",\"synonym\",\"type\",\"testDate\",\"testDateTime\",\"k_businessDate\"], \"rows\" : [{\"values\": [\"GS-ModD\",\"GS-Mod-S1\",\"STOCK\",\"GS-Mod-S1\",\"STOCK\",\"2015-09-26\",\"2014-12-04T15:22:23.123000000+0000\",\"2015-08-27T06:00:00.000000000+0000\"]}]}}", result.flush(new RelationalResultToJsonDefaultSerializer(result)));
}
Also used : ExecutionState(org.finos.legend.engine.plan.execution.nodes.state.ExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) RelationalResultToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.stores.relational.serialization.RelationalResultToJsonDefaultSerializer) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) ExecutionNodeExecutor(org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor) RelationalStoreState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreState) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) Result(org.finos.legend.engine.plan.execution.result.Result) Test(org.junit.Test)

Example 4 with Property

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Property in project legend-engine by finos.

the class TestRelationalExecutor method testNonDSTTTimeZonePlanWithDateTimeStringParameterPlan.

@Test
public void testNonDSTTTimeZonePlanWithDateTimeStringParameterPlan() throws IOException {
    String connectionTimeZone = "US/Arizona";
    Assert.assertFalse("Expect " + connectionTimeZone + " never to be in DST", ZoneId.of(connectionTimeZone).getRules().isDaylightSavings(Instant.now()));
    MutableMap<String, Result> vars = Maps.mutable.empty();
    String gmtTestDateTimeParam = "2014-12-04T15:22:23";
    vars.put("dt", new ConstantResult(gmtTestDateTimeParam));
    String planWithTz = getTemplatePlanWithNoTz().replace("%timeZone%", ",\"timeZone\": \"" + connectionTimeZone + "\"").replace("%templateFunctions%", getFreeMarkerAlloyDateFunction()).replace("%dateTimeParam%", "testDateTime = '${GMTtoTZ( \\\"[" + connectionTimeZone + "]\\\" dt )}'");
    SingleExecutionPlan executionPlan = objectMapper.readValue(planWithTz, SingleExecutionPlan.class);
    RelationalResult result = (RelationalResult) executionPlan.rootExecutionNode.accept(new ExecutionNodeExecutor(null, new ExecutionState(vars, Lists.mutable.withAll(executionPlan.templateFunctions), Lists.mutable.with(new RelationalStoreExecutionState(new RelationalStoreState(serverPort))))));
    Assert.assertEquals("{\"builder\": {\"_type\":\"classBuilder\",\"mapping\":\"meta::relational::tests::milestoning::milestoningmap\",\"classMappings\":[{\"setImplementationId\":\"meta_relational_tests_milestoning_ProductSynonym\",\"properties\":[{\"property\":\"synonym\",\"type\":\"String\"},{\"property\":\"type\",\"type\":\"String\"},{\"property\":\"testDate\",\"type\":\"Date\"},{\"property\":\"testDateTime\",\"type\":\"DateTime\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}, \"activities\": [{\"_type\":\"relational\",\"sql\":\"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\\\".testDate as \\\"testDate\\\", \\\"root\\\".testDateTime as \\\"testDateTime\\\", \\\"root\\\".from_z as \\\"k_businessDate\\\" from ProductSynonymTable as \\\"root\\\" where \\\"root\\\".testDateTime = '2014-12-04T08:22:23'\"}], \"result\" : {\"columns\" : [\"pk_0\",\"pk_1\",\"pk_2\",\"synonym\",\"type\",\"testDate\",\"testDateTime\",\"k_businessDate\"], \"rows\" : [{\"values\": [\"GS-ModC\",\"GS-Mod-S1\",\"STOCK\",\"GS-Mod-S1\",\"STOCK\",\"2015-08-26\",\"2014-12-04T15:22:23.000000000+0000\",\"2015-08-27T06:00:00.000000000+0000\"]}]}}", result.flush(new RelationalResultToJsonDefaultSerializer(result)));
}
Also used : ExecutionState(org.finos.legend.engine.plan.execution.nodes.state.ExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) RelationalResultToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.stores.relational.serialization.RelationalResultToJsonDefaultSerializer) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) ExecutionNodeExecutor(org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor) RelationalStoreState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreState) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) Result(org.finos.legend.engine.plan.execution.result.Result) Test(org.junit.Test)

Example 5 with Property

use of org.finos.legend.engine.protocol.pure.v1.model.packageableElement.domain.Property in project legend-engine by finos.

the class TestRelationalExecutor method testGMTTimeZonePlanWithDateTimeStringParameter.

@Test
public void testGMTTimeZonePlanWithDateTimeStringParameter() throws IOException {
    MutableMap<String, Result> vars = Maps.mutable.empty();
    vars.put("dt", new ConstantResult("2014-12-04T15:22:23.123456789"));
    String planWithTz = getTemplatePlanWithNoTz().replace("%timeZone%", ",\"timeZone\": \"GMT\"").replace("%templateFunctions%", getFreeMarkerAlloyDateFunction()).replace("%dateTimeParam%", "testDateTime = '${dt}'");
    SingleExecutionPlan executionPlan = objectMapper.readValue(planWithTz, SingleExecutionPlan.class);
    RelationalResult result = (RelationalResult) executionPlan.rootExecutionNode.accept(new ExecutionNodeExecutor(null, new ExecutionState(vars, Lists.mutable.withAll(executionPlan.templateFunctions), Lists.mutable.with(new RelationalStoreExecutionState(new RelationalStoreState(serverPort))))));
    Assert.assertEquals("{\"builder\": {\"_type\":\"classBuilder\",\"mapping\":\"meta::relational::tests::milestoning::milestoningmap\",\"classMappings\":[{\"setImplementationId\":\"meta_relational_tests_milestoning_ProductSynonym\",\"properties\":[{\"property\":\"synonym\",\"type\":\"String\"},{\"property\":\"type\",\"type\":\"String\"},{\"property\":\"testDate\",\"type\":\"Date\"},{\"property\":\"testDateTime\",\"type\":\"DateTime\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}],\"class\":\"meta::relational::tests::milestoning::ProductSynonym\"}, \"activities\": [{\"_type\":\"relational\",\"sql\":\"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\\\".testDate as \\\"testDate\\\", \\\"root\\\".testDateTime as \\\"testDateTime\\\", \\\"root\\\".from_z as \\\"k_businessDate\\\" from ProductSynonymTable as \\\"root\\\" where \\\"root\\\".testDateTime = '2014-12-04T15:22:23.123456789'\"}], \"result\" : {\"columns\" : [\"pk_0\",\"pk_1\",\"pk_2\",\"synonym\",\"type\",\"testDate\",\"testDateTime\",\"k_businessDate\"], \"rows\" : [{\"values\": [\"GS-ModA\",\"GS-Mod-S1\",\"STOCK\",\"GS-Mod-S1\",\"STOCK\",\"2015-06-26\",\"2014-12-04T15:22:23.123456789+0000\",\"2015-08-26T00:00:00.000000000+0000\"]}]}}", result.flush(new RelationalResultToJsonDefaultSerializer(result)));
}
Also used : ExecutionState(org.finos.legend.engine.plan.execution.nodes.state.ExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalStoreExecutionState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) RelationalResultToJsonDefaultSerializer(org.finos.legend.engine.plan.execution.stores.relational.serialization.RelationalResultToJsonDefaultSerializer) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) ExecutionNodeExecutor(org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor) RelationalStoreState(org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreState) SingleExecutionPlan(org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) ConstantResult(org.finos.legend.engine.plan.execution.result.ConstantResult) Result(org.finos.legend.engine.plan.execution.result.Result) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)18 MutableList (org.eclipse.collections.api.list.MutableList)16 FastList (org.eclipse.collections.impl.list.mutable.FastList)15 ListIterate (org.eclipse.collections.impl.utility.ListIterate)14 ExecutionNodeExecutor (org.finos.legend.engine.plan.execution.nodes.ExecutionNodeExecutor)14 RelationalResult (org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult)14 EngineException (org.finos.legend.engine.shared.core.operational.errorManagement.EngineException)14 ExecutionState (org.finos.legend.engine.plan.execution.nodes.state.ExecutionState)13 SingleExecutionPlan (org.finos.legend.engine.protocol.pure.v1.model.executionPlan.SingleExecutionPlan)13 GenericType (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.generics.GenericType)13 EngineErrorType (org.finos.legend.engine.protocol.pure.v1.model.context.EngineErrorType)12 Type (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.type.Type)12 RichIterable (org.eclipse.collections.api.RichIterable)11 Lists (org.eclipse.collections.impl.factory.Lists)11 RelationalStoreExecutionState (org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreExecutionState)11 RelationalStoreState (org.finos.legend.engine.plan.execution.stores.relational.plugin.RelationalStoreState)11 RelationalResultToJsonDefaultSerializer (org.finos.legend.engine.plan.execution.stores.relational.serialization.RelationalResultToJsonDefaultSerializer)11 ConstantResult (org.finos.legend.engine.plan.execution.result.ConstantResult)10 SourceInformation (org.finos.legend.engine.protocol.pure.v1.model.SourceInformation)10 Property (org.finos.legend.pure.m3.coreinstance.meta.pure.metamodel.function.property.Property)10