Search in sources :

Example 11 with BaseJdbcConfig

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

the class TestDataSourceTableSplitManager method initSplitDatabase.

private void initSplitDatabase() throws SQLException {
    String connectionUrl;
    connectionUrl = "jdbc:h2:mem:test" + System.nanoTime() + ThreadLocalRandom.current().nextLong();
    jdbcClient = new BaseJdbcClient(new BaseJdbcConfig(), "\"", new DriverConnectionFactory(new Driver(), connectionUrl, Optional.empty(), Optional.empty(), new Properties()));
    connection = DriverManager.getConnection(connectionUrl);
}
Also used : BaseJdbcClient(io.prestosql.plugin.jdbc.BaseJdbcClient) DriverConnectionFactory(io.prestosql.plugin.jdbc.DriverConnectionFactory) Driver(org.h2.Driver) Properties(java.util.Properties) BaseJdbcConfig(io.prestosql.plugin.jdbc.BaseJdbcConfig)

Example 12 with BaseJdbcConfig

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

the class TestDataSourceTableSplitManager method testGetTableSplits05.

// fieldMinValue and filedMaxValue not consistent with table
@Test
public void testGetTableSplits05() {
    long[][] rangeArray = new long[][] { { 0, 6 }, { 6, 12 } };
    BaseJdbcConfig config = new BaseJdbcConfig();
    config.setPushDownEnable(true).setTableSplitEnable(true).setTableSplitFields("[{\"catalogName\":\"" + catalogName + "\",\"schemaName\":\"EXAMPLE\",\"tableName\":\"NUMBERS\"," + "\"splitField\":\"value\",\"calcStepEnable\":\"false\",\"dataReadOnly\":\"true\",\"splitCount\":\"2\"," + "\"fieldMinValue\":\"6\",\"fieldMaxValue\":\"2\"}]");
    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 > 2);
    }
}
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 13 with BaseJdbcConfig

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

the class TestDataSourceTableSplitManager method testGetTableSplits11.

// read full table.
@Test
public void testGetTableSplits11() {
    BaseJdbcConfig config = new BaseJdbcConfig();
    config.setPushDownEnable(true).setTableSplitEnable(true).setTableSplitFields("[{\"catalogName\":\"" + catalogName + "\",\"schemaName\":\"EXAMPLE\",\"tableName\":\"NONE_NUMBERS\"," + "\"splitField\":\"value\",\"calcStepEnable\":\"false\",\"dataReadOnly\":\"true\",\"splitCount\":\"2\"," + "\"fieldMinValue\":\"\",\"fieldMaxValue\":\"\"}]");
    tableHandle = getTableHandle(new SchemaTableName("example", "none_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 14 with BaseJdbcConfig

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

the class TestDataSourceTableSplitManager method testGetTableSplits12.

@Test
public void testGetTableSplits12() {
    long[][] rangeArray = new long[][] { { 0, 2 }, { 2, 4 }, { 4, 5 } };
    BaseJdbcConfig config = new BaseJdbcConfig();
    config.setPushDownEnable(true).setTableSplitEnable(true).setTableSplitFields("[{\"catalogName\":\"" + catalogName + "\",\"schemaName\":\"EXAMPLE\",\"tableName\":\"NUMBERS\"," + "\"splitField\":\"value\",\"calcStepEnable\":\"false\",\"dataReadOnly\":\"true\",\"splitCount\":\"3\"," + "\"fieldMinValue\":\"1\",\"fieldMaxValue\":\"5\"}]");
    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 > 3);
    }
}
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 15 with BaseJdbcConfig

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

the class TestDataSourceTableSplitManager method testGetTableSplits02.

// fieldMinValue and fieldMaxValue is null and dataReadOnly is true
@Test
public void testGetTableSplits02() {
    long[][] rangeArray = new long[][] { { 0, 6 }, { 6, 12 } };
    BaseJdbcConfig config = new BaseJdbcConfig();
    config.setPushDownEnable(true).setTableSplitEnable(true).setTableSplitFields("[{\"catalogName\":\"" + catalogName + "\",\"schemaName\":\"EXAMPLE\",\"tableName\":\"NUMBERS\"," + "\"splitField\":\"value\",\"calcStepEnable\":\"false\",\"dataReadOnly\":\"true\",\"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 > 2);
    }
}
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)

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