Search in sources :

Example 1 with RelationalExecutionConfiguration

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);
}
Also used : RelationalExecutionConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration) TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration) DatabaseAuthenticationFlowProvider(org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider)

Example 2 with RelationalExecutionConfiguration

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);
}
Also used : RelationalExecutionConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration) TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration)

Example 3 with 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));
}
Also used : LegendDefaultDatabaseAuthenticationFlowProviderConfiguration(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProviderConfiguration) RelationalExecutionConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration) LegendDefaultDatabaseAuthenticationFlowProvider(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider) TemporaryTestDbConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration) RelationalResult(org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult) ResultSet(java.sql.ResultSet) Test(org.junit.Test)

Example 4 with RelationalExecutionConfiguration

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);
}
Also used : LegendDefaultDatabaseAuthenticationFlowProviderConfiguration(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProviderConfiguration) RelationalExecutionConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration) LegendDefaultDatabaseAuthenticationFlowProvider(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider) Test(org.junit.Test)

Example 5 with RelationalExecutionConfiguration

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);
}
Also used : LegendDefaultDatabaseAuthenticationFlowProviderConfiguration(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProviderConfiguration) RelationalExecutionConfiguration(org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration) LegendDefaultDatabaseAuthenticationFlowProvider(org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider) Test(org.junit.Test)

Aggregations

RelationalExecutionConfiguration (org.finos.legend.engine.plan.execution.stores.relational.config.RelationalExecutionConfiguration)6 TemporaryTestDbConfiguration (org.finos.legend.engine.plan.execution.stores.relational.config.TemporaryTestDbConfiguration)4 LegendDefaultDatabaseAuthenticationFlowProvider (org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProvider)3 LegendDefaultDatabaseAuthenticationFlowProviderConfiguration (org.finos.legend.engine.authentication.LegendDefaultDatabaseAuthenticationFlowProviderConfiguration)3 Test (org.junit.Test)3 DatabaseAuthenticationFlowProvider (org.finos.legend.engine.authentication.provider.DatabaseAuthenticationFlowProvider)2 ResultSet (java.sql.ResultSet)1 RelationalResult (org.finos.legend.engine.plan.execution.stores.relational.result.RelationalResult)1