Skip to content

Commit

Permalink
Reduce data size in TestCsv
Browse files Browse the repository at this point in the history
`TestCsv` was frequently failing on CI.
  • Loading branch information
findepi committed Jul 27, 2020
1 parent ea9d0b3 commit 65b509d
Showing 1 changed file with 17 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
public class TestCsv
extends ProductTest
{
private static final String TPCH_SCHEMA = "tiny";

@Test(groups = STORAGE_FORMATS)
public void testInsertIntoCsvTable()
{
Expand All @@ -51,17 +49,14 @@ private void testInsertIntoCsvTable(String tableName, String additionalTableProp

query(format(
"CREATE TABLE %s(" +
" linestatus varchar," +
" shipinstruct varchar," +
" shipmode varchar," +
" comment varchar," +
" returnflag varchar" +
" name varchar, " +
" comment varchar " +
") WITH (format='CSV' %s)",
tableName, additionalTableProperties));

query(format("INSERT INTO %s SELECT linestatus, shipinstruct, shipmode, comment, returnflag FROM tpch.%s.lineitem", tableName, TPCH_SCHEMA));
query(format("INSERT INTO %s SELECT name, comment FROM tpch.tiny.nation", tableName));

assertSelect("select max(linestatus), max(shipinstruct), max(shipmode) from %s", tableName);
assertSelect("SELECT max(name), max(comment) FROM %s", tableName);

query("DROP TABLE " + tableName);
}
Expand All @@ -86,12 +81,12 @@ private void testCreateCsvTableAs(String additionalParameters)
query(format(
"CREATE TABLE %s WITH (format='CSV' %s) AS " +
"SELECT " +
"cast(linestatus AS varchar) AS linestatus, cast(shipmode AS varchar) AS shipmode, cast(returnflag AS varchar) AS returnflag " +
"FROM tpch.tiny.lineitem",
"CAST(nationkey AS varchar) AS nationkey, CAST(name AS varchar) AS name, CAST(comment AS varchar) AS comment " +
"FROM tpch.tiny.nation",
tableName,
additionalParameters));

assertSelect("select max(linestatus), max(shipmode), count(returnflag) from %s", tableName);
assertSelect("SELECT max(name), max(comment) FROM %s", tableName);

query("DROP TABLE " + tableName);
}
Expand All @@ -114,23 +109,16 @@ private void testInsertIntoPartitionedCsvTable(String tableName, String addition

query(format(
"CREATE TABLE %s(" +
" linestatus varchar," +
" shipinstruct varchar," +
" shipmode varchar," +
" comment varchar," +
" returnflag varchar," +
" suppkey bigint" +
") WITH (format='CSV' %s, partitioned_by = ARRAY['suppkey'])",
" name varchar, " +
" comment varchar, " +
" regionkey bigint " +
") WITH (format='CSV' %s, partitioned_by = ARRAY['regionkey'])",
tableName,
additionalParameters));

query(format(
"INSERT INTO %s " +
"SELECT " +
"linestatus, shipinstruct, shipmode, comment, returnflag, suppkey " +
"FROM tpch.%s.lineitem", tableName, TPCH_SCHEMA));
query(format("INSERT INTO %s SELECT name, comment, regionkey FROM tpch.tiny.nation", tableName));

assertSelect("select max(linestatus), max(shipinstruct), max(shipmode), max(suppkey) from %s", tableName);
assertSelect("SELECT max(name), max(comment), max(regionkey) FROM %s", tableName);

query("DROP TABLE " + tableName);
}
Expand All @@ -154,19 +142,19 @@ private void testCreatePartitionedCsvTableAs(String tableName, String additional
query("DROP TABLE IF EXISTS " + tableName);

query(format(
"CREATE TABLE %s WITH (format='CSV', partitioned_by = ARRAY['suppkey'] %s) AS " +
"SELECT cast(shipmode AS varchar) AS shipmode, cast(comment AS varchar) AS comment, suppkey FROM tpch.tiny.lineitem",
"CREATE TABLE %s WITH (format='CSV', partitioned_by = ARRAY['regionkey'] %s) AS " +
"SELECT cast(nationkey AS varchar) AS nationkey, cast(name AS varchar) AS name, regionkey FROM tpch.tiny.nation",
tableName,
additionalParameters));

assertSelect("select max(shipmode), max(comment), sum(suppkey) from %s", tableName);
assertSelect("SELECT max(name), max(regionkey) FROM %s", tableName);

query("DROP TABLE " + tableName);
}

private static void assertSelect(String query, String tableName)
{
QueryResult expected = query(format(query, "tpch." + TPCH_SCHEMA + ".lineitem"));
QueryResult expected = query(format(query, "tpch.tiny.nation"));
List<Row> expectedRows = expected.rows().stream()
.map((columns) -> row(columns.toArray()))
.collect(toImmutableList());
Expand Down

0 comments on commit 65b509d

Please sign in to comment.