Search in sources :

Example 1 with Requires

use of io.prestodb.tempto.Requires 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 Requires

use of io.prestodb.tempto.Requires 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 Requires

use of io.prestodb.tempto.Requires 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 Requires

use of io.prestodb.tempto.Requires 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 Requires

use of io.prestodb.tempto.Requires in project presto by prestodb.

the class JdbcTests method shouldGetTables.

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

Aggregations

ProductTest (io.prestodb.tempto.ProductTest)21 Requires (io.prestodb.tempto.Requires)21 Test (org.testng.annotations.Test)21 QueryResult (io.prestodb.tempto.query.QueryResult)19 BigDecimal (java.math.BigDecimal)7 Statement (java.sql.Statement)6 PreparedStatement (java.sql.PreparedStatement)3 BigInteger (java.math.BigInteger)1