Search in sources :

Example 66 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesParquetFile.

@Requires(ParquetRequirements.class)
@Test(groups = { POST_HIVE_1_0_1 })
public void testSelectAllDatatypesParquetFile() {
    String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_PARQUET).getNameInDatabase();
    onHive().executeQuery(format("INSERT INTO %s VALUES(" + "127," + "32767," + "2147483647," + "9223372036854775807," + "123.345," + "234.567," + "346," + "345.67800," + "'" + Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)).toString() + "'," + "'ala ma kota'," + "'ala ma kot'," + "'ala ma    '," + "true," + "'kot binarny'" + ")", tableName));
    assertThat(query(format("SHOW COLUMNS FROM %s", tableName)).project(1, 2)).containsExactly(row("c_tinyint", "tinyint"), row("c_smallint", "smallint"), row("c_int", "integer"), row("c_bigint", "bigint"), row("c_float", "real"), row("c_double", "double"), row("c_decimal", "decimal(10,0)"), row("c_decimal_w_params", "decimal(10,5)"), row("c_timestamp", "timestamp"), row("c_string", "varchar"), row("c_varchar", "varchar(10)"), row("c_char", "char(10)"), row("c_boolean", "boolean"), row("c_binary", "varbinary"));
    QueryResult queryResult = query(format("SELECT * FROM %s", tableName));
    assertColumnTypesParquet(queryResult);
    assertThat(queryResult).containsOnly(row(127, 32767, 2147483647, 9223372036854775807L, 123.345f, 234.567, new BigDecimal("346"), new BigDecimal("345.67800"), Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)), "ala ma kota", "ala ma kot", "ala ma    ", true, "kot binarny".getBytes()));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) BigDecimal(java.math.BigDecimal) Requires(io.prestodb.tempto.Requires) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 67 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesRcfile.

@Requires(RcfileRequirements.class)
@Test(groups = { JDBC })
public void testSelectAllDatatypesRcfile() {
    String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_RCFILE).getNameInDatabase();
    populateDataToHiveTable(tableName);
    assertProperAllDatatypesSchema(tableName);
    QueryResult queryResult = query(format("SELECT * FROM %s", tableName));
    assertColumnTypes(queryResult);
    assertThat(queryResult).containsOnly(row(127, 32767, 2147483647, 9223372036854775807L, 123.345f, 234.567, new BigDecimal("346"), new BigDecimal("345.67800"), Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)), Date.valueOf("2015-05-10"), "ala ma kota", "ala ma kot", "ala ma    ", true, "kot binarny".getBytes()));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) BigDecimal(java.math.BigDecimal) Requires(io.prestodb.tempto.Requires) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 68 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class JdbcTests method shouldGetSchemas.

@Test(groups = JDBC)
public void shouldGetSchemas() throws SQLException {
    QueryResult result = QueryResult.forResultSet(metaData().getSchemas("hive", null));
    assertThat(result).contains(row("default", "hive"));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Example 69 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class JdbcTests method shouldExecuteQueryWithSelectedCatalogAndSchema.

@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldExecuteQueryWithSelectedCatalogAndSchema() throws SQLException {
    if (usingTeradataJdbc4Driver(connection())) {
        LOGGER.warn("connection().setSchema() is not supported in JDBC 4");
    } else {
        connection().setCatalog("hive");
        connection().setSchema("default");
        try (Statement statement = connection().createStatement()) {
            QueryResult result = queryResult(statement, "select * from nation");
            assertThat(result).matches(PRESTO_NATION_RESULT);
        }
    }
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest) Requires(io.prestodb.tempto.Requires)

Example 70 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project urban-eureka by errir503.

the class JdbcTests method shouldExecuteQuery.

@Test(groups = JDBC)
@Requires(ImmutableNationTable.class)
public void shouldExecuteQuery() throws SQLException {
    try (Statement statement = connection().createStatement()) {
        QueryResult result = queryResult(statement, "select * from hive.default.nation");
        assertThat(result).matches(PRESTO_NATION_RESULT);
    }
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest) Requires(io.prestodb.tempto.Requires)

Aggregations

QueryResult (io.prestodb.tempto.query.QueryResult)122 Test (org.testng.annotations.Test)110 ProductTest (io.prestodb.tempto.ProductTest)108 Requires (io.prestodb.tempto.Requires)38 BigDecimal (java.math.BigDecimal)14 Statement (java.sql.Statement)12 PreparedStatement (java.sql.PreparedStatement)8 Duration (io.airlift.units.Duration)6 Row (io.prestodb.tempto.assertions.QueryAssert.Row)6 List (java.util.List)6 STORAGE_FORMATS (com.facebook.presto.tests.TestGroups.STORAGE_FORMATS)4 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)4 Row.row (io.prestodb.tempto.assertions.QueryAssert.Row.row)4 QueryAssert.assertThat (io.prestodb.tempto.assertions.QueryAssert.assertThat)4 QueryExecutor.query (io.prestodb.tempto.query.QueryExecutor.query)4 String.format (java.lang.String.format)4 Connection (java.sql.Connection)4 Response (com.facebook.airlift.http.client.Response)2 PrestoConnection (com.facebook.presto.jdbc.PrestoConnection)2 JdbcDriverUtils (com.facebook.presto.tests.utils.JdbcDriverUtils)2