Search in sources :

Example 1 with BaseJdbcConfig

use of io.prestosql.plugin.jdbc.BaseJdbcConfig in project hetu-core by openlookeng.

the class TestMySqlRegisterRemoteUdf method testDefaults.

@Test
public void testDefaults() {
    MysqlExternalFunctionHub externalFunctionHub = new MysqlExternalFunctionHub(new BaseJdbcConfig());
    Set<ExternalFunctionInfo> externalFunctionInfo = externalFunctionHub.getExternalFunctions();
    assertTrue(externalFunctionInfo.size() > 0);
    List<ExternalFunctionInfo> functionList = externalFunctionInfo.stream().filter(x -> x.getFunctionName().get().equals("lower")).collect(Collectors.toList());
    assertEquals(functionList.size(), 1);
    ExternalFunctionInfo functionInfo = functionList.get(0);
    assertEquals(functionInfo.getInputArgs().get(0), StandardTypes.VARCHAR);
    assertEquals(functionInfo.getReturnType().get(), StandardTypes.VARCHAR);
    assertTrue(functionInfo.isDeterministic());
    assertFalse(functionInfo.isCalledOnNullInput());
}
Also used : List(java.util.List) StandardTypes(io.prestosql.spi.type.StandardTypes) MysqlExternalFunctionHub(io.prestosql.plugin.mysql.optimization.function.MysqlExternalFunctionHub) BaseJdbcConfig(io.prestosql.plugin.jdbc.BaseJdbcConfig) Set(java.util.Set) Assert.assertEquals(org.testng.Assert.assertEquals) Assert.assertTrue(org.testng.Assert.assertTrue) Test(org.testng.annotations.Test) ExternalFunctionInfo(io.prestosql.spi.function.ExternalFunctionInfo) Collectors(java.util.stream.Collectors) Assert.assertFalse(org.testng.Assert.assertFalse) MysqlExternalFunctionHub(io.prestosql.plugin.mysql.optimization.function.MysqlExternalFunctionHub) ExternalFunctionInfo(io.prestosql.spi.function.ExternalFunctionInfo) BaseJdbcConfig(io.prestosql.plugin.jdbc.BaseJdbcConfig) Test(org.testng.annotations.Test)

Example 2 with BaseJdbcConfig

use of io.prestosql.plugin.jdbc.BaseJdbcConfig in project hetu-core by openlookeng.

the class TestJdbcPlanOptimizer method getOptimizedPlan.

private PlanNode getOptimizedPlan(PlanBuilder planBuilder, PlanNode originalPlan) {
    BaseJdbcConfig config = new BaseJdbcConfig();
    JdbcClient client = new TestPushwonClient();
    TesterParameter testerParameter = TesterParameter.getTesterParameter();
    JdbcPlanOptimizer optimizer = new JdbcPlanOptimizer(client, new TestTypeManager(), config, testerParameter.getRowExpressionService(), testerParameter.getDeterminismEvaluator(), testerParameter.getMetadata().getFunctionAndTypeManager(), testerParameter.getFunctionResolution());
    return optimizer.optimize(originalPlan, defaultSessionHolder.getConnectorSession(), ImmutableMap.<String, Type>builder().put("regionid", INTEGER).put("city", VARCHAR).put("fare", DOUBLE).put("amount", BIGINT).build(), new PlanSymbolAllocator(), planBuilder.getIdAllocator());
}
Also used : Type(io.prestosql.spi.type.Type) JdbcClient(io.prestosql.plugin.jdbc.JdbcClient) PlanSymbolAllocator(io.prestosql.sql.planner.PlanSymbolAllocator) BaseJdbcConfig(io.prestosql.plugin.jdbc.BaseJdbcConfig)

Example 3 with BaseJdbcConfig

use of io.prestosql.plugin.jdbc.BaseJdbcConfig in project hetu-core by openlookeng.

the class TestDataSourceTableSplitManager method testGetTableSplits03.

// fieldMinValue and fieldMaxValue is null and dataReadOnly is false
@Test
public void testGetTableSplits03() {
    long[][] rangeArray = new long[][] { { 0, 6 }, { 6, 12 }, { 12, Long.MAX_VALUE }, { Long.MIN_VALUE, 0 } };
    BaseJdbcConfig config = new BaseJdbcConfig();
    config.setPushDownEnable(true).setTableSplitEnable(true).setTableSplitFields("[{\"catalogName\":\"" + catalogName + "\",\"schemaName\":\"EXAMPLE\",\"tableName\":\"NUMBERS\"," + "\"splitField\":\"value\",\"calcStepEnable\":\"false\",\"dataReadOnly\":\"false\",\"splitCount\":\"2\"," + "\"fieldMinValue\":\"\",\"fieldMaxValue\":\"\"}]");
    tableHandle = getTableHandle(new SchemaTableName("example", "numbers"));
    splitManager = new DataSourceTableSplitManager(config, jdbcClient, nodeManager);
    TableSplitConfig tableSplitConfig = splitManager.getTableSplitConfig(tableHandle);
    tableSplitConfig.setTableSplitFieldValid(true);
    ConnectorSplitSource splitSource = splitManager.getTableSplits(JdbcIdentity.from(SESSION), tableHandle);
    List<ConnectorSplit> splits = getFutureValue(splitSource.getNextBatch(NOT_PARTITIONED, 1000)).getSplits();
    int index = 0;
    for (ConnectorSplit split : splits) {
        JdbcSplit jdbcSplit = (JdbcSplit) split;
        assertEquals(Long.parseLong(jdbcSplit.getRangeStart()), rangeArray[index][0]);
        assertEquals(Long.parseLong(jdbcSplit.getRangEnd()), rangeArray[index][1]);
        index++;
        assertFalse(index > 4);
    }
}
Also used : JdbcSplit(io.prestosql.plugin.jdbc.JdbcSplit) ConnectorSplitSource(io.prestosql.spi.connector.ConnectorSplitSource) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) ConnectorSplit(io.prestosql.spi.connector.ConnectorSplit) BaseJdbcConfig(io.prestosql.plugin.jdbc.BaseJdbcConfig) Test(org.testng.annotations.Test)

