36 #ifdef HAVE_RUNTIME_LIBS
44 #include "gen-cpp/CalciteServer.h"
45 #include "include/bcrypt.h"
47 #include <boost/filesystem/operations.hpp>
51 #define CALCITEPORT 3279
62 using namespace Catalog_Namespace;
69 g_calcite->close_calcite_server();
83 std::unique_ptr<QueryRunner> QueryRunner::qr_instance_ =
nullptr;
88 const std::string& udf_filename,
89 const size_t max_gpu_mem,
90 const int reserved_gpu_mem) {
105 const std::vector<LeafHostInfo>& string_servers,
106 const std::vector<LeafHostInfo>& leaf_servers) {
123 const std::string& user,
124 const std::string& pass,
125 const std::string& db_name,
126 const std::vector<LeafHostInfo>& string_servers,
127 const std::vector<LeafHostInfo>& leaf_servers,
128 const std::string& udf_filename,
130 const size_t max_gpu_mem,
131 const int reserved_gpu_mem,
133 const bool create_db,
138 LOG_IF(
FATAL, !leaf_servers.empty()) <<
"Distributed test runner not supported.";
139 CHECK(leaf_servers.empty());
153 return qr_instance_.get();
157 const std::string& user_name,
158 const std::string& passwd,
159 const std::string& db_name,
160 const std::vector<LeafHostInfo>& string_servers,
161 const std::vector<LeafHostInfo>& leaf_servers,
162 const std::string& udf_filename,
164 const size_t max_gpu_mem,
165 const int reserved_gpu_mem,
167 const bool create_db,
171 boost::filesystem::path base_path{db_path};
172 CHECK(boost::filesystem::exists(base_path));
173 auto system_db_file =
175 CHECK(boost::filesystem::exists(system_db_file));
181 disk_cache_config = *cache_config;
188 std::make_shared<Calcite>(-1,
CALCITEPORT, db_path, 1024, 5000,
true, udf_filename);
190 if (!udf_filename.empty()) {
195 #ifdef HAVE_RUNTIME_LIBS
201 std::vector<TUserDefinedFunction> udfs = {};
202 g_calcite->setRuntimeExtensionFunctions(udfs, udtfs,
false);
204 std::unique_ptr<CudaMgr_Namespace::CudaMgr> cuda_mgr;
207 cuda_mgr = std::make_unique<CudaMgr_Namespace::CudaMgr>(-1, 0);
212 const size_t num_gpus =
static_cast<size_t>(cuda_mgr ? cuda_mgr->getDeviceCount() : 0);
215 mapd_params.
aggregator = !leaf_servers.empty();
221 if (!sys_cat.isInitialized()) {
222 auto data_mgr = std::make_shared<Data_Namespace::DataMgr>(data_dir.string(),
239 static_cast<size_t>(1UL << 32) ,
240 data_mgr->getCpuBufferPoolSize() ,
241 data_mgr->getGpuBufferPoolSize() ,
264 if (!sys_cat.getMetadataForUser(user_name, user)) {
268 passwd,
false,
"",
true},
272 CHECK(sys_cat.getMetadataForUser(user_name, user));
277 sys_cat.createDatabase(db_name, user.
userId);
284 session_info_ = std::make_unique<Catalog_Namespace::SessionInfo>(
288 void QueryRunner::resizeDispatchQueue(
const size_t num_executors) {
293 : session_info_(std::move(session))
296 std::shared_ptr<Catalog_Namespace::Catalog> QueryRunner::getCatalog()
const {
301 std::shared_ptr<Calcite> QueryRunner::getCalcite()
const {
306 bool QueryRunner::gpusPresent()
const {
308 return session_info_->getCatalog().getDataMgr().gpusPresent();
311 void QueryRunner::clearGpuMemory()
const {
316 void QueryRunner::clearCpuMemory()
const {
321 std::vector<MemoryInfo> QueryRunner::getMemoryInfo(
324 return session_info_->getCatalog().getDataMgr().getMemoryInfo(memory_level);
329 const bool current_db_only)
const {
332 const std::vector<MemoryInfo> memory_infos =
333 session_info_->getCatalog().getDataMgr().getMemoryInfo(memory_level);
335 CHECK_EQ(memory_infos.size(),
static_cast<size_t>(1));
337 std::set<std::vector<int32_t>> chunk_keys;
338 std::set<std::vector<int32_t>> table_keys;
339 std::set<std::vector<int32_t>> column_keys;
340 std::set<std::vector<int32_t>> fragment_keys;
341 size_t total_num_buffers{
343 size_t total_num_bytes{0};
344 for (
auto& pool_memory_info : memory_infos) {
345 const std::vector<MemoryData>& memory_data = pool_memory_info.nodeMemoryData;
346 for (
auto& memory_datum : memory_data) {
348 const auto& chunk_key = memory_datum.chunk_key;
350 chunk_key.size() < 4) {
353 if (current_db_only) {
358 total_num_bytes += (memory_datum.numPages * pool_memory_info.pageSize);
359 table_keys.insert({chunk_key[0], chunk_key[1]});
360 column_keys.insert({chunk_key[0], chunk_key[1], chunk_key[2]});
361 fragment_keys.insert({chunk_key[0], chunk_key[1], chunk_key[3]});
362 chunk_keys.insert(chunk_key);
365 return {total_num_buffers,
369 fragment_keys.size(),
380 auto calcite_mgr =
cat.getCalciteMgr();
381 const auto calciteQueryParsingOption =
382 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
383 const auto calciteOptimizationOption =
385 const auto query_ra = calcite_mgr
386 ->process(query_state->createQueryStateProxy(),
388 calciteQueryParsingOption,
389 calciteOptimizationOption)
391 auto ra_executor =
RelAlgExecutor(executor.get(), query_ra, query_state);
397 std::shared_ptr<const RelAlgNode> QueryRunner::getRootNodeFromParsedQuery(
398 const std::string& query_str) {
405 auto calcite_mgr =
cat.getCalciteMgr();
406 const auto calciteQueryParsingOption =
407 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
408 const auto calciteOptimizationOption =
410 const auto query_ra = calcite_mgr
411 ->process(query_state->createQueryStateProxy(),
413 calciteQueryParsingOption,
414 calciteOptimizationOption)
416 auto ra_executor =
RelAlgExecutor(executor.get(), query_ra, query_state);
421 std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint>>>
422 QueryRunner::getParsedQueryHints(
const std::string& query_str) {
428 auto calcite_mgr =
cat.getCalciteMgr();
429 const auto calciteQueryParsingOption =
430 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
431 const auto calciteOptimizationOption =
433 const auto query_ra = calcite_mgr
434 ->process(query_state->createQueryStateProxy(),
436 calciteQueryParsingOption,
437 calciteOptimizationOption)
439 auto ra_executor =
RelAlgExecutor(executor.get(), query_ra, query_state);
443 std::optional<RegisteredQueryHint> QueryRunner::getParsedGlobalQueryHints(
444 const std::string& query_str) {
450 auto calcite_mgr =
cat.getCalciteMgr();
451 const auto calciteQueryParsingOption =
452 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
453 const auto calciteOptimizationOption =
455 const auto query_ra = calcite_mgr
456 ->process(query_state->createQueryStateProxy(),
458 calciteQueryParsingOption,
459 calciteOptimizationOption)
461 auto ra_executor =
RelAlgExecutor(executor.get(), query_ra, query_state);
471 auto calcite_mgr =
cat.getCalciteMgr();
472 const auto calciteQueryParsingOption =
473 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
474 const auto calciteOptimizationOption =
476 const auto query_ra = calcite_mgr
477 ->process(query_state->createQueryStateProxy(),
479 calciteQueryParsingOption,
480 calciteOptimizationOption)
482 auto ra_executor =
RelAlgExecutor(executor.get(), query_ra, query_state);
488 void QueryRunner::validateDDLStatement(
const std::string& stmt_str_in) {
491 std::string stmt_str = stmt_str_in;
493 boost::algorithm::trim_left_if(stmt_str, boost::algorithm::is_any_of(
"\n"));
495 boost::algorithm::trim_left(stmt_str);
498 auto stdlog =
STDLOG(query_state);
501 auto calcite_mgr =
cat.getCalciteMgr();
502 const auto calciteQueryParsingOption =
503 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
504 const auto calciteOptimizationOption =
506 calcite_mgr->process(query_state->createQueryStateProxy(),
508 calciteQueryParsingOption,
509 calciteOptimizationOption);
512 std::shared_ptr<RelAlgTranslator> QueryRunner::getRelAlgTranslator(
513 const std::string& query_str,
514 Executor* executor) {
519 auto calcite_mgr =
cat.getCalciteMgr();
520 const auto calciteQueryParsingOption =
521 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
522 const auto calciteOptimizationOption =
524 const auto query_ra = calcite_mgr
525 ->process(query_state->createQueryStateProxy(),
527 calciteQueryParsingOption,
528 calciteOptimizationOption)
531 auto root_node_shared_ptr = ra_executor.getRootRelAlgNodeShPtr();
532 return ra_executor.getRelAlgTranslator(root_node_shared_ptr.get());
536 const std::string& query_str) {
542 auto calcite_mgr =
cat.getCalciteMgr();
543 const auto calciteQueryParsingOption =
544 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
545 const auto calciteOptimizationOption =
547 const auto query_ra = calcite_mgr
548 ->process(query_state->createQueryStateProxy(),
550 calciteQueryParsingOption,
551 calciteOptimizationOption)
558 auto join_info = ra_executor.getJoinInfo(root_node_shared_ptr.get());
559 auto relAlgTranslator = ra_executor.getRelAlgTranslator(root_node_shared_ptr.get());
560 return {root_node_shared_ptr, join_info.first, join_info.second, relAlgTranslator};
563 std::unique_ptr<Parser::Stmt> QueryRunner::createStatement(
564 const std::string& stmt_str_in) {
568 std::string stmt_str = stmt_str_in;
570 boost::algorithm::trim_left_if(stmt_str, boost::algorithm::is_any_of(
"\n"));
572 boost::algorithm::trim_left(stmt_str);
577 auto stdlog =
STDLOG(query_state);
581 auto calcite_mgr =
cat.getCalciteMgr();
582 const auto calciteQueryParsingOption =
583 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
584 const auto calciteOptimizationOption =
586 const auto query_json = calcite_mgr
587 ->process(query_state->createQueryStateProxy(),
589 calciteQueryParsingOption,
590 calciteOptimizationOption)
600 void QueryRunner::runDDLStatement(
const std::string& stmt_str_in) {
604 std::string stmt_str = stmt_str_in;
606 boost::algorithm::trim_left_if(stmt_str, boost::algorithm::is_any_of(
"\n"));
608 boost::algorithm::trim_left(stmt_str);
613 auto stdlog =
STDLOG(query_state);
617 auto calcite_mgr =
cat.getCalciteMgr();
618 const auto calciteQueryParsingOption =
619 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
620 const auto calciteOptimizationOption =
622 const auto query_ra = calcite_mgr
623 ->process(query_state->createQueryStateProxy(),
625 calciteQueryParsingOption,
626 calciteOptimizationOption)
629 rapidjson::Document ddl_query;
630 ddl_query.Parse(query_ra);
631 CHECK(ddl_query.HasMember(
"payload"));
632 CHECK(ddl_query[
"payload"].IsObject());
643 std::shared_ptr<ResultSet> QueryRunner::runSQL(
const std::string& query_str,
654 const auto execution_result =
runSelectQuery(query_str, std::move(co), std::move(eo));
655 return execution_result->getRows();
658 std::shared_ptr<ResultSet> QueryRunner::runSQL(
const std::string& query_str,
660 const bool hoist_literals,
661 const bool allow_loop_joins) {
663 co.hoist_literals = hoist_literals;
689 std::shared_ptr<Executor> QueryRunner::getExecutor()
const {
693 auto stdlog =
STDLOG(query_state);
698 std::shared_ptr<ResultSet> QueryRunner::runSQLWithAllowingInterrupt(
699 const std::string& query_str,
700 const std::string& session_id,
702 const double running_query_check_freq,
703 const unsigned pending_query_check_freq) {
707 auto session_info = std::make_shared<Catalog_Namespace::SessionInfo>(
708 session_info_->get_catalog_ptr(), current_user, device_type, session_id);
710 auto stdlog =
STDLOG(query_state);
711 auto&
cat = query_state->getConstSessionInfo()->getCatalog();
712 std::string query_ra{
""};
714 std::shared_ptr<ExecutionResult>
result;
715 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
721 &running_query_check_freq,
722 &pending_query_check_freq,
742 running_query_check_freq,
743 pending_query_check_freq,
750 std::lock_guard<std::mutex> calcite_lock_guard(
calcite_lock);
751 auto calcite_mgr = cat.getCalciteMgr();
752 const auto calciteQueryParsingOption =
753 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
754 const auto calciteOptimizationOption =
755 calcite_mgr->getCalciteOptimizationOption(
757 query_ra = calcite_mgr
758 ->process(query_state->createQueryStateProxy(),
759 pg_shim(query_state->getQueryStr()),
760 calciteQueryParsingOption,
761 calciteOptimizationOption)
764 auto ra_executor =
RelAlgExecutor(executor.get(), query_ra, query_state);
765 result = std::make_shared<ExecutionResult>(
766 ra_executor.executeRelAlgQuery(co, eo,
false,
false,
nullptr));
769 executor->enrollQuerySession(session_id,
771 query_state->getQuerySubmittedTime(),
773 QuerySessionStatus::QueryStatus::PENDING_QUEUE);
776 auto result_future = query_launch_task->get_future();
779 return result->getRows();
782 std::vector<std::shared_ptr<ResultSet>> QueryRunner::runMultipleStatements(
783 const std::string& sql,
785 std::vector<std::shared_ptr<ResultSet>> results;
787 auto fields =
split(sql,
";");
788 for (
const auto&
field : fields) {
797 results.push_back(
nullptr);
800 results.push_back(
runSQL(text, dt,
true,
true));
811 std::unique_ptr<import_export::Loader> QueryRunner::getLoader(
814 return std::make_unique<import_export::Loader>(*
cat, td);
822 const bool hoist_literals,
823 const bool allow_loop_joins,
824 const bool just_explain,
826 const bool with_filter_push_down) {
839 auto calcite_mgr =
cat.getCalciteMgr();
840 const auto calciteQueryParsingOption =
841 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
842 auto calciteOptimizationOption =
844 const auto query_ra = calcite_mgr
845 ->process(query_state_proxy,
847 calciteQueryParsingOption,
848 calciteOptimizationOption)
851 auto result = std::make_shared<ExecutionResult>(
852 ra_executor.executeRelAlgQuery(co, eo,
false,
false,
nullptr));
853 const auto& filter_push_down_requests = result->getPushedDownFilterInfo();
854 if (!filter_push_down_requests.empty()) {
855 std::vector<TFilterPushDownInfo> filter_push_down_info;
856 for (
const auto& req : filter_push_down_requests) {
857 TFilterPushDownInfo filter_push_down_info_for_request;
858 filter_push_down_info_for_request.input_prev = req.input_prev;
859 filter_push_down_info_for_request.input_start = req.input_start;
860 filter_push_down_info_for_request.input_next = req.input_next;
861 filter_push_down_info.push_back(filter_push_down_info_for_request);
863 calciteOptimizationOption.filter_push_down_info = filter_push_down_info;
864 const auto new_query_ra = calcite_mgr
865 ->process(query_state_proxy,
867 calciteQueryParsingOption,
868 calciteOptimizationOption)
870 auto eo_modified = eo;
872 eo_modified.just_calcite_explain =
false;
873 auto new_ra_executor =
RelAlgExecutor(executor.get(), new_query_ra);
874 return std::make_shared<ExecutionResult>(
875 new_ra_executor.executeRelAlgQuery(co, eo_modified,
false,
false,
nullptr));
883 std::shared_ptr<ResultSet> QueryRunner::getCalcitePlan(
const std::string& query_str,
884 bool enable_watchdog,
885 bool is_explain_as_json_str,
886 bool is_explain_detailed)
const {
891 auto stdlog =
STDLOG(query_state);
893 std::shared_ptr<ResultSet>
result;
894 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
898 &is_explain_as_json_str,
899 &is_explain_detailed,
905 auto calcite_mgr = cat.getCalciteMgr();
908 const auto calciteQueryParsingOption = calcite_mgr->getCalciteQueryParsingOption(
909 true, !is_explain_as_json_str,
false, is_explain_detailed);
910 const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
912 const auto query_ra = calcite_mgr
913 ->process(query_state->createQueryStateProxy(),
915 calciteQueryParsingOption,
916 calciteOptimizationOption)
918 result = std::make_shared<ResultSet>(query_ra);
923 auto result_future = query_launch_task->get_future();
929 std::shared_ptr<ExecutionResult> QueryRunner::runSelectQuery(
const std::string& query_str,
935 auto stdlog =
STDLOG(query_state);
948 std::shared_ptr<ExecutionResult>
result;
949 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
964 co.explain_type = explain_type;
965 auto calcite_mgr = cat.getCalciteMgr();
966 const auto calciteQueryParsingOption =
967 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
968 const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
970 const auto query_ra = calcite_mgr
971 ->process(query_state->createQueryStateProxy(),
973 calciteQueryParsingOption,
974 calciteOptimizationOption)
977 result = std::make_shared<ExecutionResult>(
978 ra_executor.executeRelAlgQuery(co, eo,
false,
false,
nullptr));
982 auto result_future = query_launch_task->get_future();
988 std::shared_ptr<ExecutionResult> QueryRunner::runSelectQuery(
989 const std::string& query_str,
991 const bool hoist_literals,
992 const bool allow_loop_joins,
993 const bool just_explain) {
995 co.hoist_literals = hoist_literals;
1005 query_dag_info.root_node.get(), executor);
1006 return extracted_dag_info;
1009 std::unique_ptr<RelAlgDag> QueryRunner::getRelAlgDag(
const std::string& query_str) {
1013 auto stdlog =
STDLOG(query_state);
1016 std::unique_ptr<RelAlgDag> rel_alg_dag;
1017 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
1026 auto calcite_mgr = cat.getCalciteMgr();
1027 const auto calciteQueryParsingOption =
1028 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
1029 const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
1031 const auto query_ra = calcite_mgr
1032 ->process(query_state->createQueryStateProxy(),
1034 calciteQueryParsingOption,
1035 calciteOptimizationOption)
1042 auto result_future = query_launch_task->get_future();
1043 result_future.get();
1059 std::shared_ptr<HashTable>,
1060 std::optional<HashtableCacheMetaInfo>>
1061 QueryRunner::getCachedHashtableWithoutCacheKey(std::set<size_t>& visited,
1065 switch (hash_table_type) {
1083 CHECK(hash_table_cache);
1084 return hash_table_cache->getCachedHashtableWithoutCacheKey(
1085 visited, hash_table_type, device_identifier);
1088 std::shared_ptr<CacheItemMetric> QueryRunner::getCacheItemMetric(
1093 switch (hash_table_type) {
1111 CHECK(hash_table_cache);
1112 return hash_table_cache->getCachedItemMetric(
1113 hash_table_type, device_identifier, cache_key);
1118 bool with_bbox_intersect_tuning_param)
const {
1119 auto get_num_cached_auto_tuner_param = [&item_status]() {
1120 auto auto_tuner_cache =
1122 CHECK(auto_tuner_cache);
1123 switch (item_status) {
1125 return auto_tuner_cache->getCurrentNumCachedItems(
1130 return auto_tuner_cache->getCurrentNumCleanCachedItems(
1135 return auto_tuner_cache->getCurrentNumDirtyCachedItems(
1141 return static_cast<size_t>(0);
1146 auto get_num_cached_hashtable =
1149 &with_bbox_intersect_tuning_param,
1151 switch (item_status) {
1153 if (with_bbox_intersect_tuning_param) {
1157 return hash_table_cache->getCurrentNumCachedItems(
1159 get_num_cached_auto_tuner_param();
1161 return hash_table_cache->getCurrentNumCachedItems(
1165 if (with_bbox_intersect_tuning_param) {
1167 return hash_table_cache->getCurrentNumCleanCachedItems(
1169 get_num_cached_auto_tuner_param();
1171 return hash_table_cache->getCurrentNumCleanCachedItems(
1175 if (with_bbox_intersect_tuning_param) {
1177 return hash_table_cache->getCurrentNumDirtyCachedItems(
1179 get_num_cached_auto_tuner_param();
1181 return hash_table_cache->getCurrentNumDirtyCachedItems(
1186 return static_cast<size_t>(0);
1191 switch (hash_table_type) {
1194 CHECK(hash_table_cache);
1195 return get_num_cached_hashtable(hash_table_cache);
1199 CHECK(hash_table_cache);
1200 return get_num_cached_hashtable(hash_table_cache);
1204 CHECK(hash_table_cache);
1205 return get_num_cached_hashtable(hash_table_cache);
1208 return get_num_cached_auto_tuner_param();
1218 void QueryRunner::reset() {
1227 const std::string session_id)
1229 std::make_unique<Catalog_Namespace::
SessionInfo>(cat, user, dt, session_id)) {}
1232 const std::string& table_name,
1233 const bool compression,
1235 const bool explode_collections) {
1236 using namespace import_export;
1238 static constexpr
bool kIsGeoRaster{
false};
1246 copy_params.geo_coords_comp_param = 32;
1249 copy_params.geo_coords_comp_param = 0;
1251 copy_params.geo_explode_collections = explode_collections;
1253 std::map<std::string, std::string> colname_to_src;
1255 auto cds = Importer::gdalToColumnDescriptors(
1258 for (
auto& cd : cds) {
1261 colname_to_src.insert(std::make_pair(col_name_sanitized, cd.columnName));
1263 cd.columnName = col_name_sanitized;
1267 const auto td =
cat.getMetadataForTable(table_name);
1268 if (td !=
nullptr) {
1269 throw std::runtime_error(
1270 "Error: Table " + table_name +
1271 " already exists. Possible failure to correctly re-create " +
1275 throw std::runtime_error(
"Invalid characters in table name: " + table_name);
1278 std::string stmt{
"CREATE TABLE " + table_name};
1279 std::vector<std::string> col_stmts;
1281 for (
auto& cd : cds) {
1284 throw std::runtime_error(
1285 "Unsupported type: INTERVAL_DAY_TIME or INTERVAL_YEAR_MONTH for col " +
1286 cd.columnName +
" (table: " + table_name +
")");
1290 if (cd.columnType.get_precision() == 0 && cd.columnType.get_scale() == 0) {
1291 cd.columnType.set_precision(14);
1292 cd.columnType.set_scale(7);
1296 std::string col_stmt;
1297 col_stmt.append(cd.columnName +
" " + cd.columnType.get_type_name() +
" ");
1300 col_stmt.append(
"ENCODING " + cd.columnType.get_compression_name() +
" ");
1302 if (cd.columnType.is_string()) {
1303 col_stmt.append(
"ENCODING NONE");
1304 }
else if (cd.columnType.is_geometry()) {
1305 if (cd.columnType.get_output_srid() == 4326) {
1306 col_stmt.append(
"ENCODING NONE");
1310 col_stmts.push_back(col_stmt);
1316 LOG(
INFO) <<
"Created table: " << table_name;
1318 LOG(
INFO) <<
"Not creating table: " << table_name;
1321 const auto td =
cat.getMetadataForTable(table_name);
1322 if (td ==
nullptr) {
1323 throw std::runtime_error(
"Error: Failed to create table " + table_name);
1329 LOG(
INFO) <<
"Import Time for " << table_name <<
": " << (double)ms / 1000.0 <<
" s";
bool g_enable_calcite_view_optimize
Classes used to wrap parser calls for calcite redirection.
static void addUdfs(const std::string &json_func_sigs)
ImportStatus importGDAL(const std::map< std::string, std::string > &colname_to_src, const Catalog_Namespace::SessionInfo *session_info, const bool is_raster)
const std::string kDataDirectoryName
static std::vector< TableFunction > get_table_funcs()
bool find_push_down_candidates
static void loadTestRuntimeLibs()
std::unique_ptr< QueryDispatchQueue > dispatch_queue_
static TimeT::rep execution(F func, Args &&...args)
std::string const & getQueryStr() const
static void initialize(const std::string &data_dir, const std::string &allowed_import_paths, const std::string &allowed_export_paths)
const std::string kDefaultDiskCacheDirName
static void loadRuntimeLibs(const std::string &torch_lib_path=std::string())
ImportDriver(std::shared_ptr< Catalog_Namespace::Catalog > cat, const Catalog_Namespace::UserMetadata &user, const ExecutorDeviceType dt=ExecutorDeviceType::GPU, const std::string session_id="")
ExecutorExplainType explain_type_
static void add(const std::string &json_func_sigs)
std::optional< std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > > getParsedQueryHints()
std::optional< RegisteredQueryHint > getParsedQueryHint(const RelAlgNode *node)
static void init_resource_mgr(const size_t num_cpu_slots, const size_t num_gpu_slots, const size_t cpu_result_mem, const size_t cpu_buffer_pool_mem, const size_t gpu_buffer_pool_mem, const double per_query_max_cpu_slots_ratio, const double per_query_max_cpu_result_mem_ratio, const bool allow_cpu_kernel_concurrency, const bool allow_cpu_gpu_kernel_concurrency, const bool allow_cpu_slot_oversubscription_concurrency, const bool allow_cpu_result_mem_oversubscription, const double max_available_resource_use_ratio)
void set_once_fatal_func(FatalFunc fatal_func)
Catalog_Namespace::DBMetadata db_metadata_
static ExecutionOptions defaultExecutionOptionsForRunSQL(bool allow_loop_joins=true, bool just_explain=false)
virtual std::shared_ptr< ResultSet > runSQL(const std::string &query_str, CompilationOptions co, ExecutionOptions eo)
const std::string kGeoColumnName
#define LOG_IF(severity, condition)
static void clearMemory(const Data_Namespace::MemoryLevel memory_level)
void calcite_shutdown_handler() noexcept
static void addShutdownCallback(std::function< void()> shutdown_callback)
std::shared_ptr< const RelAlgNode > getRootRelAlgNodeShPtr() const
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
std::shared_ptr< QueryEngine > query_engine_
bool g_enable_executor_resource_mgr
This file contains the class specification and related data structures for Catalog.
bool output_columnar_hint
RaExecutionSequence getRaExecutionSequence(const RelAlgNode *root_node, Executor *executor)
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
bool g_enable_columnar_output
Supported runtime functions management and retrieval.
static SysCatalog & instance()
void execute(const Catalog_Namespace::SessionInfo &session, bool read_only_mode) override
Classes representing a parse tree.
const std::string kDefaultDbName
void init(LogOptions const &log_opts)
std::unique_ptr< Parser::Stmt > create_stmt_for_json(const std::string &query_json)
static HashtableRecycler * getHashTableCache()
static std::shared_ptr< QueryEngine > createInstance(CudaMgr_Namespace::CudaMgr *cuda_mgr, bool cpu_only)
A container for relational algebra descriptors defining the execution order for a relational algebra ...
ExecutorExplainType explain_type
static void registerSignalHandler()
virtual void runDDLStatement(const std::string &)
static std::unique_ptr< QueryRunner > qr_instance_
double g_gpu_mem_limit_percent
import_export::SourceType source_type
bool g_serialize_temp_tables
ExecutorDeviceType device_type
std::optional< RegisteredQueryHint > getGlobalQueryHint()
void importGeoTable(const std::string &file_path, const std::string &table_name, const bool compression, const bool create_table, const bool explode_collections)
const std::string kRootUsername
static RegisteredQueryHint defaults()
TExtArgumentType::type to_thrift(const ExtArgumentType &t)
std::shared_ptr< ExecutionResult > run_select_query_with_filter_push_down(QueryStateProxy query_state_proxy, const ExecutorDeviceType device_type, const bool hoist_literals, const bool allow_loop_joins, const bool just_explain, const ExecutorExplainType explain_type, const bool with_filter_push_down)
ExecutionResult execute(bool read_only_mode)
std::string sanitize_name(const std::string &name, const bool underscore=false)
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
virtual std::shared_ptr< ExecutionResult > runSelectQuery(const std::string &query_str, CompilationOptions co, ExecutionOptions eo)
std::shared_ptr< Calcite > g_calcite
const std::string kCatalogDirectoryName
static std::shared_ptr< query_state::QueryState > create_query_state(Ts &&...args)
static CompilationOptions defaults(const ExecutorDeviceType device_type=ExecutorDeviceType::GPU)
bool g_enable_filter_push_down
std::string pg_shim(std::string const &query)
QueryPlanDagInfo getQueryInfoForDataRecyclerTest(const std::string &)
static HashtableRecycler * getHashTableCache()
size_t gpu_buffer_mem_bytes
double gpu_input_mem_limit_percent
Serializers for query engine types to/from thrift.
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
void setup_signal_handler()
static constexpr ExecutorId UNITARY_EXECUTOR_ID
static HashtableRecycler * getHashTableCache()
void init_table_functions()
std::unique_ptr< RelAlgDag > getOwnedRelAlgDag()
static constexpr DeviceIdentifier CPU_DEVICE_IDENTIFIER
static ExecutionOptions defaults()
std::shared_ptr< Catalog_Namespace::SessionInfo const > getConstSessionInfo() const
static BoundingBoxIntersectTuningParamRecycler * getBoundingBoxIntersectTuningParamCache()
ThreadLocalIds thread_local_ids()