Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,15 @@ protected QueryRunner createQueryRunner()
@Test
public void testCloseIdleWriters()
{
String tableName = "task_close_idle_writers_" + randomNameSuffix();
String sourceTable = "tpch.\"sf0.1\".lineitem";
String targetTable = "task_close_idle_writers_" + randomNameSuffix();
try {
String zeroShipModes = "'AIR', 'FOB', 'SHIP', 'TRUCK'";
String oneShipModes = "'MAIL', 'RAIL', 'REG AIR'";
String bothShipModes = zeroShipModes + ", " + oneShipModes;

long expectedCount = (long) computeScalar("SELECT count (*) FROM %s WHERE shipmode IN (%s)".formatted(sourceTable, bothShipModes));

// Create a table with two partitions (0 and 1). Using the order by trick we will write the partitions in
// this order 0, 1, and then again 0. This way we are sure that during partition 1 write there will
// be an idle writer for partition 0. Additionally, during second partition 0 write, there will be an idle
Expand All @@ -73,16 +80,16 @@ public void testCloseIdleWriters()
discount, tax, returnflag, linestatus, commitdate, receiptdate, shipinstruct,
comment, shipdate,
CASE
WHEN shipmode IN ('AIR', 'FOB', 'SHIP', 'TRUCK') THEN 0
WHEN shipmode IN ('MAIL', 'RAIL', 'REG AIR') THEN 1
ELSE 2
WHEN shipmode IN (%s) THEN 0
WHEN shipmode IN (%s) THEN 1
END AS shipmodeVal
FROM tpch.tiny.lineitem
FROM %s
WHERE shipmode IN (%s)
ORDER BY shipmode
LIMIT 60174
""".formatted(tableName);
LIMIT %s
""".formatted(targetTable, zeroShipModes, oneShipModes, sourceTable, bothShipModes, expectedCount);

// Disable all kind of scaling and set idle writer threshold to 10MB
// Disable all kind of scaling and set low idle writer threshold
assertUpdate(
Session.builder(getSession())
.setSystemProperty(SCALE_WRITERS, "false")
Expand All @@ -92,13 +99,13 @@ WHEN shipmode IN ('MAIL', 'RAIL', 'REG AIR') THEN 1
.setSystemProperty(IDLE_WRITER_MIN_DATA_SIZE_THRESHOLD, "0.1MB")
.build(),
createTableSql,
60174);
long files = (long) computeScalar("SELECT count(DISTINCT \"$path\") FROM " + tableName);
expectedCount);
long files = (long) computeScalar("SELECT count(DISTINCT \"$path\") FROM " + targetTable);
// There should more than 2 files since we triggered close idle writers.
assertThat(files).isGreaterThan(2);
}
finally {
assertUpdate("DROP TABLE IF EXISTS " + tableName);
assertUpdate("DROP TABLE IF EXISTS " + targetTable);
}
}
}