use of org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration in project legend-engine by finos.
the class RelationalStoreExecutorBuilder method build.
@Override
public StoreExecutor build(StoreExecutorConfiguration storeExecutorConfiguration) {
if (!(storeExecutorConfiguration instanceof RelationalExecutionConfiguration)) {
String message = String.format("Invalid argument. Expected %s but found %s", RelationalExecutionConfiguration.class.getCanonicalName(), storeExecutorConfiguration.getClass().getCanonicalName());
throw new RuntimeException(message);
}
RelationalExecutionConfiguration relationalExecutionConfiguration = (RelationalExecutionConfiguration) storeExecutorConfiguration;
if (relationalExecutionConfiguration.tempPath == null) {
relationalExecutionConfiguration.tempPath = DEFAULT_TEMP_PATH;
}
if (relationalExecutionConfiguration.temporarytestdb == null) {
relationalExecutionConfiguration.temporarytestdb = new TemporaryTestDbConfiguration(DEFAULT_PORT);
}
Optional<DatabaseAuthenticationFlowProvider> flowProviderHolder = this.configureDatabaseAuthenticationFlowProvider(relationalExecutionConfiguration);
RelationalStoreState state = new RelationalStoreState(relationalExecutionConfiguration.temporarytestdb, relationalExecutionConfiguration, flowProviderHolder);
return new RelationalStoreExecutor(state);
}
use of org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration in project legend-engine by finos.
the class TestExecutionScope method buildTestExecutor.
public static RelationalExecutor buildTestExecutor(int port) {
RelationalExecutionConfiguration relationalExecutionConfiguration = new RelationalExecutionConfiguration();
relationalExecutionConfiguration.tempPath = "/tmp/";
TemporaryTestDbConfiguration temporaryTestDbConfiguration = new TemporaryTestDbConfiguration();
temporaryTestDbConfiguration.port = port;
return new RelationalExecutor(temporaryTestDbConfiguration, relationalExecutionConfiguration);
}
use of org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration in project legend-engine by finos.
the class TestServiceClassExecution method testSimpleRelationalServiceExecution.
@Test
public void testSimpleRelationalServiceExecution() throws SQLException {
RelationalExecutionConfiguration relationalExecutionConfiguration = RelationalExecutionConfiguration.newInstance().withTemporaryTestDbConfiguration(new TemporaryTestDbConfiguration(9090)).withDatabaseAuthenticationFlowProvider(LegendDefaultDatabaseAuthenticationFlowProvider.class, new LegendDefaultDatabaseAuthenticationFlowProviderConfiguration()).build();
SimpleRelationalService service = new SimpleRelationalService(relationalExecutionConfiguration);
RelationalResult relationalResult = (RelationalResult) service.execute();
ResultSet resultSet = relationalResult.getResultSet();
assertTrue("failed to fetch data", resultSet.next());
assertEquals(1, resultSet.getInt(1));
assertEquals("f1", resultSet.getString(2));
assertEquals("l1", resultSet.getString(3));
}
use of org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration in project legend-engine by finos.
the class TestServiceRunner method testSimpleRelationalServiceExecution.
@Test
public void testSimpleRelationalServiceExecution() {
RelationalExecutionConfiguration relationalExecutionConfiguration = RelationalExecutionConfiguration.newInstance().withDatabaseAuthenticationFlowProvider(LegendDefaultDatabaseAuthenticationFlowProvider.class, new LegendDefaultDatabaseAuthenticationFlowProviderConfiguration()).build();
SimpleRelationalServiceRunner simpleRelationalServiceRunner = (SimpleRelationalServiceRunner) ServiceRunnerBuilder.newInstance().withServiceRunnerClass(SimpleRelationalServiceRunner.class.getCanonicalName()).withAllowJavaCompilation(false).withStoreExecutorConfigurations(relationalExecutionConfiguration).build();
ServiceRunnerInput serviceRunnerInput1 = ServiceRunnerInput.newInstance().withArgs(Collections.singletonList(Collections.singletonList("John"))).withSerializationFormat(SerializationFormat.PURE);
String result1 = simpleRelationalServiceRunner.run(serviceRunnerInput1);
Assert.assertEquals("{\"firstName\":\"John\",\"lastName\":\"Johnson\"}", result1);
ServiceRunnerInput serviceRunnerInput2 = ServiceRunnerInput.newInstance().withArgs(Collections.singletonList(Arrays.asList("John", "Peter"))).withSerializationFormat(SerializationFormat.PURE);
String result2 = simpleRelationalServiceRunner.run(serviceRunnerInput2);
Assert.assertEquals("[{\"firstName\":\"Peter\",\"lastName\":\"Smith\"},{\"firstName\":\"John\",\"lastName\":\"Johnson\"}]", result2);
}
use of org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration in project legend-engine by finos.
the class TestServiceRunner method testSimpleRelationalServiceExecutionWithTDSResult.
@Test
public void testSimpleRelationalServiceExecutionWithTDSResult() {
RelationalExecutionConfiguration relationalExecutionConfiguration = RelationalExecutionConfiguration.newInstance().withDatabaseAuthenticationFlowProvider(LegendDefaultDatabaseAuthenticationFlowProvider.class, new LegendDefaultDatabaseAuthenticationFlowProviderConfiguration()).build();
SimpleRelationalServiceRunnerTDS simpleRelationalServiceRunner = (SimpleRelationalServiceRunnerTDS) ServiceRunnerBuilder.newInstance().withServiceRunnerClass(SimpleRelationalServiceRunnerTDS.class.getCanonicalName()).withAllowJavaCompilation(false).withStoreExecutorConfigurations(relationalExecutionConfiguration).build();
ServiceRunnerInput serviceRunnerInput1 = ServiceRunnerInput.newInstance().withArgs(Collections.singletonList(Collections.singletonList("John"))).withSerializationFormat(SerializationFormat.PURE);
String result1 = simpleRelationalServiceRunner.run(serviceRunnerInput1);
Assert.assertEquals("{\"columns\":[{\"name\":\"Age\",\"type\":\"Integer\"},{\"name\":\"First Name\",\"type\":\"String\"},{\"name\":\"Last Name\",\"type\":\"String\"}],\"rows\":[{\"values\":[1,\"f1\",\"l1\"]}]}", result1);
}
Aggregations