|
13 | 13 | */
|
14 | 14 | package com.facebook.presto.iceberg;
|
15 | 15 |
|
| 16 | +import com.facebook.presto.Session; |
16 | 17 | import com.facebook.presto.common.type.TimestampType;
|
17 | 18 | import com.facebook.presto.common.type.TimestampWithTimeZoneType;
|
18 | 19 | import com.facebook.presto.common.type.Type;
|
19 | 20 | import com.facebook.presto.testing.MaterializedResult;
|
| 21 | +import com.facebook.presto.testing.MaterializedRow; |
20 | 22 | import com.facebook.presto.testing.QueryRunner;
|
21 | 23 | import com.facebook.presto.tests.AbstractTestQueryFramework;
|
22 | 24 | import com.google.common.collect.ImmutableMap;
|
@@ -59,60 +61,83 @@ protected QueryRunner createQueryRunner() throws Exception
|
59 | 61 | @DataProvider(name = "testTimestampWithTimezone")
|
60 | 62 | public Object[][] createTestTimestampWithTimezoneData()
|
61 | 63 | {
|
| 64 | + //return new Object[][] { |
| 65 | + // {getQueryRunner()}, |
| 66 | + // {getBatchReaderEnabledQueryRunner()} |
| 67 | + //}; |
62 | 68 | 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()} |
65 | 75 | };
|
66 | 76 | }
|
67 | 77 |
|
68 | 78 | @Test(dataProvider = "testTimestampWithTimezone")
|
69 |
| - public void testTimestampWithTimezone(QueryRunner runner) |
| 79 | + public void testTimestampWithTimezone(Session session) |
70 | 80 | {
|
| 81 | + QueryRunner runner = getQueryRunner(); |
71 | 82 | String timestamptz = "TIMESTAMP '1984-12-08 00:10:00 America/Los_Angeles'";
|
72 | 83 | String timestamp = "TIMESTAMP '1984-12-08 00:10:00'";
|
73 | 84 |
|
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 | + |
75 | 88 | String row = "(" + timestamptz + ", " + timestamp + ", " + timestamptz + ")";
|
76 | 89 | 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); |
78 | 91 | }
|
79 | 92 |
|
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"); |
82 | 94 |
|
| 95 | + List<Type> types = initialRows.getTypes(); |
83 | 96 | assertTrue(types.get(0) instanceof TimestampWithTimeZoneType);
|
84 | 97 | assertTrue(types.get(1) instanceof TimestampType);
|
85 | 98 |
|
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) " + |
87 | 106 | "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); |
89 | 108 |
|
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"); |
92 | 110 |
|
| 111 | + List<Type> partitionTypes = partitionRows.getTypes(); |
93 | 112 | assertTrue(partitionTypes.get(0) instanceof TimestampWithTimeZoneType);
|
94 | 113 | assertTrue(partitionTypes.get(1) instanceof TimestampType);
|
95 | 114 |
|
| 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 | + |
96 | 120 | 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)"); |
98 | 123 |
|
99 | 124 | 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); |
101 | 126 | }
|
102 | 127 | 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); |
104 | 129 | }
|
105 | 130 |
|
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); |
107 | 132 | assertEquals(lateRows.getMaterializedRows().size(), 5);
|
108 | 133 |
|
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); |
110 | 135 | com.facebook.presto.testing.assertions.Assert.assertEquals(lateRows, lateRowsFromEquals);
|
111 | 136 |
|
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); |
113 | 138 | assertEquals(earlyRows.getMaterializedRows().size(), 5);
|
114 | 139 |
|
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); |
116 | 141 | com.facebook.presto.testing.assertions.Assert.assertEquals(earlyRows, earlyRowsFromEquals);
|
117 | 142 | }
|
118 | 143 |
|
|
0 commit comments