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));
656 return execution_result->getRows();
659 std::shared_ptr<ResultSet> QueryRunner::runSQL(
const std::string& query_str,
661 const bool hoist_literals,
662 const bool allow_loop_joins) {
664 co.hoist_literals = hoist_literals;
690 std::shared_ptr<Executor> QueryRunner::getExecutor()
const {
694 auto stdlog =
STDLOG(query_state);
699 std::shared_ptr<ResultSet> QueryRunner::runSQLWithAllowingInterrupt(
700 const std::string& query_str,
701 const std::string& session_id,
703 const double running_query_check_freq,
704 const unsigned pending_query_check_freq) {
708 auto session_info = std::make_shared<Catalog_Namespace::SessionInfo>(
709 session_info_->get_catalog_ptr(), current_user, device_type, session_id);
711 auto stdlog =
STDLOG(query_state);
712 auto&
cat = query_state->getConstSessionInfo()->getCatalog();
713 std::string query_ra{
""};
715 std::shared_ptr<ExecutionResult>
result;
716 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
722 &running_query_check_freq,
723 &pending_query_check_freq,
743 running_query_check_freq,
744 pending_query_check_freq,
751 std::lock_guard<std::mutex> calcite_lock_guard(
calcite_lock);
752 auto calcite_mgr = cat.getCalciteMgr();
753 const auto calciteQueryParsingOption =
754 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
755 const auto calciteOptimizationOption =
756 calcite_mgr->getCalciteOptimizationOption(
758 query_ra = calcite_mgr
759 ->process(query_state->createQueryStateProxy(),
760 pg_shim(query_state->getQueryStr()),
761 calciteQueryParsingOption,
762 calciteOptimizationOption)
765 auto ra_executor =
RelAlgExecutor(executor.get(), query_ra, query_state);
766 result = std::make_shared<ExecutionResult>(
767 ra_executor.executeRelAlgQuery(co, eo,
false,
false,
nullptr));
770 executor->enrollQuerySession(session_id,
772 query_state->getQuerySubmittedTime(),
774 QuerySessionStatus::QueryStatus::PENDING_QUEUE);
777 auto result_future = query_launch_task->get_future();
780 return result->getRows();
783 std::vector<std::shared_ptr<ResultSet>> QueryRunner::runMultipleStatements(
784 const std::string& sql,
786 std::vector<std::shared_ptr<ResultSet>> results;
788 auto fields =
split(sql,
";");
789 for (
const auto&
field : fields) {
798 results.push_back(
nullptr);
801 results.push_back(
runSQL(text, dt,
true,
true));
812 std::unique_ptr<import_export::Loader> QueryRunner::getLoader(
815 return std::make_unique<import_export::Loader>(*
cat, td);
823 const bool hoist_literals,
824 const bool allow_loop_joins,
825 const bool just_explain,
827 const bool with_filter_push_down) {
840 auto calcite_mgr =
cat.getCalciteMgr();
841 const auto calciteQueryParsingOption =
842 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
843 auto calciteOptimizationOption =
845 const auto query_ra = calcite_mgr
846 ->process(query_state_proxy,
848 calciteQueryParsingOption,
849 calciteOptimizationOption)
852 auto result = std::make_shared<ExecutionResult>(
853 ra_executor.executeRelAlgQuery(co, eo,
false,
false,
nullptr));
854 const auto& filter_push_down_requests = result->getPushedDownFilterInfo();
855 if (!filter_push_down_requests.empty()) {
856 std::vector<TFilterPushDownInfo> filter_push_down_info;
857 for (
const auto& req : filter_push_down_requests) {
858 TFilterPushDownInfo filter_push_down_info_for_request;
859 filter_push_down_info_for_request.input_prev = req.input_prev;
860 filter_push_down_info_for_request.input_start = req.input_start;
861 filter_push_down_info_for_request.input_next = req.input_next;
862 filter_push_down_info.push_back(filter_push_down_info_for_request);
864 calciteOptimizationOption.filter_push_down_info = filter_push_down_info;
865 const auto new_query_ra = calcite_mgr
866 ->process(query_state_proxy,
868 calciteQueryParsingOption,
869 calciteOptimizationOption)
871 auto eo_modified = eo;
873 eo_modified.just_calcite_explain =
false;
874 auto new_ra_executor =
RelAlgExecutor(executor.get(), new_query_ra);
875 return std::make_shared<ExecutionResult>(
876 new_ra_executor.executeRelAlgQuery(co, eo_modified,
false,
false,
nullptr));
884 std::shared_ptr<ResultSet> QueryRunner::getCalcitePlan(
const std::string& query_str,
885 bool enable_watchdog,
886 bool is_explain_as_json_str,
887 bool is_explain_detailed)
const {
892 auto stdlog =
STDLOG(query_state);
894 std::shared_ptr<ResultSet>
result;
895 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
899 &is_explain_as_json_str,
900 &is_explain_detailed,
906 auto calcite_mgr = cat.getCalciteMgr();
909 const auto calciteQueryParsingOption = calcite_mgr->getCalciteQueryParsingOption(
910 true, !is_explain_as_json_str,
false, is_explain_detailed);
911 const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
913 const auto query_ra = calcite_mgr
914 ->process(query_state->createQueryStateProxy(),
916 calciteQueryParsingOption,
917 calciteOptimizationOption)
919 result = std::make_shared<ResultSet>(query_ra);
924 auto result_future = query_launch_task->get_future();
930 std::shared_ptr<ExecutionResult> QueryRunner::runSelectQuery(
const std::string& query_str,
936 auto stdlog =
STDLOG(query_state);
949 std::shared_ptr<ExecutionResult>
result;
950 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
965 co.explain_type = explain_type;
966 auto calcite_mgr = cat.getCalciteMgr();
967 const auto calciteQueryParsingOption =
968 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
969 const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
971 const auto query_ra = calcite_mgr
972 ->process(query_state->createQueryStateProxy(),
974 calciteQueryParsingOption,
975 calciteOptimizationOption)
978 result = std::make_shared<ExecutionResult>(
979 ra_executor.executeRelAlgQuery(co, eo,
false,
false,
nullptr));
983 auto result_future = query_launch_task->get_future();
989 std::shared_ptr<ExecutionResult> QueryRunner::runSelectQuery(
990 const std::string& query_str,
992 const bool hoist_literals,
993 const bool allow_loop_joins,
994 const bool just_explain) {
996 co.hoist_literals = hoist_literals;
1006 query_dag_info.root_node.get(), executor);
1007 return extracted_dag_info;
1010 std::unique_ptr<RelAlgDag> QueryRunner::getRelAlgDag(
const std::string& query_str) {
1014 auto stdlog =
STDLOG(query_state);
1017 std::unique_ptr<RelAlgDag> rel_alg_dag;
1018 auto query_launch_task = std::make_shared<QueryDispatchQueue::Task>(
1027 auto calcite_mgr = cat.getCalciteMgr();
1028 const auto calciteQueryParsingOption =
1029 calcite_mgr->getCalciteQueryParsingOption(
true,
false,
true,
false);
1030 const auto calciteOptimizationOption = calcite_mgr->getCalciteOptimizationOption(
1032 const auto query_ra = calcite_mgr
1033 ->process(query_state->createQueryStateProxy(),
1035 calciteQueryParsingOption,
1036 calciteOptimizationOption)
1043 auto result_future = query_launch_task->get_future();
1044 result_future.get();
1060 std::shared_ptr<HashTable>,
1061 std::optional<HashtableCacheMetaInfo>>
1062 QueryRunner::getCachedHashtableWithoutCacheKey(std::set<size_t>& visited,
1066 switch (hash_table_type) {
1084 CHECK(hash_table_cache);
1085 return hash_table_cache->getCachedHashtableWithoutCacheKey(
1086 visited, hash_table_type, device_identifier);
1089 std::shared_ptr<CacheItemMetric> QueryRunner::getCacheItemMetric(
1094 switch (hash_table_type) {
1112 CHECK(hash_table_cache);
1113 return hash_table_cache->getCachedItemMetric(
1114 hash_table_type, device_identifier, cache_key);
1119 bool with_bbox_intersect_tuning_param)
const {
1120 auto get_num_cached_auto_tuner_param = [&item_status]() {
1121 auto auto_tuner_cache =
1123 CHECK(auto_tuner_cache);
1124 switch (item_status) {
1126 return auto_tuner_cache->getCurrentNumCachedItems(
1131 return auto_tuner_cache->getCurrentNumCleanCachedItems(
1136 return auto_tuner_cache->getCurrentNumDirtyCachedItems(
1142 return static_cast<size_t>(0);
1147 auto get_num_cached_hashtable =
1150 &with_bbox_intersect_tuning_param,
1152 switch (item_status) {
1154 if (with_bbox_intersect_tuning_param) {
1158 return hash_table_cache->getCurrentNumCachedItems(
1160 get_num_cached_auto_tuner_param();
1162 return hash_table_cache->getCurrentNumCachedItems(
1166 if (with_bbox_intersect_tuning_param) {
1168 return hash_table_cache->getCurrentNumCleanCachedItems(
1170 get_num_cached_auto_tuner_param();
1172 return hash_table_cache->getCurrentNumCleanCachedItems(
1176 if (with_bbox_intersect_tuning_param) {
1178 return hash_table_cache->getCurrentNumDirtyCachedItems(
1180 get_num_cached_auto_tuner_param();
1182 return hash_table_cache->getCurrentNumDirtyCachedItems(
1187 return static_cast<size_t>(0);
1192 switch (hash_table_type) {
1195 CHECK(hash_table_cache);
1196 return get_num_cached_hashtable(hash_table_cache);
1200 CHECK(hash_table_cache);
1201 return get_num_cached_hashtable(hash_table_cache);
1205 CHECK(hash_table_cache);
1206 return get_num_cached_hashtable(hash_table_cache);
1209 return get_num_cached_auto_tuner_param();
1219 void QueryRunner::reset() {
1228 const std::string session_id)
1230 std::make_unique<Catalog_Namespace::
SessionInfo>(cat, user, dt, session_id)) {}
1233 const std::string& table_name,
1234 const bool compression,
1236 const bool explode_collections) {
1237 using namespace import_export;
1239 static constexpr
bool kIsGeoRaster{
false};
1247 copy_params.geo_coords_comp_param = 32;
1250 copy_params.geo_coords_comp_param = 0;
1252 copy_params.geo_explode_collections = explode_collections;
1254 std::map<std::string, std::string> colname_to_src;
1256 auto cds = Importer::gdalToColumnDescriptors(
1259 for (
auto& cd : cds) {
1262 colname_to_src.insert(std::make_pair(col_name_sanitized, cd.columnName));
1264 cd.columnName = col_name_sanitized;
1268 const auto td =
cat.getMetadataForTable(table_name);
1269 if (td !=
nullptr) {
1270 throw std::runtime_error(
1271 "Error: Table " + table_name +
1272 " already exists. Possible failure to correctly re-create " +
1276 throw std::runtime_error(
"Invalid characters in table name: " + table_name);
1279 std::string stmt{
"CREATE TABLE " + table_name};
1280 std::vector<std::string> col_stmts;
1282 for (
auto& cd : cds) {
1285 throw std::runtime_error(
1286 "Unsupported type: INTERVAL_DAY_TIME or INTERVAL_YEAR_MONTH for col " +
1287 cd.columnName +
" (table: " + table_name +
")");
1291 if (cd.columnType.get_precision() == 0 && cd.columnType.get_scale() == 0) {
1292 cd.columnType.set_precision(14);
1293 cd.columnType.set_scale(7);
1297 std::string col_stmt;
1298 col_stmt.append(cd.columnName +
" " + cd.columnType.get_type_name() +
" ");
1301 col_stmt.append(
"ENCODING " + cd.columnType.get_compression_name() +
" ");
1303 if (cd.columnType.is_string()) {
1304 col_stmt.append(
"ENCODING NONE");
1305 }
else if (cd.columnType.is_geometry()) {
1306 if (cd.columnType.get_output_srid() == 4326) {
1307 col_stmt.append(
"ENCODING NONE");
1311 col_stmts.push_back(col_stmt);
1317 LOG(
INFO) <<
"Created table: " << table_name;
1319 LOG(
INFO) <<
"Not creating table: " << table_name;
1322 const auto td =
cat.getMetadataForTable(table_name);
1323 if (td ==
nullptr) {
1324 throw std::runtime_error(
"Error: Failed to create table " + table_name);
1330 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
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
std::string pg_shim(const std::string &query)
static BoundingBoxIntersectTuningParamRecycler * getBoundingBoxIntersectTuningParamCache()
ThreadLocalIds thread_local_ids()