Skip to content

Commit 3badf53

Browse files
committedJan 27, 2025
Improve testing
1 parent 0442dcc commit 3badf53

File tree

2 files changed

+43
-20
lines changed

2 files changed

+43
-20
lines changed
 

‎presto-iceberg/src/test/java/com/facebook/presto/iceberg/IcebergDistributedSmokeTestBase.java

-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ public void testTimestamp()
8989
@Test
9090
public void testTimestampWithTimeZone()
9191
{
92-
assertQuerySucceeds("CREATE TABLE test_timestamp_with_timezone (x timestamp with time zone)");
93-
dropTable(getSession(), "test_timestamp_with_timezone");
9492
assertQuerySucceeds("CREATE TABLE test_timestamp_with_timezone (x) AS SELECT TIMESTAMP '1969-12-01 00:00:00.000000 UTC'");
9593
assertQuerySucceeds("ALTER TABLE test_timestamp_with_timezone ADD COLUMN y timestamp with time zone");
9694
dropTable(getSession(), "test_timestamp_with_timezone");

‎presto-iceberg/src/test/java/com/facebook/presto/iceberg/TestIcebergTypes.java

+43-18
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
*/
1414
package com.facebook.presto.iceberg;
1515

16+
import com.facebook.presto.Session;
1617
import com.facebook.presto.common.type.TimestampType;
1718
import com.facebook.presto.common.type.TimestampWithTimeZoneType;
1819
import com.facebook.presto.common.type.Type;
1920
import com.facebook.presto.testing.MaterializedResult;
21+
import com.facebook.presto.testing.MaterializedRow;
2022
import com.facebook.presto.testing.QueryRunner;
2123
import com.facebook.presto.tests.AbstractTestQueryFramework;
2224
import com.google.common.collect.ImmutableMap;
@@ -59,60 +61,83 @@ protected QueryRunner createQueryRunner() throws Exception
5961
@DataProvider(name = "testTimestampWithTimezone")
6062
public Object[][] createTestTimestampWithTimezoneData()
6163
{
64+
//return new Object[][] {
65+
// {getQueryRunner()},
66+
// {getBatchReaderEnabledQueryRunner()}
67+
//};
6268
return new Object[][] {
63-
{getQueryRunner()},
64-
{getBatchReaderEnabledQueryRunner()}
69+
{Session.builder(getSession())
70+
.setCatalogSessionProperty("iceberg", PARQUET_BATCH_READ_OPTIMIZATION_ENABLED, "true")
71+
.build()},
72+
{Session.builder(getSession())
73+
.setCatalogSessionProperty("iceberg", PARQUET_BATCH_READ_OPTIMIZATION_ENABLED, "false")
74+
.build()}
6575
};
6676
}
6777

6878
@Test(dataProvider = "testTimestampWithTimezone")
69-
public void testTimestampWithTimezone(QueryRunner runner)
79+
public void testTimestampWithTimezone(Session session)
7080
{
81+
QueryRunner runner = getQueryRunner();
7182
String timestamptz = "TIMESTAMP '1984-12-08 00:10:00 America/Los_Angeles'";
7283
String timestamp = "TIMESTAMP '1984-12-08 00:10:00'";
7384

74-
runner.execute("CREATE TABLE test_timestamptz(a TIMESTAMP WITH TIME ZONE, b TIMESTAMP, c TIMESTAMP WITH TIME ZONE)");
85+
dropTableIfExists(runner, session.getCatalog().get(), session.getSchema().get(), "test_timestamptz");
86+
assertQuerySucceeds(session, "CREATE TABLE test_timestamptz(a TIMESTAMP WITH TIME ZONE, b TIMESTAMP, c TIMESTAMP WITH TIME ZONE)");
87+
7588
String row = "(" + timestamptz + ", " + timestamp + ", " + timestamptz + ")";
7689
for (int i = 0; i < 10; i++) {
77-
runner.execute("INSERT INTO test_timestamptz values " + row);
90+
assertUpdate(session, "INSERT INTO test_timestamptz values " + row, 1);
7891
}
7992

80-
MaterializedResult initialRows = runner.execute("SELECT * FROM test_timestamptz");
81-
List<Type> types = initialRows.getTypes();
93+
MaterializedResult initialRows = runner.execute(session, "SELECT * FROM test_timestamptz");
8294

95+
List<Type> types = initialRows.getTypes();
8396
assertTrue(types.get(0) instanceof TimestampWithTimeZoneType);
8497
assertTrue(types.get(1) instanceof TimestampType);
8598

86-
runner.execute("CREATE TABLE test_timestamptz_partition(a TIMESTAMP WITH TIME ZONE, b TIMESTAMP, c TIMESTAMP WITH TIME ZONE) " +
99+
List<MaterializedRow> rows = initialRows.getMaterializedRows();
100+
for (int i = 0; i < 10; i++) {
101+
assertEquals("[1984-12-08T08:10Z[UTC], 1984-12-08T00:10, 1984-12-08T08:10Z[UTC]]", rows.get(i).toString());
102+
}
103+
104+
dropTableIfExists(runner, session.getCatalog().get(), session.getSchema().get(), "test_timestamptz_partition");
105+
assertQuerySucceeds(session, "CREATE TABLE test_timestamptz_partition(a TIMESTAMP WITH TIME ZONE, b TIMESTAMP, c TIMESTAMP WITH TIME ZONE) " +
87106
"WITH (PARTITIONING = ARRAY['b'])");
88-
runner.execute("INSERT INTO test_timestamptz_partition (a, b, c) SELECT a, b, c FROM test_timestamptz");
107+
assertUpdate(session, "INSERT INTO test_timestamptz_partition (a, b, c) SELECT a, b, c FROM test_timestamptz", 10);
89108

90-
MaterializedResult partitionRows = runner.execute("SELECT * FROM test_timestamptz");
91-
List<Type> partitionTypes = partitionRows.getTypes();
109+
MaterializedResult partitionRows = runner.execute(session, "SELECT * FROM test_timestamptz");
92110

111+
List<Type> partitionTypes = partitionRows.getTypes();
93112
assertTrue(partitionTypes.get(0) instanceof TimestampWithTimeZoneType);
94113
assertTrue(partitionTypes.get(1) instanceof TimestampType);
95114

115+
rows = partitionRows.getMaterializedRows();
116+
for (int i = 0; i < 10; i++) {
117+
assertEquals("[1984-12-08T08:10Z[UTC], 1984-12-08T00:10, 1984-12-08T08:10Z[UTC]]", rows.get(i).toString());
118+
}
119+
96120
String earlyTimestamptz = "TIMESTAMP '1980-12-08 00:10:00 America/Los_Angeles'";
97-
runner.execute("CREATE TABLE test_timestamptz_filter(a TIMESTAMP WITH TIME ZONE)");
121+
dropTableIfExists(runner, session.getCatalog().get(), session.getSchema().get(), "test_timestamptz_filter");
122+
assertQuerySucceeds(session, "CREATE TABLE test_timestamptz_filter(a TIMESTAMP WITH TIME ZONE)");
98123

99124
for (int i = 0; i < 5; i++) {
100-
runner.execute("INSERT INTO test_timestamptz_filter VALUES (" + earlyTimestamptz + ")");
125+
assertUpdate(session, "INSERT INTO test_timestamptz_filter VALUES (" + earlyTimestamptz + ")", 1);
101126
}
102127
for (int i = 0; i < 5; i++) {
103-
runner.execute("INSERT INTO test_timestamptz_filter VALUES (" + timestamptz + ")");
128+
assertUpdate(session, "INSERT INTO test_timestamptz_filter VALUES (" + timestamptz + ")", 1);
104129
}
105130

106-
MaterializedResult lateRows = runner.execute("SELECT a FROM test_timestamptz_filter WHERE a > " + earlyTimestamptz);
131+
MaterializedResult lateRows = runner.execute(session, "SELECT a FROM test_timestamptz_filter WHERE a > " + earlyTimestamptz);
107132
assertEquals(lateRows.getMaterializedRows().size(), 5);
108133

109-
MaterializedResult lateRowsFromEquals = runner.execute("SELECT a FROM test_timestamptz_filter WHERE a = " + timestamptz);
134+
MaterializedResult lateRowsFromEquals = runner.execute(session, "SELECT a FROM test_timestamptz_filter WHERE a = " + timestamptz);
110135
com.facebook.presto.testing.assertions.Assert.assertEquals(lateRows, lateRowsFromEquals);
111136

112-
MaterializedResult earlyRows = runner.execute("SELECT a FROM test_timestamptz_filter WHERE a < " + timestamptz);
137+
MaterializedResult earlyRows = runner.execute(session, "SELECT a FROM test_timestamptz_filter WHERE a < " + timestamptz);
113138
assertEquals(earlyRows.getMaterializedRows().size(), 5);
114139

115-
MaterializedResult earlyRowsFromEquals = runner.execute("SELECT a FROM test_timestamptz_filter WHERE a = " + earlyTimestamptz);
140+
MaterializedResult earlyRowsFromEquals = runner.execute(session, "SELECT a FROM test_timestamptz_filter WHERE a = " + earlyTimestamptz);
116141
com.facebook.presto.testing.assertions.Assert.assertEquals(earlyRows, earlyRowsFromEquals);
117142
}
118143

0 commit comments

Comments
 (0)