1 package com.mapd.parser.extension.ddl;
3 import static org.junit.Assert.assertEquals;
5 import com.google.gson.Gson;
6 import com.google.gson.JsonObject;
11 import ai.heavy.thrift.calciteserver.TPlanResult;
15 resourceDirPath = ForeignServerTest.class.getClassLoader().getResource(
"").getPath();
21 final JsonObject expectedJsonObject =
24 "ALTER SERVER test_server SET FOREIGN DATA WRAPPER DELIMITED_FILE;");
25 final JsonObject actualJsonObject =
26 gson.fromJson(result.plan_result, JsonObject.class);
28 assertEquals(expectedJsonObject, actualJsonObject);
33 final JsonObject expectedJsonObject =
36 "ALTER SERVER my_csv_server SET (base_path = '/home/my_user/data/new-csv/');");
37 final JsonObject actualJsonObject =
38 gson.fromJson(result.plan_result, JsonObject.class);
40 assertEquals(expectedJsonObject, actualJsonObject);
45 final JsonObject expectedJsonObject =
49 final JsonObject actualJsonObject =
50 gson.fromJson(result.plan_result, JsonObject.class);
52 assertEquals(expectedJsonObject, actualJsonObject);
57 final JsonObject expectedJsonObject =
61 final JsonObject actualJsonObject =
62 gson.fromJson(result.plan_result, JsonObject.class);
64 assertEquals(expectedJsonObject, actualJsonObject);
69 final JsonObject expectedJsonObject =
getJsonFromFile(
"create_foreign_server.json");
71 "CREATE SERVER test_server FOREIGN DATA WRAPPER test_data_wrapper "
72 +
"WITH (attribute_1 = 'value_1', attribute_2 = 2);");
73 final JsonObject actualJsonObject =
74 gson.fromJson(result.plan_result, JsonObject.class);
76 assertEquals(expectedJsonObject, actualJsonObject);
81 final JsonObject expectedJsonObject =
84 "CREATE SERVER IF NOT EXISTS test_server FOREIGN DATA WRAPPER test_data_wrapper "
85 +
"WITH (attribute_1 = 'value_1', attribute_2 = 2);");
86 final JsonObject actualJsonObject =
87 gson.fromJson(result.plan_result, JsonObject.class);
89 assertEquals(expectedJsonObject, actualJsonObject);
94 final JsonObject expectedJsonObject =
getJsonFromFile(
"drop_foreign_server.json");
96 final JsonObject actualJsonObject =
97 gson.fromJson(result.plan_result, JsonObject.class);
99 assertEquals(expectedJsonObject, actualJsonObject);
104 final JsonObject expectedJsonObject =
107 final JsonObject actualJsonObject =
108 gson.fromJson(result.plan_result, JsonObject.class);
110 assertEquals(expectedJsonObject, actualJsonObject);
115 final JsonObject expectedJsonObject =
getJsonFromFile(
"show_foreign_server.json");
117 final JsonObject actualJsonObject =
118 gson.fromJson(result.plan_result, JsonObject.class);
119 assertEquals(expectedJsonObject, actualJsonObject);
124 final JsonObject expectedJsonObject =
126 final TPlanResult
result =
128 final JsonObject actualJsonObject =
129 gson.fromJson(result.plan_result, JsonObject.class);
130 assertEquals(expectedJsonObject, actualJsonObject);
135 final JsonObject expectedJsonObject =
137 final TPlanResult
result =
139 final JsonObject actualJsonObject =
140 gson.fromJson(result.plan_result, JsonObject.class);
141 assertEquals(expectedJsonObject, actualJsonObject);
146 final JsonObject expectedJsonObject =
149 "SHOW SERVERS WHERE data_wrapper LIKE 'omnisci_%' AND data_wrapper LIKE '%_csv';");
150 final JsonObject actualJsonObject =
151 gson.fromJson(result.plan_result, JsonObject.class);
152 assertEquals(expectedJsonObject, actualJsonObject);
157 final JsonObject expectedJsonObject =
160 "SHOW SERVERS WHERE data_wrapper LIKE 'omnisci_%' OR data_wrapper = 'test';");
161 final JsonObject actualJsonObject =
162 gson.fromJson(result.plan_result, JsonObject.class);
163 assertEquals(expectedJsonObject, actualJsonObject);
168 final JsonObject expectedJsonObject =
171 "SHOW SERVERS WHERE data_wrapper LIKE 'omnisci_%' AND created_at LIKE '2020%' OR data_wrapper = 'test';");
172 final JsonObject actualJsonObject =
173 gson.fromJson(result.plan_result, JsonObject.class);
174 assertEquals(expectedJsonObject, actualJsonObject);
JsonObject getJsonFromFile(final String fileName)
void AlterServerSetDataWrapper()
void AlterServerRenameServer()
void DropServerDdlCommand()
void AlterServerChangeOwner()
TPlanResult processDdlCommand(final String ddlCommand)
void ShowForeignServersWhere()
void CreateServerDdlCommandWithIfNotExists()
void ShowForeignServersLikeAnd()
void ShowForeignServersLikeAndLikeOrEq()
void DropServerDdlCommandWithIfExists()
void CreateServerDdlCommand()
void ShowForeignServersLike()
void ShowForeignServersEqOr()
void AlterServerSetOptions()
void ShowForeignServers()