Search in sources :

Example 1 with JdbcSplit

use of io.prestosql.plugin.jdbc.JdbcSplit 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 2 with JdbcSplit

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

the class TestDataSourceTableSplitManager method testGetTableSplits04.

// dataReadOnly is false
@Test
public void testGetTableSplits04() {
    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\":\"1\",\"fieldMaxValue\":\"12\"}]");
    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 3 with JdbcSplit

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

the class TestDataSourceTableSplitManager method testGetTableSplits06.

// dataReadOnly is not exist.
@Test
public void testGetTableSplits06() {
    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\",\"splitCount\":\"2\"," + "\"fieldMinValue\":\"1\",\"fieldMaxValue\":\"12\"}]");
    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 JdbcSplit

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

the class DataSourceTableSplitManager method addJdbcSplit.

private void addJdbcSplit(JdbcTableHandle tableHandle, List<JdbcSplit> builder, String[] splitInfo, long timeStamp, int scanNodes, TableSplitConfig config) {
    JdbcSplit jdbcSplit = new JdbcSplit(tableHandle.getCatalogName(), tableHandle.getSchemaName(), tableHandle.getTableName(), config.getSplitField(), splitInfo[1], splitInfo[2], timeStamp, scanNodes, Optional.of(splitInfo[0]));
    builder.add(jdbcSplit);
}
Also used : JdbcSplit(io.prestosql.plugin.jdbc.JdbcSplit)

Example 5 with JdbcSplit

use of io.prestosql.plugin.jdbc.JdbcSplit 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)

Aggregations

JdbcSplit (io.prestosql.plugin.jdbc.JdbcSplit)8 BaseJdbcConfig (io.prestosql.plugin.jdbc.BaseJdbcConfig)6 ConnectorSplit (io.prestosql.spi.connector.ConnectorSplit)6 ConnectorSplitSource (io.prestosql.spi.connector.ConnectorSplitSource)6 SchemaTableName (io.prestosql.spi.connector.SchemaTableName)6 Test (org.testng.annotations.Test)6 PrestoException (io.prestosql.spi.PrestoException)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 ArrayList (java.util.ArrayList)1