OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Calcite.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * File: Calcite.cpp
19  * Author: michael
20  *
21  * Created on November 23, 2015, 9:33 AM
22  */
23 
24 #include "Calcite.h"
25 #include "Catalog/Catalog.h"
26 #include "Shared/ConfigResolve.h"
27 #include "Shared/Logger.h"
28 #include "Shared/MapDParameters.h"
29 #include "Shared/ThriftClient.h"
30 #include "Shared/fixautotools.h"
31 #include "Shared/mapd_shared_ptr.h"
32 #include "Shared/mapdpath.h"
33 #include "Shared/measure.h"
35 
36 #include <thrift/protocol/TBinaryProtocol.h>
37 #include <thrift/transport/TSocket.h>
38 #include <thrift/transport/TTransportUtils.h>
39 #include <type_traits>
40 
41 #include "gen-cpp/CalciteServer.h"
42 
43 #include "rapidjson/document.h"
44 
45 #include <utility>
46 
47 using namespace rapidjson;
48 using namespace apache::thrift;
49 using namespace apache::thrift::protocol;
50 using namespace apache::thrift::transport;
51 
52 namespace {
53 template <typename XDEBUG_OPTION,
54  typename REMOTE_DEBUG_OPTION,
55  typename... REMAINING_ARGS>
56 int wrapped_execlp(char const* path,
57  XDEBUG_OPTION&& x_debug,
58  REMOTE_DEBUG_OPTION&& remote_debug,
59  REMAINING_ARGS&&... standard_args) {
60  if (std::is_same<JVMRemoteDebugSelector, PreprocessorTrue>::value) {
61  return execlp(
62  path, x_debug, remote_debug, std::forward<REMAINING_ARGS>(standard_args)...);
63  }
64  return execlp(path, std::forward<REMAINING_ARGS>(standard_args)...);
65 }
66 } // namespace
67 
68 static void start_calcite_server_as_daemon(const int mapd_port,
69  const int port,
70  const std::string& data_dir,
71  const size_t calcite_max_mem,
72  const std::string& ssl_trust_store,
73  const std::string& ssl_trust_password,
74  const std::string& ssl_keystore,
75  const std::string& ssl_keystore_password,
76  const std::string& ssl_key_file,
77  const std::string& ssl_cert_file,
78  const std::string& udf_filename) {
79  std::string const xDebug = "-Xdebug";
80  std::string const remoteDebug =
81  "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005";
82  std::string xmxP = "-Xmx" + std::to_string(calcite_max_mem) + "m";
83  std::string jarP = "-jar";
84  std::string jarD =
85  mapd_root_abs_path() + "/bin/calcite-1.0-SNAPSHOT-jar-with-dependencies.jar";
86  std::string extensionsP = "-e";
87  std::string extensionsD = mapd_root_abs_path() + "/QueryEngine/";
88  std::string dataP = "-d";
89  std::string dataD = data_dir;
90  std::string localPortP = "-p";
91  std::string localPortD = std::to_string(port);
92  std::string mapdPortP = "-m";
93  std::string mapdPortD = std::to_string(mapd_port);
94  std::string mapdTrustStoreP = "-T";
95  std::string mapdTrustPasswdP = "-P";
96  std::string mapdKeyStoreP = "-Y";
97  std::string mapdKeyStorePasswdP = "-Z";
98  std::string mapdLogDirectory = "-DMAPD_LOG_DIR=" + data_dir;
99  std::string userDefinedFunctionsP = "";
100  std::string userDefinedFunctionsD = "";
101 
102  if (!udf_filename.empty()) {
103  userDefinedFunctionsP += "-u";
104  userDefinedFunctionsD += udf_filename;
105  }
106 
107  int pid = fork();
108  if (pid == 0) {
109  int i;
110 
111  if (udf_filename.empty()) {
112  i = wrapped_execlp("java",
113  xDebug.c_str(),
114  remoteDebug.c_str(),
115  xmxP.c_str(),
116  mapdLogDirectory.c_str(),
117  jarP.c_str(),
118  jarD.c_str(),
119  extensionsP.c_str(),
120  extensionsD.c_str(),
121  dataP.c_str(),
122  dataD.c_str(),
123  localPortP.c_str(),
124  localPortD.c_str(),
125  mapdPortP.c_str(),
126  mapdPortD.c_str(),
127  mapdTrustStoreP.c_str(),
128  ssl_trust_store.c_str(),
129  mapdTrustPasswdP.c_str(),
130  ssl_trust_password.c_str(),
131  mapdKeyStoreP.c_str(),
132  ssl_keystore.c_str(),
133  mapdKeyStorePasswdP.c_str(),
134  ssl_keystore_password.c_str(),
135  (char*)0);
136  } else {
137  i = wrapped_execlp("java",
138  xDebug.c_str(),
139  remoteDebug.c_str(),
140  xmxP.c_str(),
141  mapdLogDirectory.c_str(),
142  jarP.c_str(),
143  jarD.c_str(),
144  extensionsP.c_str(),
145  extensionsD.c_str(),
146  dataP.c_str(),
147  dataD.c_str(),
148  localPortP.c_str(),
149  localPortD.c_str(),
150  mapdPortP.c_str(),
151  mapdPortD.c_str(),
152  mapdTrustStoreP.c_str(),
153  ssl_trust_store.c_str(),
154  mapdTrustPasswdP.c_str(),
155  ssl_trust_password.c_str(),
156  mapdKeyStoreP.c_str(),
157  ssl_keystore.c_str(),
158  mapdKeyStorePasswdP.c_str(),
159  ssl_keystore_password.c_str(),
160  userDefinedFunctionsP.c_str(),
161  userDefinedFunctionsD.c_str(),
162  (char*)0);
163  }
164 
165  if (i) {
166  int errsv = errno;
167  LOG(FATAL) << "Failed to start Calcite server [errno=" << errsv
168  << "]: " << strerror(errsv);
169  } else {
170  LOG(INFO) << "Successfully started Calcite server";
171  }
172  }
173 }
174 
175 std::pair<mapd::shared_ptr<CalciteServerClient>, mapd::shared_ptr<TTransport>>
177  const auto transport = connMgr_->open_buffered_client_transport(
178  "localhost", port, ssl_cert_file_, true, 2000, 5000, 5000);
179 
180  try {
181  transport->open();
182 
183  } catch (TException& tx) {
184  throw tx;
185  } catch (std::exception& ex) {
186  throw ex;
187  }
188  mapd::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
189  mapd::shared_ptr<CalciteServerClient> client;
190  client.reset(new CalciteServerClient(protocol));
191  std::pair<mapd::shared_ptr<CalciteServerClient>, mapd::shared_ptr<TTransport>> ret;
192  return std::make_pair(client, transport);
193 }
194 
195 void Calcite::runServer(const int mapd_port,
196  const int port,
197  const std::string& data_dir,
198  const size_t calcite_max_mem,
199  const std::string& udf_filename) {
200  LOG(INFO) << "Running calcite server as a daemon";
201 
202  // ping server to see if for any reason there is an orphaned one
203  int ping_time = ping();
204  if (ping_time > -1) {
205  // we have an orphaned server shut it down
206  LOG(ERROR)
207  << "Appears to be orphaned Calcite server already running, shutting it down";
208  LOG(ERROR) << "Please check that you are not trying to run two servers on same port";
209  LOG(ERROR) << "Attempting to shutdown orphaned Calcite server";
210  try {
211  auto clientP = getClient(remote_calcite_port_);
212  clientP.first->shutdown();
213  clientP.second->close();
214  LOG(ERROR) << "orphaned Calcite server shutdown";
215 
216  } catch (TException& tx) {
217  LOG(ERROR) << "Failed to shutdown orphaned Calcite server, reason: " << tx.what();
218  }
219  }
220 
221  // start the calcite server as a seperate process
223  port,
224  data_dir,
225  calcite_max_mem,
226  ssl_trust_store_,
227  ssl_trust_password_,
228  ssl_keystore_,
229  ssl_keystore_password_,
230  ssl_key_file_,
231  ssl_cert_file_,
232  udf_filename);
233 
234  // check for new server for 5 seconds max
235  std::this_thread::sleep_for(std::chrono::milliseconds(200));
236  for (int i = 2; i < 50; i++) {
237  int ping_time = ping();
238  if (ping_time > -1) {
239  LOG(INFO) << "Calcite server start took " << i * 100 << " ms ";
240  LOG(INFO) << "ping took " << ping_time << " ms ";
241  server_available_ = true;
242  return;
243  } else {
244  // wait 100 ms
245  std::this_thread::sleep_for(std::chrono::milliseconds(100));
246  }
247  }
248  server_available_ = false;
249  LOG(FATAL) << "Could not connect to calcite remote server running on port " << port;
250 }
251 
252 // ping existing server
253 // return -1 if no ping response
255  try {
256  auto ms = measure<>::execution([&]() {
257  auto clientP = getClient(remote_calcite_port_);
258  clientP.first->ping();
259  clientP.second->close();
260  });
261  return ms;
262 
263  } catch (TException& tx) {
264  return -1;
265  }
266 }
267 
268 Calcite::Calcite(const int mapd_port,
269  const int calcite_port,
270  const std::string& data_dir,
271  const size_t calcite_max_mem,
272  const std::string& udf_filename)
273  : server_available_(false) {
274  init(mapd_port, calcite_port, data_dir, calcite_max_mem, udf_filename);
275 }
276 
277 void Calcite::init(const int mapd_port,
278  const int calcite_port,
279  const std::string& data_dir,
280  const size_t calcite_max_mem,
281  const std::string& udf_filename) {
282  LOG(INFO) << "Creating Calcite Handler, Calcite Port is " << calcite_port
283  << " base data dir is " << data_dir;
284  connMgr_ = std::make_shared<ThriftClientConnection>();
285  if (calcite_port < 0) {
286  CHECK(false) << "JNI mode no longer supported.";
287  }
288  if (calcite_port == 0) {
289  // dummy process for initdb
290  remote_calcite_port_ = calcite_port;
291  server_available_ = false;
292  } else {
293  remote_calcite_port_ = calcite_port;
294  runServer(mapd_port, calcite_port, data_dir, calcite_max_mem, udf_filename);
295  server_available_ = true;
296  }
297 }
298 
299 Calcite::Calcite(const MapDParameters& mapd_parameter,
300  const std::string& data_dir,
301  const std::string& udf_filename)
302  : ssl_trust_store_(mapd_parameter.ssl_trust_store)
303  , ssl_trust_password_(mapd_parameter.ssl_trust_password)
304  , ssl_key_file_(mapd_parameter.ssl_key_file)
305  , ssl_keystore_(mapd_parameter.ssl_keystore)
306  , ssl_keystore_password_(mapd_parameter.ssl_keystore_password)
307  , ssl_cert_file_(mapd_parameter.ssl_cert_file) {
308  init(mapd_parameter.omnisci_server_port,
309  mapd_parameter.calcite_port,
310  data_dir,
311  mapd_parameter.calcite_max_mem,
312  udf_filename);
313 }
314 
315 void Calcite::updateMetadata(std::string catalog, std::string table) {
316  if (server_available_) {
317  auto ms = measure<>::execution([&]() {
318  auto clientP = getClient(remote_calcite_port_);
319  clientP.first->updateMetadata(catalog, table);
320  clientP.second->close();
321  });
322  LOG(INFO) << "Time to updateMetadata " << ms << " (ms)";
323  } else {
324  LOG(INFO) << "Not routing to Calcite, server is not up";
325  }
326 }
327 
329  std::vector<std::string> tableOrViewNames,
330  AccessPrivileges tablePrivs,
331  AccessPrivileges viewPrivs) {
332  Catalog_Namespace::Catalog& catalog = session_info.getCatalog();
333 
334  for (auto tableOrViewName : tableOrViewNames) {
335  const TableDescriptor* tableMeta =
336  catalog.getMetadataForTable(tableOrViewName, false);
337 
338  if (!tableMeta) {
339  throw std::runtime_error("unknown table of view: " + tableOrViewName);
340  }
341 
342  DBObjectKey key;
343  key.dbId = catalog.getCurrentDB().dbId;
346  key.objectId = tableMeta->tableId;
347  AccessPrivileges privs = tableMeta->isView ? viewPrivs : tablePrivs;
348  DBObject dbobject(key, privs, tableMeta->userId);
349  std::vector<DBObject> privObjects{dbobject};
350 
351  if (!privs.hasAny()) {
352  throw std::runtime_error("Operation not supported for object " + tableOrViewName);
353  }
354 
355  if (!Catalog_Namespace::SysCatalog::instance().checkPrivileges(
356  session_info.get_currentUser(), privObjects)) {
357  throw std::runtime_error("Violation of access privileges: user " +
358  session_info.get_currentUser().userName +
359  " has no proper privileges for object " + tableOrViewName);
360  }
361  }
362 }
363 
364 TPlanResult Calcite::process(
365  query_state::QueryStateProxy query_state_proxy,
366  std::string sql_string,
367  const std::vector<TFilterPushDownInfo>& filter_push_down_info,
368  const bool legacy_syntax,
369  const bool is_explain,
370  const bool is_view_optimize,
371  const std::string& calcite_session_id) {
372  TPlanResult result = processImpl(query_state_proxy,
373  std::move(sql_string),
374  filter_push_down_info,
375  legacy_syntax,
376  is_explain,
377  is_view_optimize,
378  calcite_session_id);
379 
380  AccessPrivileges NOOP;
381 
382  if (!is_explain) {
383  // check the individual tables
384  auto const session_ptr = query_state_proxy.getQueryState().getConstSessionInfo();
385  checkPermissionForTables(*session_ptr,
386  result.primary_accessed_objects.tables_selected_from,
389  checkPermissionForTables(*session_ptr,
390  result.primary_accessed_objects.tables_inserted_into,
392  NOOP);
393  checkPermissionForTables(*session_ptr,
394  result.primary_accessed_objects.tables_updated_in,
396  NOOP);
397  checkPermissionForTables(*session_ptr,
398  result.primary_accessed_objects.tables_deleted_from,
400  NOOP);
401  }
402 
403  return result;
404 }
405 
406 std::vector<TCompletionHint> Calcite::getCompletionHints(
407  const Catalog_Namespace::SessionInfo& session_info,
408  const std::vector<std::string>& visible_tables,
409  const std::string sql_string,
410  const int cursor) {
411  std::vector<TCompletionHint> hints;
412  auto& cat = session_info.getCatalog();
413  const auto user = session_info.get_currentUser().userName;
414  const auto session = session_info.get_session_id();
415  const auto catalog = cat.getCurrentDB().dbName;
416  auto client = getClient(remote_calcite_port_);
417  client.first->getCompletionHints(
418  hints, user, session, catalog, visible_tables, sql_string, cursor);
419  return hints;
420 }
421 
422 std::vector<std::string> Calcite::get_db_objects(const std::string ra) {
423  std::vector<std::string> v_db_obj;
424  Document document;
425  document.Parse(ra.c_str());
426  const Value& rels = document["rels"];
427  CHECK(rels.IsArray());
428  for (auto& v : rels.GetArray()) {
429  std::string relOp(v["relOp"].GetString());
430  if (!relOp.compare("EnumerableTableScan")) {
431  std::string x;
432  auto t = v["table"].GetArray();
433  x = t[1].GetString();
434  v_db_obj.push_back(x);
435  }
436  }
437 
438  return v_db_obj;
439 }
440 
442  query_state::QueryStateProxy query_state_proxy,
443  const std::string sql_string,
444  const std::vector<TFilterPushDownInfo>& filter_push_down_info,
445  const bool legacy_syntax,
446  const bool is_explain,
447  const bool is_view_optimize,
448  const std::string& calcite_session_id) {
449  query_state::Timer timer = query_state_proxy.createTimer(__func__);
450  const auto& user_session_info = query_state_proxy.getQueryState().getConstSessionInfo();
451  const auto& cat = user_session_info->getCatalog();
452  const std::string user = getInternalSessionProxyUserName();
453  const std::string catalog = cat.getCurrentDB().dbName;
454  LOG(INFO) << "User " << user << " catalog " << catalog << " sql '" << sql_string << "'";
455  LOG(IR) << "SQL query\n" << sql_string << "\nEnd of SQL query";
456  LOG(PTX) << "SQL query\n" << sql_string << "\nEnd of SQL query";
457 
458  TPlanResult ret;
459  if (server_available_) {
460  try {
461  // calcite_session_id would be an empty string when accessed by internal resources
462  // that would not access `process` through handler instance, like for eg: Unit
463  // Tests. In these cases we would use the session_id from query state.
464  auto ms = measure<>::execution([&]() {
465  auto clientP = getClient(remote_calcite_port_);
466  clientP.first->process(ret,
467  user,
468  calcite_session_id.empty()
469  ? user_session_info->get_session_id()
470  : calcite_session_id,
471  catalog,
472  sql_string,
473  filter_push_down_info,
474  legacy_syntax,
475  is_explain,
476  is_view_optimize);
477  clientP.second->close();
478  });
479 
480  // LOG(INFO) << ret.plan_result;
481  LOG(INFO) << "Time in Thrift "
482  << (ms > ret.execution_time_ms ? ms - ret.execution_time_ms : 0)
483  << " (ms), Time in Java Calcite server " << ret.execution_time_ms
484  << " (ms)";
485  } catch (InvalidParseRequest& e) {
486  throw std::invalid_argument(e.whyUp);
487  } catch (const std::exception& ex) {
488  LOG(FATAL)
489  << "Error occurred trying to communicate with calcite server, the error was: '"
490  << ex.what() << "', omnisci_server restart will be required";
491  return ret; // satisfy return-type warning
492  }
493  } else {
494  LOG(INFO) << "Not routing to Calcite, server is not up";
495  ret.plan_result = "";
496  }
497  return ret;
498 }
499 
501  if (server_available_) {
502  TPlanResult ret;
503  std::string whitelist;
504 
505  auto clientP = getClient(remote_calcite_port_);
506  clientP.first->getExtensionFunctionWhitelist(whitelist);
507  clientP.second->close();
508  VLOG(1) << whitelist;
509  return whitelist;
510  } else {
511  LOG(FATAL) << "Not routing to Calcite, server is not up";
512  return "";
513  }
514  CHECK(false);
515  return "";
516 }
517 
519  if (server_available_) {
520  TPlanResult ret;
521  std::string whitelist;
522 
523  auto clientP = getClient(remote_calcite_port_);
524  clientP.first->getUserDefinedFunctionWhitelist(whitelist);
525  clientP.second->close();
526  VLOG(1) << "User defined functions whitelist loaded from Calcite: " << whitelist;
527  return whitelist;
528  } else {
529  LOG(FATAL) << "Not routing to Calcite, server is not up";
530  return "";
531  }
532  UNREACHABLE();
533  return "";
534 }
535 
537  std::call_once(shutdown_once_flag_,
538  [this, log]() { this->inner_close_calcite_server(log); });
539 }
540 
542  if (server_available_) {
543  LOG_IF(INFO, log) << "Shutting down Calcite server";
544  try {
545  auto clientP = getClient(remote_calcite_port_);
546  clientP.first->shutdown();
547  clientP.second->close();
548  } catch (const std::exception& e) {
549  if (std::string(e.what()) != "connect() failed: Connection refused" &&
550  std::string(e.what()) != "socket open() error: Connection refused" &&
551  std::string(e.what()) != "No more data to read.") {
552  std::cerr << "Error shutting down Calcite server: " << e.what() << std::endl;
553  } // else Calcite already shut down
554  }
555  LOG_IF(INFO, log) << "shut down Calcite";
556  server_available_ = false;
557  }
558 }
559 
561  close_calcite_server(false);
562 }
563 
565  if (server_available_) {
566  TPlanResult ret;
567  std::string whitelist;
568  auto clientP = getClient(remote_calcite_port_);
569  clientP.first->getRuntimeExtensionFunctionWhitelist(whitelist);
570  clientP.second->close();
571  VLOG(1) << "Runtime extension functions whitelist loaded from Calcite: " << whitelist;
572  return whitelist;
573  } else {
574  LOG(FATAL) << "Not routing to Calcite, server is not up";
575  return "";
576  }
577  UNREACHABLE();
578  return "";
579 }
580 
582  const std::vector<TUserDefinedFunction>& udfs,
583  const std::vector<TUserDefinedTableFunction>& udtfs) {
584  if (server_available_) {
585  auto clientP = getClient(remote_calcite_port_);
586  clientP.first->setRuntimeExtensionFunctions(udfs, udtfs);
587  clientP.second->close();
588  } else {
589  LOG(FATAL) << "Not routing to Calcite, server is not up";
590  }
591 }
std::vector< std::string > get_db_objects(const std::string ra)
Definition: Calcite.cpp:422
int wrapped_execlp(char const *path, XDEBUG_OPTION &&x_debug, REMOTE_DEBUG_OPTION &&remote_debug, REMAINING_ARGS &&...standard_args)
Definition: Calcite.cpp:56
std::once_flag shutdown_once_flag_
Definition: Calcite.h:130
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:81
static TimeT::rep execution(F func, Args &&...args)
Definition: sample.cpp:29
#define LOG(tag)
Definition: Logger.h:185
mapd::shared_ptr< ThriftClientConnection > connMgr_
Definition: Calcite.h:121
std::string mapd_root_abs_path()
Definition: mapdpath.h:30
static const AccessPrivileges INSERT_INTO_TABLE
Definition: DBObject.h:154
TPlanResult processImpl(query_state::QueryStateProxy, std::string sql_string, const std::vector< TFilterPushDownInfo > &filter_push_down_info, const bool legacy_syntax, const bool is_explain, const bool is_view_optimize, const std::string &calcite_session_id)
Definition: Calcite.cpp:441
#define UNREACHABLE()
Definition: Logger.h:234
bool hasAny() const
Definition: DBObject.h:133
TPlanResult process(query_state::QueryStateProxy, std::string sql_string, const std::vector< TFilterPushDownInfo > &filter_push_down_info, const bool legacy_syntax, const bool is_explain, const bool is_view_optimize, const std::string &calcite_session_id="")
Definition: Calcite.cpp:364
int32_t objectId
Definition: DBObject.h:56
Timer createTimer(char const *event_name)
Definition: QueryState.cpp:111
static const AccessPrivileges SELECT_FROM_TABLE
Definition: DBObject.h:153
std::string to_string(char const *&&v)
#define LOG_IF(severity, condition)
Definition: Logger.h:276
void updateMetadata(std::string catalog, std::string table)
Definition: Calcite.cpp:315
static void start_calcite_server_as_daemon(const int mapd_port, const int port, const std::string &data_dir, const size_t calcite_max_mem, const std::string &ssl_trust_store, const std::string &ssl_trust_password, const std::string &ssl_keystore, const std::string &ssl_keystore_password, const std::string &ssl_key_file, const std::string &ssl_cert_file, const std::string &udf_filename)
Definition: Calcite.cpp:68
int ping()
Definition: Calcite.cpp:254
This file contains the class specification and related data structures for Catalog.
static SysCatalog & instance()
Definition: SysCatalog.h:242
CHECK(cgen_state)
void setRuntimeExtensionFunctions(const std::vector< TUserDefinedFunction > &udfs, const std::vector< TUserDefinedTableFunction > &udtfs)
Definition: Calcite.cpp:581
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:176
std::vector< TCompletionHint > getCompletionHints(const Catalog_Namespace::SessionInfo &session_info, const std::vector< std::string > &visible_tables, const std::string sql_string, const int cursor)
Definition: Calcite.cpp:406
QueryState & getQueryState()
Definition: QueryState.h:172
static const AccessPrivileges DELETE_FROM_TABLE
Definition: DBObject.h:156
std::string getUserDefinedFunctionWhitelist()
Definition: Calcite.cpp:518
size_t calcite_max_mem
std::string get_session_id() const
Definition: SessionInfo.h:98
Calcite(const int mapd_port, const int port, const std::string &data_dir, const size_t calcite_max_mem, const std::string &udf_filename="")
Definition: Calcite.cpp:268
static const AccessPrivileges SELECT_FROM_VIEW
Definition: DBObject.h:173
Catalog & getCatalog() const
Definition: SessionInfo.h:90
int remote_calcite_port_
Definition: Calcite.h:123
int32_t dbId
Definition: DBObject.h:55
std::string const getInternalSessionProxyUserName()
Definition: Calcite.h:93
void inner_close_calcite_server(bool log)
Definition: Calcite.cpp:541
bool server_available_
Definition: Calcite.h:122
bool g_enable_watchdog false
Definition: Execute.cpp:71
int32_t permissionType
Definition: DBObject.h:54
void runServer(const int mapd_port, const int port, const std::string &data_dir, const size_t calcite_max_mem, const std::string &udf_filename)
Definition: Calcite.cpp:195
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
specifies the content in-memory of a row in the table metadata table
void init(const int mapd_port, const int port, const std::string &data_dir, const size_t calcite_max_mem, const std::string &udf_filename)
Definition: Calcite.cpp:277
static const AccessPrivileges UPDATE_IN_TABLE
Definition: DBObject.h:155
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
Definition: QueryState.cpp:75
~Calcite()
Definition: Calcite.cpp:560
std::string getExtensionFunctionWhitelist()
Definition: Calcite.cpp:500
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
std::pair< mapd::shared_ptr< CalciteServerClient >, mapd::shared_ptr< TTransport > > getClient(int port)
Definition: Calcite.cpp:176
void checkPermissionForTables(const Catalog_Namespace::SessionInfo &session_info, std::vector< std::string > tableOrViewNames, AccessPrivileges tablePrivs, AccessPrivileges viewPrivs)
Definition: Calcite.cpp:328
std::string getRuntimeExtensionFunctionWhitelist()
Definition: Calcite.cpp:564
#define VLOG(n)
Definition: Logger.h:280
void close_calcite_server(bool log=true)
Definition: Calcite.cpp:536