|
42 | 42 | import java.util.HashMap; |
43 | 43 | import java.util.List; |
44 | 44 | import java.util.Map; |
| 45 | +import java.util.Objects; |
45 | 46 | import java.util.stream.Collectors; |
46 | 47 |
|
47 | 48 | import static org.apache.paimon.options.CatalogOptions.FORMAT_TABLE_ENABLED; |
@@ -119,46 +120,56 @@ public void evaluate() throws Throwable { |
119 | 120 |
|
120 | 121 | @Test |
121 | 122 | public void testCsvFormatTable() throws Exception { |
122 | | - hiveShell.execute("CREATE TABLE csv_table (a INT, b STRING)"); |
| 123 | + hiveShell.execute( |
| 124 | + "CREATE TABLE csv_table (a INT COMMENT 'comment a', b STRING COMMENT 'comment b')"); |
123 | 125 | doTestFormatTable("csv_table"); |
124 | 126 | } |
125 | 127 |
|
126 | 128 | @Test |
127 | 129 | public void testCsvFormatTableWithDelimiter() throws Exception { |
128 | 130 | hiveShell.execute( |
129 | | - "CREATE TABLE csv_table_delimiter (a INT, b STRING) ROW FORMAT DELIMITED FIELDS TERMINATED BY ';'"); |
| 131 | + "CREATE TABLE csv_table_delimiter (a INT COMMENT 'comment a', b STRING COMMENT 'comment b') ROW FORMAT DELIMITED FIELDS TERMINATED BY ';'"); |
130 | 132 | doTestFormatTable("csv_table_delimiter"); |
131 | 133 | } |
132 | 134 |
|
133 | 135 | @Test |
134 | 136 | public void testPartitionTable() throws Exception { |
135 | | - hiveShell.execute("CREATE TABLE partition_table (a INT) PARTITIONED BY (b STRING)"); |
| 137 | + hiveShell.execute( |
| 138 | + "CREATE TABLE partition_table (a INT COMMENT 'comment a') PARTITIONED BY (b STRING COMMENT 'comment b')"); |
136 | 139 | doTestFormatTable("partition_table"); |
137 | 140 | } |
138 | 141 |
|
139 | 142 | @Test |
140 | 143 | public void testFlinkCreateCsvFormatTable() throws Exception { |
141 | 144 | tEnv.executeSql( |
142 | | - "CREATE TABLE flink_csv_table (a INT, b STRING) with ('type'='format-table', 'file.format'='csv')") |
| 145 | + "CREATE TABLE flink_csv_table (a INT COMMENT 'comment a', b STRING COMMENT 'comment b') with ('type'='format-table', 'file.format'='csv')") |
143 | 146 | .await(); |
144 | 147 | doTestFormatTable("flink_csv_table"); |
145 | 148 | } |
146 | 149 |
|
147 | 150 | @Test |
148 | 151 | public void testFlinkCreateFormatTableWithDelimiter() throws Exception { |
149 | 152 | tEnv.executeSql( |
150 | | - "CREATE TABLE flink_csv_table_delimiter (a INT, b STRING) with ('type'='format-table', 'file.format'='csv', 'field-delimiter'=';')"); |
| 153 | + "CREATE TABLE flink_csv_table_delimiter (a INT COMMENT 'comment a', b STRING COMMENT 'comment b') with ('type'='format-table', 'file.format'='csv', 'field-delimiter'=';')"); |
151 | 154 | doTestFormatTable("flink_csv_table_delimiter"); |
152 | 155 | } |
153 | 156 |
|
154 | 157 | @Test |
155 | 158 | public void testFlinkCreatePartitionTable() throws Exception { |
156 | 159 | tEnv.executeSql( |
157 | | - "CREATE TABLE flink_partition_table (a INT,b STRING) PARTITIONED BY (b) with ('type'='format-table', 'file.format'='csv')"); |
| 160 | + "CREATE TABLE flink_partition_table (a INT COMMENT 'comment a', b STRING COMMENT 'comment b') PARTITIONED BY (b) with ('type'='format-table', 'file.format'='csv')"); |
158 | 161 | doTestFormatTable("flink_partition_table"); |
159 | 162 | } |
160 | 163 |
|
161 | 164 | private void doTestFormatTable(String tableName) throws Exception { |
| 165 | + List<String> descResult = |
| 166 | + collect("DESC " + tableName).stream() |
| 167 | + .map(Objects::toString) |
| 168 | + .collect(Collectors.toList()); |
| 169 | + assertThat(descResult) |
| 170 | + .containsExactly( |
| 171 | + "+I[a, INT, true, null, null, null, comment a]", |
| 172 | + "+I[b, STRING, true, null, null, null, comment b]"); |
162 | 173 | hiveShell.execute( |
163 | 174 | String.format("INSERT INTO %s VALUES (100, 'Hive'), (200, 'Table')", tableName)); |
164 | 175 | assertThat(collect(String.format("SELECT * FROM %s", tableName))) |
|
0 commit comments