|
127 | 127 | import java.nio.ByteBuffer;
|
128 | 128 | import java.nio.charset.StandardCharsets;
|
129 | 129 | import java.nio.file.FileSystems;
|
| 130 | +import java.time.Instant; |
130 | 131 | import java.util.ArrayList;
|
131 | 132 | import java.util.Collection;
|
132 | 133 | import java.util.Collections;
|
@@ -1854,6 +1855,40 @@ public void testQuery() throws InterruptedException {
|
1854 | 1855 | assertNotNull(statistics.getQueryPlan());
|
1855 | 1856 | }
|
1856 | 1857 |
|
| 1858 | + @Test |
| 1859 | + public void testQueryTimeStamp() throws InterruptedException { |
| 1860 | + String query = "SELECT TIMESTAMP '2022-01-24T23:54:25.095574Z'"; |
| 1861 | + Instant beforeQueryInstant = Instant.parse("2022-01-24T23:54:25.095574Z"); |
| 1862 | + long microsBeforeQuery = |
| 1863 | + TimeUnit.SECONDS.toMicros(beforeQueryInstant.getEpochSecond()) |
| 1864 | + + TimeUnit.NANOSECONDS.toMicros(beforeQueryInstant.getNano()); |
| 1865 | + |
| 1866 | + // Verify that timestamp remains the same when priority is set to INTERACTIVE |
| 1867 | + TableResult result = |
| 1868 | + bigquery.query( |
| 1869 | + QueryJobConfiguration.newBuilder(query) |
| 1870 | + .setDefaultDataset(DatasetId.of(DATASET)) |
| 1871 | + .setPriority(QueryJobConfiguration.Priority.INTERACTIVE) |
| 1872 | + .build()); |
| 1873 | + for (FieldValueList row : result.getValues()) { |
| 1874 | + FieldValue timeStampCell = row.get(0); |
| 1875 | + long microsAfterQuery = timeStampCell.getTimestampValue(); |
| 1876 | + assertEquals(microsBeforeQuery, microsAfterQuery); |
| 1877 | + } |
| 1878 | + |
| 1879 | + // Verify that timestamp remains the same without priority set to INTERACTIVE |
| 1880 | + TableResult resultInteractive = |
| 1881 | + bigquery.query( |
| 1882 | + QueryJobConfiguration.newBuilder(query) |
| 1883 | + .setDefaultDataset(DatasetId.of(DATASET)) |
| 1884 | + .build()); |
| 1885 | + for (FieldValueList row : resultInteractive.getValues()) { |
| 1886 | + FieldValue timeStampCell = row.get(0); |
| 1887 | + long microsAfterQuery = timeStampCell.getTimestampValue(); |
| 1888 | + assertEquals(microsBeforeQuery, microsAfterQuery); |
| 1889 | + } |
| 1890 | + } |
| 1891 | + |
1857 | 1892 | @Test
|
1858 | 1893 | public void testQueryCaseInsensitiveSchemaFieldByGetName() throws InterruptedException {
|
1859 | 1894 | String query = "SELECT TimestampField, StringField, BooleanField FROM " + TABLE_ID.getTable();
|
|
0 commit comments