Search in sources :

Example 1 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

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 2 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesAvro.

@Requires(AvroRequirements.class)
@Test(groups = { JDBC, SKIP_ON_CDH, AVRO })
public void testSelectAllDatatypesAvro() {
    String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_AVRO).getNameInDatabase();
    onHive().executeQuery(format("INSERT INTO %s VALUES(" + "2147483647," + "9223372036854775807," + "123.345," + "234.567," + "346," + "345.67800," + "'" + Timestamp.valueOf(LocalDateTime.of(2015, 5, 10, 12, 15, 35, 123_000_000)).toString() + "'," + "'" + Date.valueOf("2015-05-10") + "'," + "'ala ma kota'," + "'ala ma kot'," + "'ala ma    '," + "true," + "'kot binarny'" + ")", tableName));
    assertThat(query("SHOW COLUMNS FROM " + tableName).project(1, 2)).containsExactly(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_date", "date"), 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("SELECT * FROM " + tableName);
    assertThat(queryResult).hasColumns(INTEGER, BIGINT, REAL, DOUBLE, DECIMAL, DECIMAL, TIMESTAMP, DATE, VARCHAR, VARCHAR, CHAR, BOOLEAN, VARBINARY);
    assertThat(queryResult).containsOnly(row(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 3 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesOrc.

@Requires(OrcRequirements.class)
@Test(groups = { JDBC })
public void testSelectAllDatatypesOrc() {
    String tableName = mutableTableInstanceOf(ALL_HIVE_SIMPLE_TYPES_ORC).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 4 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestAllDatatypesFromHiveConnector method testSelectAllDatatypesTextFile.

@Requires(TextRequirements.class)
@Test(groups = { SMOKE })
public void testSelectAllDatatypesTextFile() {
    String tableName = ALL_HIVE_SIMPLE_TYPES_TEXTFILE.getName();
    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 5 with QueryResult

use of io.prestodb.tempto.query.QueryResult in project presto by prestodb.

the class TestSelect method testSelectWithMorePartitioningKeysThanLimit.

@Test(groups = CASSANDRA)
public void testSelectWithMorePartitioningKeysThanLimit() {
    String sql = format("SELECT s_suppkey FROM %s.%s.%s WHERE s_suppkey = 10", CONNECTOR_NAME, KEY_SPACE, CASSANDRA_SUPPLIER.getName());
    QueryResult queryResult = onPresto().executeQuery(sql);
    assertThat(queryResult).containsOnly(row(10));
}
Also used : QueryResult(io.prestodb.tempto.query.QueryResult) Test(org.testng.annotations.Test) ProductTest(io.prestodb.tempto.ProductTest)

Aggregations

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