17 package com.mapd.parser.server.test;
19 import static org.junit.Assert.*;
24 import org.apache.thrift.TException;
25 import org.apache.thrift.protocol.TBinaryProtocol;
26 import org.apache.thrift.protocol.TProtocol;
27 import org.apache.thrift.transport.TSocket;
28 import org.apache.thrift.transport.TTransport;
29 import org.junit.AfterClass;
30 import org.junit.BeforeClass;
31 import org.junit.Ignore;
32 import org.junit.Test;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
36 import java.util.ArrayList;
37 import java.util.Random;
38 import java.util.concurrent.ExecutorService;
39 import java.util.concurrent.Executors;
41 import ai.heavy.thrift.calciteserver.CalciteServer;
42 import ai.heavy.thrift.calciteserver.TOptimizationOption;
43 import ai.heavy.thrift.calciteserver.TPlanResult;
44 import ai.heavy.thrift.calciteserver.TQueryParsingOption;
47 private final static Logger
HEAVYDBLOGGER = LoggerFactory.getLogger(TestServer.class);
51 private volatile AssertionError
ae;
59 new Thread(
csw).start();
71 Runnable r =
new Runnable() {
75 for (
int i = 1; i <= 5; i++) {
78 }
catch (AssertionError x) {
79 HEAVYDBLOGGER.error(
"error during Runnable");
93 while (!pool.isShutdown()) {
107 +
" \"id\": \"0\",\n"
108 +
" \"relOp\": \"LogicalTableScan\",\n"
109 +
" \"fieldNames\": [\n"
119 +
" \"SLACKARR1\",\n"
127 +
" \"inputs\": []\n"
130 +
" \"id\": \"1\",\n"
131 +
" \"relOp\": \"LogicalProject\",\n"
151 Random r =
new Random();
152 int aliasID = r.nextInt(100000) + 1000000;
155 "Select TABALIAS%d.ENAME AS COLALIAS%d from EMP TABALIAS%d LIMIT %d",
163 +
" \"id\": \"0\",\n"
164 +
" \"relOp\": \"LogicalTableScan\",\n"
165 +
" \"fieldNames\": [\n"
175 +
" \"SLACKARR1\",\n"
183 +
" \"inputs\": []\n"
186 +
" \"id\": \"1\",\n"
187 +
" \"relOp\": \"LogicalProject\",\n"
189 +
" \"COLALIAS%d\"\n"
198 +
" \"id\": \"2\",\n"
199 +
" \"relOp\": \"LogicalSort\",\n"
200 +
" \"collation\": [],\n"
202 +
" \"literal\": %d,\n"
203 +
" \"type\": \"DECIMAL\",\n"
205 +
" \"precision\": 7,\n"
206 +
" \"type_scale\": 0,\n"
207 +
" \"type_precision\": 10\n"
211 +
" \"id\": \"3\",\n"
212 +
" \"relOp\": \"LogicalProject\",\n"
214 +
" \"COLALIAS%d\"\n"
223 +
" \"id\": \"4\",\n"
224 +
" \"relOp\": \"LogicalSort\",\n"
225 +
" \"collation\": [],\n"
227 +
" \"literal\": %d,\n"
228 +
" \"type\": \"DECIMAL\",\n"
230 +
" \"precision\": 7,\n"
231 +
" \"type_scale\": 0,\n"
232 +
" \"type_precision\": 10\n"
245 TTransport transport;
246 transport =
new TSocket(
"localhost", 11000);
248 TProtocol protocol =
new TBinaryProtocol(transport);
249 CalciteServer.Client client =
new CalciteServer.Client(protocol);
251 TQueryParsingOption queryParsingOption =
new TQueryParsingOption();
252 queryParsingOption.legacy_syntax =
false;
253 queryParsingOption.is_explain =
false;
254 queryParsingOption.check_privileges =
false;
255 queryParsingOption.is_explain_detail =
false;
257 TOptimizationOption optimizationOption =
new TOptimizationOption();
258 optimizationOption.is_view_optimize =
false;
259 optimizationOption.enable_watchdog =
false;
260 optimizationOption.filter_push_down_info =
new ArrayList<>();
262 TPlanResult algebra = client.process(
"user",
271 assertEquals(algebra.plan_result, result);
272 }
catch (AssertionError s) {
273 HEAVYDBLOGGER.error(
"error during callCalciteCheck");
276 }
catch (TException x) {
static final Logger HEAVYDBLOGGER
static final int TEST_THREAD_COUNT
volatile boolean threadHadFailure
static CalciteServerWrapper csw
volatile AssertionError ae
static void startServer()
void callCalciteCheck(String query, String result)
static SockTransportProperties client_skT
static SockTransportProperties server_skT