@@ -1903,6 +1903,41 @@ public void testCreateAndGetTable() {
|
1903 | 1903 | assertTrue(remoteTable.delete()); |
1904 | 1904 | } |
1905 | 1905 | |
| 1906 | +@Test |
| 1907 | +public void testCreateAndListTable() { |
| 1908 | +String tableName = "test_create_and_list_table"; |
| 1909 | +TableId tableId = TableId.of(DATASET, tableName); |
| 1910 | +TimePartitioning partitioning = TimePartitioning.of(Type.DAY); |
| 1911 | +Clustering clustering = |
| 1912 | +Clustering.newBuilder().setFields(ImmutableList.of(STRING_FIELD_SCHEMA.getName())).build(); |
| 1913 | +StandardTableDefinition tableDefinition = |
| 1914 | +StandardTableDefinition.newBuilder() |
| 1915 | + .setSchema(TABLE_SCHEMA) |
| 1916 | + .setTimePartitioning(partitioning) |
| 1917 | + .setClustering(clustering) |
| 1918 | + .build(); |
| 1919 | +Table createdTable = bigquery.create(TableInfo.of(tableId, tableDefinition)); |
| 1920 | +assertNotNull(createdTable); |
| 1921 | +assertEquals(DATASET, createdTable.getTableId().getDataset()); |
| 1922 | +assertEquals(tableName, createdTable.getTableId().getTable()); |
| 1923 | + |
| 1924 | +Page<Table> tables = bigquery.listTables(DATASET); |
| 1925 | +boolean found = false; |
| 1926 | +Iterator<Table> tableIterator = tables.getValues().iterator(); |
| 1927 | +// Find createdTable and validate the table definition. |
| 1928 | +while (tableIterator.hasNext() && !found) { |
| 1929 | +Table table = tableIterator.next(); |
| 1930 | +if (table.getTableId().equals(createdTable.getTableId())) { |
| 1931 | +StandardTableDefinition definition = table.getDefinition(); |
| 1932 | +assertThat(definition.getClustering()).isNotNull(); |
| 1933 | +assertThat(definition.getTimePartitioning()).isNotNull(); |
| 1934 | +found = true; |
| 1935 | + } |
| 1936 | + } |
| 1937 | +assertTrue(found); |
| 1938 | +assertTrue(createdTable.delete()); |
| 1939 | + } |
| 1940 | + |
1906 | 1941 | @Test |
1907 | 1942 | public void testCreateAndGetTableWithBasicTableMetadataView() { |
1908 | 1943 | String tableName = "test_create_and_get_table_with_basic_metadata_view"; |
|