OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ForeignTableTest.java
Go to the documentation of this file.
1 package com.mapd.parser.extension.ddl;
2 
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.fail;
5 
6 import com.google.gson.Gson;
7 import com.google.gson.JsonObject;
9 
10 import org.junit.Test;
11 
12 import ai.heavy.thrift.calciteserver.InvalidParseRequest;
13 import ai.heavy.thrift.calciteserver.TPlanResult;
14 
15 public class ForeignTableTest extends DDLTest {
16  public ForeignTableTest() {
17  resourceDirPath = ForeignTableTest.class.getClassLoader().getResource("").getPath();
18  jsonTestDir = "foreigntable";
19  }
20 
21  @Test
22  public void createForeignTableOneCol() throws Exception {
23  final JsonObject expectedJsonObject = getJsonFromFile("cft_OneCol.json");
24  final TPlanResult result = processDdlCommand(
25  "CREATE FOREIGN TABLE test_table (test_column_1 INTEGER) SERVER test_server;");
26  final JsonObject actualJsonObject =
27  gson.fromJson(result.plan_result, JsonObject.class);
28  assertEquals(expectedJsonObject, actualJsonObject);
29  }
30 
31  @Test
32  public void createForeignTableDecimal() throws Exception {
33  final JsonObject expectedJsonObject = getJsonFromFile("cft_Decimal.json");
34  final TPlanResult result = processDdlCommand(
35  "CREATE FOREIGN TABLE test_table (test_column_1 DECIMAL(10, 6)) SERVER test_server;");
36  final JsonObject actualJsonObject =
37  gson.fromJson(result.plan_result, JsonObject.class);
38  assertEquals(expectedJsonObject, actualJsonObject);
39  }
40 
41  @Test(expected = InvalidParseRequest.class)
42  public void createForeignTableDoubleDecimal() throws Exception {
43  final JsonObject expectedJsonObject = getJsonFromFile("cft_Decimal.json");
44  final TPlanResult result = processDdlCommand(
45  "CREATE FOREIGN TABLE test_table (test_column_1 DECIMAL(10, 6)(11,5)) SERVER test_server;");
46  final JsonObject actualJsonObject =
47  gson.fromJson(result.plan_result, JsonObject.class);
48  assertEquals(expectedJsonObject, actualJsonObject);
49  }
50 
51  @Test
52  public void createForeignTableIfNotExists() throws Exception {
53  final JsonObject expectedJsonObject = getJsonFromFile("cft_IfNotExists.json");
54  final TPlanResult result = processDdlCommand(
55  "CREATE FOREIGN TABLE IF NOT EXISTS test_table (test_column_1 INTEGER) "
56  + "SERVER test_server;");
57  final JsonObject actualJsonObject =
58  gson.fromJson(result.plan_result, JsonObject.class);
59  assertEquals(expectedJsonObject, actualJsonObject);
60  }
61 
62  @Test
63  public void createForeignTableTwoCol() throws Exception {
64  final JsonObject expectedJsonObject = getJsonFromFile("cft_TwoCol.json");
65  final TPlanResult result = processDdlCommand(
66  "CREATE FOREIGN TABLE test_table (test_column_1 INTEGER, test_column_2 TEXT) "
67  + "SERVER test_server;");
68  final JsonObject actualJsonObject =
69  gson.fromJson(result.plan_result, JsonObject.class);
70  assertEquals(expectedJsonObject, actualJsonObject);
71  }
72 
73  @Test
74  public void createForeignTableNotNull() throws Exception {
75  final JsonObject expectedJsonObject = getJsonFromFile("cft_NotNull.json");
76  final TPlanResult result = processDdlCommand(
77  "CREATE FOREIGN TABLE test_table (test_column_1 INTEGER NOT NULL) "
78  + "SERVER test_server;");
79  final JsonObject actualJsonObject =
80  gson.fromJson(result.plan_result, JsonObject.class);
81  assertEquals(expectedJsonObject, actualJsonObject);
82  }
83 
84  @Test
85  public void createForeignTableEncodingDict8() throws Exception {
86  final JsonObject expectedJsonObject = getJsonFromFile("cft_Encoding_Dict8.json");
87  final TPlanResult result = processDdlCommand(
88  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING DICT(8)) "
89  + "SERVER test_server");
90  final JsonObject actualJsonObject =
91  gson.fromJson(result.plan_result, JsonObject.class);
92  assertEquals(expectedJsonObject, actualJsonObject);
93  }
94 
95  @Test
96  public void createForeignTableEncodingDict() throws Exception {
97  final JsonObject expectedJsonObject = getJsonFromFile("cft_Encoding_Dict.json");
98  final TPlanResult result = processDdlCommand(
99  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING DICT) "
100  + "SERVER test_server");
101  final JsonObject actualJsonObject =
102  gson.fromJson(result.plan_result, JsonObject.class);
103  assertEquals(expectedJsonObject, actualJsonObject);
104  }
105 
106  @Test
107  public void createForeignTableEncodingNone() throws Exception {
108  final JsonObject expectedJsonObject = getJsonFromFile("cft_Encoding_None.json");
109  final TPlanResult result = processDdlCommand(
110  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING NONE) "
111  + "SERVER test_server");
112  final JsonObject actualJsonObject =
113  gson.fromJson(result.plan_result, JsonObject.class);
114  assertEquals(expectedJsonObject, actualJsonObject);
115  }
116 
117  @Test
118  public void createForeignTableEncodingFixed1() throws Exception {
119  final JsonObject expectedJsonObject = getJsonFromFile("cft_Encoding_Fixed1.json");
120  final TPlanResult result = processDdlCommand(
121  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING FIXED(1)) "
122  + "SERVER test_server");
123  final JsonObject actualJsonObject =
124  gson.fromJson(result.plan_result, JsonObject.class);
125  assertEquals(expectedJsonObject, actualJsonObject);
126  }
127 
128  @Test
129  public void createForeignTableEncodingDays1() throws Exception {
130  final JsonObject expectedJsonObject = getJsonFromFile("cft_Encoding_Days1.json");
131  final TPlanResult result = processDdlCommand(
132  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING DAYS(1)) "
133  + "SERVER test_server");
134  final JsonObject actualJsonObject =
135  gson.fromJson(result.plan_result, JsonObject.class);
136  assertEquals(expectedJsonObject, actualJsonObject);
137  }
138 
139  @Test
140  public void createForeignTableEncodingCompressed32() throws Exception {
141  final JsonObject expectedJsonObject =
142  getJsonFromFile("cft_Encoding_Compressed32.json");
143  final TPlanResult result = processDdlCommand(
144  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING COMPRESSED(32)) "
145  + "SERVER test_server");
146  final JsonObject actualJsonObject =
147  gson.fromJson(result.plan_result, JsonObject.class);
148  assertEquals(expectedJsonObject, actualJsonObject);
149  }
150 
151  @Test
152  public void createForeignTableEncodingCompressed() throws Exception {
153  final JsonObject expectedJsonObject = getJsonFromFile("cft_Encoding_Compressed.json");
154  final TPlanResult result = processDdlCommand(
155  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING COMPRESSED) "
156  + "SERVER test_server");
157  final JsonObject actualJsonObject =
158  gson.fromJson(result.plan_result, JsonObject.class);
159  assertEquals(expectedJsonObject, actualJsonObject);
160  }
161 
162  @Test(expected = InvalidParseRequest.class)
163  public void createForeignTableEncodingNone1() throws Exception {
164  final TPlanResult result = processDdlCommand(
165  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING NONE(1)) "
166  + "SERVER test_server");
167  }
168 
169  @Test(expected = InvalidParseRequest.class)
170  public void createForeignTableEncodingFixedWithoutSize() throws Exception {
171  final TPlanResult result = processDdlCommand(
172  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING FIXED) "
173  + "SERVER test_server");
174  }
175 
176  @Test(expected = InvalidParseRequest.class)
177  public void createForeignTableEncodingDaysWithoutSize() throws Exception {
178  final TPlanResult result = processDdlCommand(
179  "CREATE FOREIGN TABLE test_table (test_column_1 TEXT ENCODING DAYS) "
180  + "SERVER test_server");
181  }
182 
183  @Test
184  public void createForeignTableColOptions() throws Exception {
185  final JsonObject expectedJsonObject = getJsonFromFile("cft_ColOptions.json");
186  final TPlanResult result =
187  processDdlCommand("CREATE FOREIGN TABLE test_table (test_column_1 INTEGER "
188  + "WITH ( option_1 = 'value_1', option_2 = 2)) SERVER test_server;");
189  final JsonObject actualJsonObject =
190  gson.fromJson(result.plan_result, JsonObject.class);
191  assertEquals(expectedJsonObject, actualJsonObject);
192  }
193 
194  @Test
195  public void createForeignTableOptions() throws Exception {
196  final JsonObject expectedJsonObject = getJsonFromFile("cft_Options.json");
197  final TPlanResult result =
198  processDdlCommand("CREATE FOREIGN TABLE test_table (test_column_1 INTEGER) "
199  + "SERVER test_server WITH ( option_1 = 'value_1', option_2 = 2);");
200  final JsonObject actualJsonObject =
201  gson.fromJson(result.plan_result, JsonObject.class);
202  assertEquals(expectedJsonObject, actualJsonObject);
203  }
204 
205  @Test
206  public void createForeignTableEscapeOption() throws Exception {
207  final JsonObject expectedJsonObject = getJsonFromFile("cft_EscapeOption.json");
208  final TPlanResult result =
209  processDdlCommand("CREATE FOREIGN TABLE test_table (test_column_1 INTEGER) "
210  + "SERVER test_server WITH ( escape = '\\');");
211  final JsonObject actualJsonObject =
212  gson.fromJson(result.plan_result, JsonObject.class);
213  assertEquals(expectedJsonObject, actualJsonObject);
214  }
215 
216  @Test
217  public void createForeignTableSchema() throws Exception {
218  final JsonObject expectedJsonObject = getJsonFromFile("cft_Schema.json");
219  final TPlanResult result =
220  processDdlCommand("CREATE FOREIGN TABLE test_table SCHEMA 'test_schema' "
221  + "SERVER test_server;");
222  final JsonObject actualJsonObject =
223  gson.fromJson(result.plan_result, JsonObject.class);
224  assertEquals(expectedJsonObject, actualJsonObject);
225  }
226 
227  @Test
228  public void createForeignTablePoint() throws Exception {
229  final JsonObject expectedJsonObject = getJsonFromFile("cft_Point.json");
230  final TPlanResult result = processDdlCommand(
231  "CREATE FOREIGN TABLE test_table (test_column_1 POINT) SERVER test_server;");
232  final JsonObject actualJsonObject =
233  gson.fromJson(result.plan_result, JsonObject.class);
234  assertEquals(expectedJsonObject, actualJsonObject);
235  }
236 
237  @Test
238  public void createForeignTableGeoPoint() throws Exception {
239  final JsonObject expectedJsonObject = getJsonFromFile("cft_Point.json");
240  final TPlanResult result = processDdlCommand(
241  "CREATE FOREIGN TABLE test_table (test_column_1 GEOMETRY(POINT)) SERVER test_server;");
242  final JsonObject actualJsonObject =
243  gson.fromJson(result.plan_result, JsonObject.class);
244  assertEquals(expectedJsonObject, actualJsonObject);
245  }
246 
247  @Test
248  public void createForeignTableMultiPoint() throws Exception {
249  final JsonObject expectedJsonObject = getJsonFromFile("cft_MultiPoint.json");
250  final TPlanResult result = processDdlCommand(
251  "CREATE FOREIGN TABLE test_table (test_column_1 MULTIPOINT) SERVER test_server;");
252  final JsonObject actualJsonObject =
253  gson.fromJson(result.plan_result, JsonObject.class);
254  assertEquals(expectedJsonObject, actualJsonObject);
255  }
256 
257  @Test
258  public void createForeignTableLinestring() throws Exception {
259  final JsonObject expectedJsonObject = getJsonFromFile("cft_Linestring.json");
260  final TPlanResult result = processDdlCommand(
261  "CREATE FOREIGN TABLE test_table (test_column_1 LINESTRING) SERVER test_server;");
262  final JsonObject actualJsonObject =
263  gson.fromJson(result.plan_result, JsonObject.class);
264  assertEquals(expectedJsonObject, actualJsonObject);
265  }
266 
267  @Test
268  public void createForeignTableMultiLinestring() throws Exception {
269  final JsonObject expectedJsonObject = getJsonFromFile("cft_MultiLinestring.json");
270  final TPlanResult result = processDdlCommand(
271  "CREATE FOREIGN TABLE test_table (test_column_1 MULTILINESTRING) SERVER test_server;");
272  final JsonObject actualJsonObject =
273  gson.fromJson(result.plan_result, JsonObject.class);
274  assertEquals(expectedJsonObject, actualJsonObject);
275  }
276 
277  @Test
278  public void createForeignTablePolygon() throws Exception {
279  final JsonObject expectedJsonObject = getJsonFromFile("cft_Polygon.json");
280  final TPlanResult result = processDdlCommand(
281  "CREATE FOREIGN TABLE test_table (test_column_1 POLYGON) SERVER test_server;");
282  final JsonObject actualJsonObject =
283  gson.fromJson(result.plan_result, JsonObject.class);
284  assertEquals(expectedJsonObject, actualJsonObject);
285  }
286 
287  @Test
288  public void createForeignTableMultiPolygon() throws Exception {
289  final JsonObject expectedJsonObject = getJsonFromFile("cft_MultiPolygon.json");
290  final TPlanResult result = processDdlCommand(
291  "CREATE FOREIGN TABLE test_table (test_column_1 MULTIPOLYGON) SERVER test_server;");
292  final JsonObject actualJsonObject =
293  gson.fromJson(result.plan_result, JsonObject.class);
294  assertEquals(expectedJsonObject, actualJsonObject);
295  }
296 
297  @Test
298  public void createForeignTableGeoPointMerc() throws Exception {
299  final JsonObject expectedJsonObject = getJsonFromFile("cft_GeoPointMerc.json");
300  final TPlanResult result = processDdlCommand(
301  "CREATE FOREIGN TABLE test_table (test_column_1 GEOMETRY(POINT, 900913)) SERVER test_server;");
302  final JsonObject actualJsonObject =
303  gson.fromJson(result.plan_result, JsonObject.class);
304  assertEquals(expectedJsonObject, actualJsonObject);
305  }
306 
307  @Test
308  public void createForeignTableGeoPointWG() throws Exception {
309  final JsonObject expectedJsonObject = getJsonFromFile("cft_GeoPointWG.json");
310  final TPlanResult result = processDdlCommand(
311  "CREATE FOREIGN TABLE test_table (test_column_1 GEOMETRY(POINT, 4326)) SERVER test_server;");
312  final JsonObject actualJsonObject =
313  gson.fromJson(result.plan_result, JsonObject.class);
314  assertEquals(expectedJsonObject, actualJsonObject);
315  }
316 
317  @Test
318  public void createForeignTablePointCompressed() throws Exception {
319  final JsonObject expectedJsonObject = getJsonFromFile("cft_PointCompressed.json");
320  final TPlanResult result = processDdlCommand(
321  "CREATE FOREIGN TABLE test_table (test_column_1 POINT ENCODING COMPRESSED(32)) SERVER test_server;");
322  final JsonObject actualJsonObject =
323  gson.fromJson(result.plan_result, JsonObject.class);
324  assertEquals(expectedJsonObject, actualJsonObject);
325  }
326 
327  @Test
328  public void createForeignTableBigInt() throws Exception {
329  final JsonObject expectedJsonObject = getJsonFromFile("cft_BigInt.json");
330  final TPlanResult result = processDdlCommand(
331  "CREATE FOREIGN TABLE test_table (test_column_1 BIGINT) SERVER test_server;");
332  final JsonObject actualJsonObject =
333  gson.fromJson(result.plan_result, JsonObject.class);
334  assertEquals(expectedJsonObject, actualJsonObject);
335  }
336 
337  @Test
338  public void createForeignTableBoolean() throws Exception {
339  final JsonObject expectedJsonObject = getJsonFromFile("cft_Boolean.json");
340  final TPlanResult result = processDdlCommand(
341  "CREATE FOREIGN TABLE test_table (test_column_1 BOOLEAN) SERVER test_server;");
342  final JsonObject actualJsonObject =
343  gson.fromJson(result.plan_result, JsonObject.class);
344  assertEquals(expectedJsonObject, actualJsonObject);
345  }
346 
347  @Test
348  public void createForeignTableDate() throws Exception {
349  final JsonObject expectedJsonObject = getJsonFromFile("cft_Date.json");
350  final TPlanResult result = processDdlCommand(
351  "CREATE FOREIGN TABLE test_table (test_column_1 DATE) SERVER test_server;");
352  final JsonObject actualJsonObject =
353  gson.fromJson(result.plan_result, JsonObject.class);
354  assertEquals(expectedJsonObject, actualJsonObject);
355  }
356 
357  @Test
358  public void createForeignTableDouble() throws Exception {
359  final JsonObject expectedJsonObject = getJsonFromFile("cft_Double.json");
360  final TPlanResult result = processDdlCommand(
361  "CREATE FOREIGN TABLE test_table (test_column_1 DOUBLE) SERVER test_server;");
362  final JsonObject actualJsonObject =
363  gson.fromJson(result.plan_result, JsonObject.class);
364  assertEquals(expectedJsonObject, actualJsonObject);
365  }
366 
367  @Test
368  public void createForeignTableEpoch() throws Exception {
369  final JsonObject expectedJsonObject = getJsonFromFile("cft_Epoch.json");
370  final TPlanResult result = processDdlCommand(
371  "CREATE FOREIGN TABLE test_table (test_column_1 EPOCH) SERVER test_server;");
372  final JsonObject actualJsonObject =
373  gson.fromJson(result.plan_result, JsonObject.class);
374  assertEquals(expectedJsonObject, actualJsonObject);
375  }
376 
377  @Test
378  public void createForeignTableFloat() throws Exception {
379  final JsonObject expectedJsonObject = getJsonFromFile("cft_Float.json");
380  final TPlanResult result = processDdlCommand(
381  "CREATE FOREIGN TABLE test_table (test_column_1 FLOAT) SERVER test_server;");
382  final JsonObject actualJsonObject =
383  gson.fromJson(result.plan_result, JsonObject.class);
384  assertEquals(expectedJsonObject, actualJsonObject);
385  }
386 
387  @Test
388  public void createForeignTableSmallInt() throws Exception {
389  final JsonObject expectedJsonObject = getJsonFromFile("cft_SmallInt.json");
390  final TPlanResult result = processDdlCommand(
391  "CREATE FOREIGN TABLE test_table (test_column_1 SMALLINT) SERVER test_server;");
392  final JsonObject actualJsonObject =
393  gson.fromJson(result.plan_result, JsonObject.class);
394  assertEquals(expectedJsonObject, actualJsonObject);
395  }
396 
397  @Test
398  public void createForeignTableTime() throws Exception {
399  final JsonObject expectedJsonObject = getJsonFromFile("cft_Time.json");
400  final TPlanResult result = processDdlCommand(
401  "CREATE FOREIGN TABLE test_table (test_column_1 TIME) SERVER test_server;");
402  final JsonObject actualJsonObject =
403  gson.fromJson(result.plan_result, JsonObject.class);
404  assertEquals(expectedJsonObject, actualJsonObject);
405  }
406 
407  @Test
408  public void createForeignTableTimestamp() throws Exception {
409  final JsonObject expectedJsonObject = getJsonFromFile("cft_TimeStamp.json");
410  final TPlanResult result = processDdlCommand(
411  "CREATE FOREIGN TABLE test_table (test_column_1 TIMESTAMP) SERVER test_server;");
412  final JsonObject actualJsonObject =
413  gson.fromJson(result.plan_result, JsonObject.class);
414  assertEquals(expectedJsonObject, actualJsonObject);
415  }
416 
417  @Test
418  public void createForeignTableTinyInt() throws Exception {
419  final JsonObject expectedJsonObject = getJsonFromFile("cft_TinyInt.json");
420  final TPlanResult result = processDdlCommand(
421  "CREATE FOREIGN TABLE test_table (test_column_1 TINYINT) SERVER test_server;");
422  final JsonObject actualJsonObject =
423  gson.fromJson(result.plan_result, JsonObject.class);
424  assertEquals(expectedJsonObject, actualJsonObject);
425  }
426 
427  @Test
428  public void createForeignTableArraySized() throws Exception {
429  final JsonObject expectedJsonObject = getJsonFromFile("cft_ArraySized.json");
430  final TPlanResult result = processDdlCommand(
431  "CREATE FOREIGN TABLE test_table (test_column_1 INTEGER[5]) SERVER test_server;");
432  final JsonObject actualJsonObject =
433  gson.fromJson(result.plan_result, JsonObject.class);
434  assertEquals(expectedJsonObject, actualJsonObject);
435  }
436 
437  @Test
438  public void createForeignTableArrayUnsized() throws Exception {
439  final JsonObject expectedJsonObject = getJsonFromFile("cft_ArrayUnsized.json");
440  final TPlanResult result = processDdlCommand(
441  "CREATE FOREIGN TABLE test_table (test_column_1 INTEGER[]) SERVER test_server;");
442  final JsonObject actualJsonObject =
443  gson.fromJson(result.plan_result, JsonObject.class);
444  assertEquals(expectedJsonObject, actualJsonObject);
445  }
446 
447  @Test
448  public void dropForeignTable() throws Exception {
449  final JsonObject expectedJsonObject = getJsonFromFile("dft.json");
450  final TPlanResult result = processDdlCommand("DROP FOREIGN TABLE test_table;");
451  final JsonObject actualJsonObject =
452  gson.fromJson(result.plan_result, JsonObject.class);
453  assertEquals(expectedJsonObject, actualJsonObject);
454  }
455 
456  @Test
457  public void dropForeignTableIfExists() throws Exception {
458  final JsonObject expectedJsonObject = getJsonFromFile("dft_ifExists.json");
459  final TPlanResult result =
460  processDdlCommand("DROP FOREIGN TABLE IF EXISTS test_table;");
461  final JsonObject actualJsonObject =
462  gson.fromJson(result.plan_result, JsonObject.class);
463  assertEquals(expectedJsonObject, actualJsonObject);
464  }
465 
466  @Test
467  public void refresh_foreign_table() throws Exception {
468  final JsonObject expectedJsonObject = getJsonFromFile("refresh_foreign_table.json");
469  final TPlanResult result = processDdlCommand("REFRESH FOREIGN TABLES test_table");
470  final JsonObject actualJsonObject =
471  gson.fromJson(result.plan_result, JsonObject.class);
472  assertEquals(expectedJsonObject, actualJsonObject);
473  }
474 
475  @Test
476  public void refresh_foreign_tables() throws Exception {
477  final JsonObject expectedJsonObject = getJsonFromFile("refresh_foreign_tables.json");
478  final TPlanResult result =
479  processDdlCommand("REFRESH FOREIGN TABLES test_table, test_table2");
480  final JsonObject actualJsonObject =
481  gson.fromJson(result.plan_result, JsonObject.class);
482  assertEquals(expectedJsonObject, actualJsonObject);
483  }
484 
485  @Test
486  public void refresh_foreign_table_with_evict() throws Exception {
487  final JsonObject expectedJsonObject =
488  getJsonFromFile("refresh_foreign_table_with_evict.json");
489  final TPlanResult result =
490  processDdlCommand("REFRESH FOREIGN TABLES test_table WITH (evict = 'true')");
491  final JsonObject actualJsonObject =
492  gson.fromJson(result.plan_result, JsonObject.class);
493  assertEquals(expectedJsonObject, actualJsonObject);
494  }
495 
496  @Test
497  public void alterForeignTableSetOptions() throws Exception {
498  final JsonObject expectedJsonObject =
499  getJsonFromFile("alter_foreign_table_set_options.json");
500  final TPlanResult result = processDdlCommand(
501  "ALTER FOREIGN TABLE test_table SET (base_path = '/home/my_user/data/new-csv/');");
502  final JsonObject actualJsonObject =
503  gson.fromJson(result.plan_result, JsonObject.class);
504  assertEquals(expectedJsonObject, actualJsonObject);
505  }
506 
507  @Test
508  public void alterForeignTableRenameTable() throws Exception {
509  final JsonObject expectedJsonObject =
510  getJsonFromFile("alter_foreign_table_rename_table.json");
511  final TPlanResult result =
512  processDdlCommand("ALTER FOREIGN TABLE test_table RENAME TO new_test_table;");
513  final JsonObject actualJsonObject =
514  gson.fromJson(result.plan_result, JsonObject.class);
515  assertEquals(expectedJsonObject, actualJsonObject);
516  }
517 
518  @Test
519  public void alterForeignTableRenameColumn() throws Exception {
520  final JsonObject expectedJsonObject =
521  getJsonFromFile("alter_foreign_table_rename_column.json");
522  final TPlanResult result = processDdlCommand(
523  "ALTER FOREIGN TABLE test_table RENAME COLUMN old_column TO new_column;");
524  final JsonObject actualJsonObject =
525  gson.fromJson(result.plan_result, JsonObject.class);
526  assertEquals(expectedJsonObject, actualJsonObject);
527  }
528 }
JsonObject getJsonFromFile(final String fileName)
Definition: DDLTest.java:51
TPlanResult processDdlCommand(final String ddlCommand)
Definition: DDLTest.java:35