Search in sources :

Example 66 with MaterializedRow

use of io.trino.testing.MaterializedRow in project trino by trinodb.

the class BaseRaptorConnectorTest method testShardUuidHiddenColumn.

@Test
public void testShardUuidHiddenColumn() {
    assertUpdate("CREATE TABLE test_shard_uuid AS SELECT orderdate, orderkey FROM orders", "SELECT count(*) FROM orders");
    MaterializedResult actualResults = computeActual("SELECT *, \"$shard_uuid\" FROM test_shard_uuid");
    assertEquals(actualResults.getTypes(), ImmutableList.of(DATE, BIGINT, SHARD_UUID_COLUMN_TYPE));
    UUID arbitraryUuid = null;
    for (MaterializedRow row : actualResults.getMaterializedRows()) {
        Object uuid = row.getField(2);
        assertInstanceOf(uuid, String.class);
        arbitraryUuid = UUID.fromString((String) uuid);
    }
    assertNotNull(arbitraryUuid);
    actualResults = computeActual(format("SELECT * FROM test_shard_uuid where \"$shard_uuid\" = '%s'", arbitraryUuid));
    assertNotEquals(actualResults.getMaterializedRows().size(), 0);
    actualResults = computeActual("SELECT * FROM test_shard_uuid where \"$shard_uuid\" = 'foo'");
    assertEquals(actualResults.getMaterializedRows().size(), 0);
}
Also used : MaterializedResult(io.trino.testing.MaterializedResult) UUID(java.util.UUID) MaterializedRow(io.trino.testing.MaterializedRow) Test(org.testng.annotations.Test) BaseConnectorTest(io.trino.testing.BaseConnectorTest)

Example 67 with MaterializedRow

use of io.trino.testing.MaterializedRow in project trino by trinodb.

the class TestSingleStoreConnectorTest method testSingleStoreTinyint.

@Test
public void testSingleStoreTinyint() {
    onRemoteDatabase().execute("CREATE TABLE tpch.mysql_test_tinyint1 (c_tinyint tinyint(1))");
    MaterializedResult actual = computeActual("SHOW COLUMNS FROM mysql_test_tinyint1");
    MaterializedResult expected = resultBuilder(getSession(), VARCHAR, VARCHAR, VARCHAR, VARCHAR).row("c_tinyint", "tinyint", "", "").build();
    assertEquals(actual, expected);
    onRemoteDatabase().execute("INSERT INTO tpch.mysql_test_tinyint1 VALUES (127), (-128)");
    MaterializedResult materializedRows = computeActual("SELECT * FROM tpch.mysql_test_tinyint1 WHERE c_tinyint = 127");
    assertEquals(materializedRows.getRowCount(), 1);
    MaterializedRow row = getOnlyElement(materializedRows);
    assertEquals(row.getFields().size(), 1);
    assertEquals(row.getField(0), (byte) 127);
    assertUpdate("DROP TABLE mysql_test_tinyint1");
}
Also used : MaterializedResult(io.trino.testing.MaterializedResult) MaterializedRow(io.trino.testing.MaterializedRow) Test(org.testng.annotations.Test) BaseJdbcConnectorTest(io.trino.plugin.jdbc.BaseJdbcConnectorTest)

Aggregations

MaterializedRow (io.trino.testing.MaterializedRow)67 MaterializedResult (io.trino.testing.MaterializedResult)58 Test (org.testng.annotations.Test)44 BaseConnectorTest (io.trino.testing.BaseConnectorTest)21 Constraint (io.trino.spi.connector.Constraint)11 Language (org.intellij.lang.annotations.Language)11 Session (io.trino.Session)9 ConnectorPageSource (io.trino.spi.connector.ConnectorPageSource)9 ConnectorSession (io.trino.spi.connector.ConnectorSession)9 ImmutableList (com.google.common.collect.ImmutableList)8 ColumnHandle (io.trino.spi.connector.ColumnHandle)8 Type (io.trino.spi.type.Type)8 ConnectorMetadata (io.trino.spi.connector.ConnectorMetadata)7 ConnectorTableHandle (io.trino.spi.connector.ConnectorTableHandle)7 HiveColumnHandle.bucketColumnHandle (io.trino.plugin.hive.HiveColumnHandle.bucketColumnHandle)6 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)6 LocalDate (java.time.LocalDate)6 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)5 ImmutableMap.toImmutableMap (com.google.common.collect.ImmutableMap.toImmutableMap)5 TableMetadata (io.trino.metadata.TableMetadata)5