Example 4 with BaseJdbcConfig

use of io.prestosql.plugin.jdbc.BaseJdbcConfig in project hetu-core by openlookeng.

the class TestDataSourceTableSplitManager method testGetTableSplits07.

@Test
public void testGetTableSplits07() {
    BaseJdbcConfig config = new BaseJdbcConfig();
    config.setPushDownEnable(true).setTableSplitEnable(true).setTableSplitFields("[{\"catalogName\":\"" + catalogName + "\",\"schemaName\":\"EXAMPLE\",\"tableName\":\"NUMBERS\"," + "\"splitField\":\"value\",\"calcStepEnable\":\"false\",\"dataReadOnly\":\"true\",\"splitCount\":\"-1\"," + "\"fieldMinValue\":\"1\",\"fieldMaxValue\":\"12\"}]");
    tableHandle = getTableHandle(new SchemaTableName("example", "numbers"));
    splitManager = new DataSourceTableSplitManager(config, jdbcClient, nodeManager);
    ConnectorSplitSource splitSource = splitManager.getTableSplits(JdbcIdentity.from(SESSION), tableHandle);
    assertEquals(splitSource.getClass(), FixedSplitSource.class);
}
Also used : ConnectorSplitSource(io.prestosql.spi.connector.ConnectorSplitSource) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) BaseJdbcConfig(io.prestosql.plugin.jdbc.BaseJdbcConfig) Test(org.testng.annotations.Test)

Example 5 with BaseJdbcConfig

use of io.prestosql.plugin.jdbc.BaseJdbcConfig in project hetu-core by openlookeng.

the class TestDataSourceTableSplitManager method testGetTableSplits01.

// calcStepEnable is false
@Test
public void testGetTableSplits01() {
    BaseJdbcConfig config = new BaseJdbcConfig();
    config.setPushDownEnable(true).setTableSplitEnable(false).setTableSplitFields("[{\"catalogName\":\"" + catalogName + "\",\"schemaName\":\"EXAMPLE\",\"tableName\":\"NUMBERS\"," + "\"splitField\":\"value\",\"calcStepEnable\":\"false\",\"dataReadOnly\":\"true\",\"scanNodes\":\"2\"," + "\"fieldMinValue\":\"2\",\"fieldMaxValue\":\"12\"}]");
    tableHandle = getTableHandle(new SchemaTableName("example", "numbers"));
    splitManager = new DataSourceTableSplitManager(config, jdbcClient, nodeManager);
    ConnectorSplitSource splitSource = splitManager.getSplits(JdbcIdentity.from(SESSION), tableHandle);
    assertEquals(splitSource.getClass(), FixedSplitSource.class);
}
Also used : ConnectorSplitSource(io.prestosql.spi.connector.ConnectorSplitSource) SchemaTableName(io.prestosql.spi.connector.SchemaTableName) BaseJdbcConfig(io.prestosql.plugin.jdbc.BaseJdbcConfig) Test(org.testng.annotations.Test)

Aggregations

BaseJdbcConfig (io.prestosql.plugin.jdbc.BaseJdbcConfig)20 Test (org.testng.annotations.Test)17 ConnectorSplitSource (io.prestosql.spi.connector.ConnectorSplitSource)14 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)14 JdbcSplit (io.prestosql.plugin.jdbc.JdbcSplit)6 ConnectorSplit (io.prestosql.spi.connector.ConnectorSplit)6 MysqlExternalFunctionHub (io.prestosql.plugin.mysql.optimization.function.MysqlExternalFunctionHub)3 ExternalFunctionInfo (io.prestosql.spi.function.ExternalFunctionInfo)3 StandardTypes (io.prestosql.spi.type.StandardTypes)3 List (java.util.List)3 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 Assert.assertEquals (org.testng.Assert.assertEquals)3 Assert.assertFalse (org.testng.Assert.assertFalse)3 Assert.assertTrue (org.testng.Assert.assertTrue)3 BaseJdbcClient (io.prestosql.plugin.jdbc.BaseJdbcClient)1 DriverConnectionFactory (io.prestosql.plugin.jdbc.DriverConnectionFactory)1 JdbcClient (io.prestosql.plugin.jdbc.JdbcClient)1 BaseJdbcRowExpressionConverter (io.prestosql.plugin.jdbc.optimization.BaseJdbcRowExpressionConverter)1 TesterParameter (io.prestosql.plugin.jdbc.optimization.TesterParameter)1