28 #include <gperftools/heap-profiler.h>
29 #endif // HAVE_PROFILER
63 #include <sys/types.h>
64 #include <thrift/server/TServer.h>
65 #include <thrift/transport/THttpClient.h>
66 #include <thrift/transport/TSocket.h>
67 #include <thrift/transport/TTransport.h>
69 #include <boost/algorithm/string.hpp>
70 #include <boost/algorithm/string/replace.hpp>
71 #include <boost/algorithm/string/trim.hpp>
72 #include <boost/filesystem.hpp>
73 #include <boost/make_shared.hpp>
74 #include <boost/noncopyable.hpp>
75 #include <boost/none_t.hpp>
76 #include <boost/optional.hpp>
77 #include <boost/program_options.hpp>
78 #include <boost/tokenizer.hpp>
90 #include <unordered_map>
92 #include "gen-cpp/Heavy.h"
93 #include "gen-cpp/extension_functions_types.h"
95 using namespace std::string_literals;
103 using SessionMap = std::map<TSessionId, std::shared_ptr<Catalog_Namespace::SessionInfo>>;
107 namespace dbhandler {
111 bool throw_db_exception =
false);
117 : HeavyProcessor(handler), check_origin_(check_origin) {}
119 bool process(std::shared_ptr<::apache::thrift::protocol::TProtocol> in,
120 std::shared_ptr<::apache::thrift::protocol::TProtocol> out,
121 void* connectionContext)
override {
122 using namespace ::apache::thrift;
124 auto transport = in->getTransport();
125 if (transport && check_origin_) {
126 static std::mutex processor_mutex;
128 const auto origin_str = transport->getOrigin();
129 std::vector<std::string> origins;
130 boost::split(origins, origin_str, boost::is_any_of(
","));
131 if (origins.empty()) {
136 auto trimmed_origin = origins.front();
137 boost::algorithm::trim(trimmed_origin);
140 if (dynamic_cast<transport::THttpTransport*>(transport.get())) {
142 }
else if (dynamic_cast<transport::TBufferedTransport*>(transport.get())) {
151 return HeavyProcessor::process(in, out, connectionContext);
161 namespace File_Namespace {
162 struct DiskCacheConfig;
167 DBHandler(
const std::vector<LeafHostInfo>& db_leaves,
168 const std::vector<LeafHostInfo>& string_leaves,
169 const std::string& base_data_path,
170 const bool allow_multifrag,
171 const bool jit_debug,
172 const bool intel_jit_profile,
173 const bool read_only,
174 const bool allow_loop_joins,
175 const bool enable_rendering,
176 const bool renderer_prefer_igpu,
177 const unsigned renderer_vulkan_timeout_ms,
178 const bool renderer_use_parallel_executors,
179 const bool enable_auto_clear_render_mem,
180 const int render_oom_retry_threshold,
181 const size_t render_mem_bytes,
182 const size_t max_concurrent_render_sessions,
183 const size_t reserved_gpu_mem,
184 const bool render_compositor_use_last_gpu,
185 const bool renderer_enable_slab_allocation,
186 const size_t num_reader_threads,
189 const bool legacy_syntax,
190 const int idle_session_duration,
191 const int max_session_duration,
192 const std::string& udf_filename,
193 const std::string& clang_path,
194 const std::vector<std::string>& clang_options,
196 const std::string& libgeos_so_filename,
198 #ifdef HAVE_TORCH_TFS
199 const std::string& torch_lib_path,
202 const bool is_new_db);
203 void initialize(
const bool is_new_db);
207 return 2 * 1000 * 1000 * 1000LL;
215 void krb5_connect(TKrb5Session& session,
216 const std::string& token,
217 const std::string& dbname)
override;
219 void connect(TSessionId& session,
220 const std::string& username,
221 const std::string& passwd,
222 const std::string& dbname)
override;
223 void disconnect(
const TSessionId& session)
override;
224 void switch_database(
const TSessionId& session,
const std::string& dbname)
override;
225 void clone_session(TSessionId& session2,
const TSessionId& session1)
override;
226 void get_server_status(TServerStatus& _return,
const TSessionId& session)
override;
227 void get_status(std::vector<TServerStatus>& _return,
228 const TSessionId& session)
override;
229 void get_hardware_info(TClusterHardwareInfo& _return,
230 const TSessionId& session)
override;
234 void get_tables(std::vector<std::string>& _return,
const TSessionId& session)
override;
235 void get_tables_for_database(std::vector<std::string>& _return,
236 const TSessionId& session,
237 const std::string& database_name)
override;
238 void get_physical_tables(std::vector<std::string>& _return,
239 const TSessionId& session)
override;
240 void get_views(std::vector<std::string>& _return,
const TSessionId& session)
override;
241 void get_tables_meta(std::vector<TTableMeta>& _return,
242 const TSessionId& session)
override;
243 void get_table_details(TTableDetails& _return,
244 const TSessionId& session,
245 const std::string& table_name)
override;
246 void get_table_details_for_database(TTableDetails& _return,
247 const TSessionId& session,
248 const std::string& table_name,
249 const std::string& database_name)
override;
250 void get_internal_table_details(TTableDetails& _return,
251 const TSessionId& session,
252 const std::string& table_name,
253 const bool include_system_columns)
override;
254 void get_internal_table_details_for_database(TTableDetails& _return,
255 const TSessionId& session,
256 const std::string& table_name,
257 const std::string& database_name)
override;
258 void get_users(std::vector<std::string>& _return,
const TSessionId& session)
override;
259 void get_databases(std::vector<TDBInfo>& _return,
const TSessionId& session)
override;
261 void get_version(std::string& _return)
override;
262 void start_heap_profile(
const TSessionId& session)
override;
263 void stop_heap_profile(
const TSessionId& session)
override;
264 void get_heap_profile(std::string& _return,
const TSessionId& session)
override;
265 void get_memory(std::vector<TNodeMemoryInfo>& _return,
266 const TSessionId& session,
267 const std::string& memory_level)
override;
268 void clear_cpu_memory(
const TSessionId& session)
override;
269 void clear_gpu_memory(
const TSessionId& session)
override;
270 void clearRenderMemory(
const TSessionId& session);
273 void pause_executor_queue(
274 const TSessionId& session);
275 void resume_executor_queue(
276 const TSessionId& session);
278 void set_cur_session(
const TSessionId& parent_session,
279 const TSessionId& leaf_session,
280 const std::string& start_time_str,
281 const std::string&
label,
282 bool for_running_query_kernel)
override;
283 void invalidate_cur_session(
const TSessionId& parent_session,
284 const TSessionId& leaf_session,
285 const std::string& start_time_str,
286 const std::string&
label,
287 bool for_running_query_kernel)
override;
288 void set_table_epoch(
const TSessionId& session,
291 const int new_epoch)
override;
292 void set_table_epoch_by_name(
const TSessionId& session,
293 const std::string& table_name,
294 const int new_epoch)
override;
295 int32_t get_table_epoch(
const TSessionId& session,
297 const int32_t table_id)
override;
298 int32_t get_table_epoch_by_name(
const TSessionId& session,
299 const std::string& table_name)
override;
300 void get_table_epochs(std::vector<TTableEpochInfo>& _return,
301 const TSessionId& session,
303 const int32_t table_id)
override;
304 void set_table_epochs(
const TSessionId& session,
306 const std::vector<TTableEpochInfo>& table_epochs)
override;
308 void get_session_info(TSessionInfo& _return,
const TSessionId& session)
override;
310 void set_leaf_info(
const TSessionId& session,
const TLeafInfo& info)
override;
313 const TSessionId& session,
314 const std::string& query,
315 const bool column_format,
316 const int32_t first_n,
317 const int32_t at_most_n,
320 void sql_execute(TQueryResult& _return,
321 const TSessionId& session,
322 const std::string& query,
323 const bool column_format,
324 const std::string& nonce,
325 const int32_t first_n,
326 const int32_t at_most_n)
override;
327 void get_completion_hints(std::vector<TCompletionHint>& hints,
328 const TSessionId& session,
329 const std::string& sql,
330 const int cursor)
override;
332 void sql_execute_df(TDataFrame& _return,
333 const TSessionId& session,
334 const std::string& query,
336 const int32_t device_id,
337 const int32_t first_n,
339 void sql_execute_gdf(TDataFrame& _return,
340 const TSessionId& session,
341 const std::string& query,
342 const int32_t device_id,
343 const int32_t first_n)
override;
344 void deallocate_df(
const TSessionId& session,
345 const TDataFrame& df,
347 const int32_t device_id)
override;
348 void interrupt(
const TSessionId& query_session,
349 const TSessionId& interrupt_session)
override;
350 void sql_validate(TRowDescriptor& _return,
351 const TSessionId& session,
352 const std::string& query)
override;
354 void set_execution_mode(
const TSessionId& session,
356 void render_vega(TRenderResult& _return,
357 const TSessionId& session,
358 const int64_t widget_id,
359 const std::string& vega_json,
360 const int32_t compression_level,
361 const std::string& nonce)
override;
362 void get_result_row_for_pixel(
363 TPixelTableRowResult& _return,
364 const TSessionId& session,
365 const int64_t widget_id,
367 const std::map<std::string, std::vector<std::string>>& table_col_names,
368 const bool column_format,
369 const int32_t pixel_radius,
370 const std::string& nonce)
override;
373 int32_t create_custom_expression(
const TSessionId& session,
374 const TCustomExpression& custom_expression)
override;
375 void get_custom_expressions(std::vector<TCustomExpression>& _return,
376 const TSessionId& session)
override;
377 void update_custom_expression(
const TSessionId& session,
379 const std::string& expression_json)
override;
380 void delete_custom_expressions(
const TSessionId& session,
381 const std::vector<int32_t>& custom_expression_ids,
382 const bool do_soft_delete)
override;
385 void get_dashboard(TDashboard& _return,
386 const TSessionId& session,
387 const int32_t dashboard_id)
override;
388 void get_dashboards(std::vector<TDashboard>& _return,
389 const TSessionId& session)
override;
391 const std::string& dashboard_name,
392 const std::string& dashboard_state,
393 const std::string& image_hash,
394 const std::string& dashboard_metadata)
override;
395 void replace_dashboard(
const TSessionId& session,
396 const int32_t dashboard_id,
397 const std::string& dashboard_name,
398 const std::string& dashboard_owner,
399 const std::string& dashboard_state,
400 const std::string& image_hash,
401 const std::string& dashboard_metadata)
override;
402 void delete_dashboard(
const TSessionId& session,
const int32_t dashboard_id)
override;
403 void share_dashboards(
const TSessionId& session,
404 const std::vector<int32_t>& dashboard_ids,
405 const std::vector<std::string>& groups,
406 const TDashboardPermissions& permissions)
override;
407 void delete_dashboards(
const TSessionId& session,
408 const std::vector<int32_t>& dashboard_ids)
override;
409 void share_dashboard(
const TSessionId& session,
410 const int32_t dashboard_id,
411 const std::vector<std::string>& groups,
412 const std::vector<std::string>& objects,
413 const TDashboardPermissions& permissions,
414 const bool grant_role)
override;
415 void unshare_dashboards(
const TSessionId& session,
416 const std::vector<int32_t>& dashboard_ids,
417 const std::vector<std::string>& groups,
418 const TDashboardPermissions& permissions)
override;
419 void unshare_dashboard(
const TSessionId& session,
420 const int32_t dashboard_id,
421 const std::vector<std::string>& groups,
422 const std::vector<std::string>& objects,
423 const TDashboardPermissions& permissions)
override;
424 void get_dashboard_grantees(std::vector<TDashboardGrantees>& _return,
425 const TSessionId& session,
426 const int32_t dashboard_id)
override;
428 void get_link_view(TFrontendView& _return,
429 const TSessionId& session,
430 const std::string& link)
override;
431 void create_link(std::string& _return,
432 const TSessionId& session,
433 const std::string& view_state,
434 const std::string& view_metadata)
override;
436 void load_table_binary(
const TSessionId& session,
437 const std::string& table_name,
438 const std::vector<TRow>&
rows,
439 const std::vector<std::string>& column_names)
override;
441 void load_table_binary_columnar(
const TSessionId& session,
442 const std::string& table_name,
443 const std::vector<TColumn>& cols,
444 const std::vector<std::string>& column_names)
override;
445 void load_table_binary_arrow(
const TSessionId& session,
446 const std::string& table_name,
447 const std::string& arrow_stream,
448 const bool use_column_names)
override;
450 void load_table(
const TSessionId& session,
451 const std::string& table_name,
452 const std::vector<TStringRow>&
rows,
453 const std::vector<std::string>& column_names)
override;
454 void detect_column_types(TDetectResult& _return,
455 const TSessionId& session,
456 const std::string& file_name,
457 const TCopyParams& copy_params)
override;
459 const std::string& table_name,
460 const TRowDescriptor& row_desc,
461 const TCreateParams& create_params)
override;
462 void import_table(
const TSessionId& session,
463 const std::string& table_name,
464 const std::string& file_name,
465 const TCopyParams& copy_params)
override;
466 void import_geo_table(
const TSessionId& session,
467 const std::string& table_name,
468 const std::string& file_name,
469 const TCopyParams& copy_params,
470 const TRowDescriptor& row_desc,
471 const TCreateParams& create_params)
override;
472 void import_table_status(TImportStatus& _return,
473 const TSessionId& session,
474 const std::string& import_id)
override;
475 void get_first_geo_file_in_archive(std::string& _return,
476 const TSessionId& session,
477 const std::string& archive_path,
478 const TCopyParams& copy_params)
override;
479 void get_all_files_in_archive(std::vector<std::string>& _return,
480 const TSessionId& session,
481 const std::string& archive_path,
482 const TCopyParams& copy_params)
override;
483 void get_layers_in_geo_file(std::vector<TGeoFileLayerInfo>& _return,
484 const TSessionId& session,
485 const std::string& file_name,
486 const TCopyParams& copy_params)
override;
488 int64_t query_get_outer_fragment_count(
const TSessionId& session,
489 const std::string& select_query)
override;
491 void check_table_consistency(TTableMeta& _return,
492 const TSessionId& session,
493 const int32_t table_id)
override;
494 void start_query(TPendingQuery& _return,
495 const TSessionId& leaf_session,
496 const TSessionId& parent_session,
497 const std::string& serialized_rel_alg_dag,
498 const std::string& start_time_str,
499 const bool just_explain,
500 const std::vector<int64_t>& outer_fragment_indices)
override;
501 void execute_query_step(TStepResult& _return,
502 const TPendingQuery& pending_query,
503 const TSubqueryId subquery_id,
504 const std::string& start_time_str)
override;
505 void broadcast_serialized_rows(
const TSerializedRows& serialized_rows,
506 const TRowDescriptor& row_desc,
507 const TQueryId query_id,
508 const TSubqueryId subquery_id,
509 const bool is_final_subquery_result)
override;
511 void start_render_query(TPendingRenderQuery& _return,
512 const TSessionId& session,
513 const int64_t widget_id,
514 const int16_t node_idx,
515 const std::string& vega_json)
override;
516 void execute_next_render_step(TRenderStepResult& _return,
517 const TPendingRenderQuery& pending_render,
518 const TRenderAggDataMap& merged_data)
override;
520 void insert_data(
const TSessionId& session,
const TInsertData& insert_data)
override;
521 void insert_chunks(
const TSessionId& session,
522 const TInsertChunks& insert_chunks)
override;
523 void checkpoint(
const TSessionId& session,
const int32_t table_id)
override;
525 void get_roles(std::vector<std::string>& _return,
const TSessionId& session)
override;
526 bool has_role(
const TSessionId& sessionId,
527 const std::string& granteeName,
528 const std::string& roleName)
override;
529 bool has_object_privilege(
const TSessionId& sessionId,
530 const std::string& granteeName,
531 const std::string& objectName,
533 const TDBObjectPermissions& permissions)
override;
534 void get_db_objects_for_grantee(std::vector<TDBObject>& _return,
535 const TSessionId& session,
536 const std::string& roleName)
override;
537 void get_db_object_privs(std::vector<TDBObject>& _return,
538 const TSessionId& session,
539 const std::string& objectName,
541 void get_all_roles_for_user(std::vector<std::string>& _return,
542 const TSessionId& session,
543 const std::string& granteeName)
override;
544 void get_all_effective_roles_for_user(std::vector<std::string>& _return,
545 const TSessionId& session,
546 const std::string& granteeName)
override;
547 std::vector<std::string> get_valid_groups(
const TSessionId& session,
548 int32_t dashboard_id,
549 std::vector<std::string> groups);
551 void set_license_key(TLicenseInfo& _return,
552 const TSessionId& session,
553 const std::string& key,
554 const std::string& nonce)
override;
555 void get_license_claims(TLicenseInfo& _return,
556 const TSessionId& session,
557 const std::string& nonce)
override;
564 const TSessionId& session)
override;
572 void register_runtime_extension_functions(
573 const TSessionId& session,
574 const std::vector<TUserDefinedFunction>& udfs,
575 const std::vector<TUserDefinedTableFunction>& udtfs,
576 const std::map<std::string, std::string>& device_ir_map)
override;
581 void get_function_names(std::vector<std::string>& _return,
582 const TSessionId& session)
override;
587 void get_runtime_function_names(std::vector<std::string>& _return,
588 const TSessionId& session)
override;
593 void get_function_details(std::vector<TUserDefinedFunction>& _return,
594 const TSessionId& session,
595 const std::vector<std::string>& udf_names)
override;
600 void get_table_function_names(std::vector<std::string>& _return,
601 const TSessionId& session)
override;
606 void get_runtime_table_function_names(std::vector<std::string>& _return,
607 const TSessionId& session)
override;
612 void get_table_function_details(std::vector<TUserDefinedTableFunction>& _return,
613 const TSessionId& session,
614 const std::vector<std::string>& udtf_names)
override;
619 void emergency_shutdown();
621 TSessionId getInvalidSessionId()
const;
623 void internal_connect(TSessionId& session,
624 const std::string& username,
625 const std::string& dbname);
627 bool isAggregator()
const;
629 bool checkInMemorySystemTableQuery(
630 const std::unordered_set<shared::TableKey>& tables_selected_from)
const;
662 template <
typename... ARGS>
664 return query_states_.create(std::forward<ARGS>(
args)...);
670 void get_tables_meta_impl(std::vector<TTableMeta>& _return,
673 const bool with_table_locks =
true);
676 void resizeDispatchQueue(
size_t queue_size);
680 std::shared_ptr<Catalog_Namespace::SessionInfo> get_session_ptr(
681 const TSessionId& session_id);
686 std::atomic<bool> initialized_{
false};
687 void init_executor_resource_mgr();
688 void validate_configurations();
689 std::shared_ptr<Catalog_Namespace::SessionInfo> create_new_session(
691 const std::string& dbname,
693 std::shared_ptr<Catalog_Namespace::Catalog>
cat);
694 void connect_impl(TSessionId& session,
695 const std::string& passwd,
696 const std::string& dbname,
698 std::shared_ptr<Catalog_Namespace::Catalog>
cat,
702 const std::string& table_name);
703 void get_tables_impl(std::vector<std::string>& table_names,
706 const std::string& database_name = {});
707 void get_table_details_impl(TTableDetails& _return,
709 const std::string& table_name,
710 const bool get_system,
711 const bool get_physical,
712 const std::string& database_name = {});
713 void getAllRolesForUserImpl(
714 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr,
715 std::vector<std::string>& roles,
716 const std::string& granteeName,
718 void check_read_only(
const std::string& str);
719 void validateGroups(
const std::vector<std::string>& groups);
721 const std::vector<int32_t>& dashboard_ids);
722 void shareOrUnshareDashboards(
const TSessionId& session,
723 const std::vector<int32_t>& dashboard_ids,
724 const std::vector<std::string>& groups,
725 const TDashboardPermissions& permissions,
726 const bool do_share);
728 static void value_to_thrift_column(
const TargetValue& tv,
733 std::pair<TPlanResult, lockmgr::LockedTableDescriptors> parse_to_ra(
735 const std::string& query_str,
736 const std::vector<TFilterPushDownInfo>& filter_push_down_info,
737 const bool acquire_locks,
739 bool check_privileges =
true);
741 void sql_execute_local(
742 TQueryResult& _return,
744 const std::shared_ptr<Catalog_Namespace::SessionInfo> session_ptr,
745 const std::string& query_str,
746 const bool column_format,
747 const std::string& nonce,
748 const int32_t first_n,
749 const int32_t at_most_n,
750 const bool use_calcite);
752 int64_t process_deferred_copy_from(
const TSessionId& session_id);
754 static void convertData(TQueryResult& _return,
757 const bool column_format,
758 const int32_t first_n,
759 const int32_t at_most_n);
763 const bool column_format,
765 const int32_t first_n,
766 const int32_t at_most_n,
767 const bool use_calcite,
774 void execute_distributed_copy_statement(
778 TPlanResult processCalciteRequest(
780 const std::shared_ptr<Catalog_Namespace::Catalog>&
cat,
781 const std::string& query_str,
782 const std::vector<TFilterPushDownInfo>& filter_push_down_info,
784 const bool check_privileges);
786 TRowDescriptor validateRelAlg(
const std::string& query_ra,
789 void dispatch_query_task(std::shared_ptr<QueryDispatchQueue::Task> query_task,
790 const bool is_update_delete);
792 std::vector<PushedDownFilterInfo> execute_rel_alg(
795 const std::string& query_ra,
796 const bool column_format,
798 const int32_t first_n,
799 const int32_t at_most_n,
800 const bool just_validate,
801 const bool find_push_down_candidates,
803 const std::optional<size_t> executor_index = std::nullopt)
const;
805 void execute_rel_alg_with_filter_push_down(
808 std::string& query_ra,
809 const bool column_format,
811 const int32_t first_n,
812 const int32_t at_most_n,
813 const bool just_explain,
814 const bool just_calcite_explain,
815 const std::vector<PushedDownFilterInfo>& filter_push_down_requests);
817 void executeDdl(TQueryResult& _return,
818 const std::string& query_ra,
819 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr);
822 const std::string& query_ra,
823 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr);
830 char unescape_char(std::string str);
833 void check_geospatial_files(
const boost::filesystem::path file_path,
835 void render_rel_alg(TRenderResult& _return,
836 const std::string& query_ra,
837 const std::string& query_str,
839 const std::string& render_type,
840 const bool is_projection_query);
843 const std::string&
name,
844 const bool is_array);
846 static void convertExplain(TQueryResult& _return,
847 const ResultSet& results,
848 const bool column_format);
849 static void convertResult(TQueryResult& _return,
850 const ResultSet& results,
851 const bool column_format);
853 static void convertRows(TQueryResult& _return,
855 const std::vector<TargetMetaInfo>& targets,
856 const ResultSet& results,
857 const bool column_format,
858 const int32_t first_n,
859 const int32_t at_most_n);
865 const std::string& query_state_str,
866 TQueryResult& _return);
868 static void createSimpleResult(TQueryResult& _return,
869 const ResultSet& results,
870 const bool column_format,
871 const std::string
label);
873 std::vector<TargetMetaInfo> getTargetMetaInfo(
874 const std::vector<std::shared_ptr<Analyzer::TargetEntry>>& targets)
const;
876 std::vector<std::string> getTargetNames(
877 const std::vector<TargetMetaInfo>& targets)
const;
879 std::vector<std::string> getTargetNames(
880 const std::vector<std::shared_ptr<Analyzer::TargetEntry>>& targets)
const;
882 void get_completion_hints_unsorted(std::vector<TCompletionHint>& hints,
883 std::vector<std::string>& visible_tables,
885 const std::string& sql,
887 void get_token_based_completions(std::vector<TCompletionHint>& hints,
889 std::vector<std::string>& visible_tables,
890 const std::string& sql,
893 std::unordered_map<std::string, std::unordered_set<std::string>>
894 fill_column_names_by_table(std::vector<std::string>& table_names,
897 TDashboard get_dashboard_impl(
898 const std::shared_ptr<Catalog_Namespace::SessionInfo const>& session_ptr,
901 const bool populate_state =
true);
904 const TDBObjectPermissions& permissions);
906 const TDBObjectPermissions& permission);
908 const TDBObjectPermissions& permissions);
910 const TDBObjectPermissions& permissions);
912 const TDBObjectPermissions& permissions);
917 std::unordered_set<std::string> get_uc_compatible_table_names_by_column(
918 const std::unordered_set<std::string>& uc_column_names,
919 std::vector<std::string>& table_names,
922 std::unique_ptr<lockmgr::AbstractLockContainer<const TableDescriptor*>>
923 prepare_loader_generic(
925 const std::string& table_name,
927 std::unique_ptr<import_export::Loader>* loader,
928 std::vector<std::unique_ptr<import_export::TypedImportBuffer>>* import_buffers,
929 const std::vector<std::string>& column_names,
930 std::string load_type);
933 const TSessionId& session,
935 std::vector<std::unique_ptr<import_export::TypedImportBuffer>>& import_buffers,
939 const std::string& table_name);
941 void fillMissingBuffers(
942 const TSessionId& session,
944 std::vector<std::unique_ptr<import_export::TypedImportBuffer>>& import_buffers,
945 const std::list<const ColumnDescriptor*>& cds,
946 const std::vector<int>& desc_id_to_column_id,
948 const std::string& table_name);
975 const std::string& libgeos_so_filename_;
977 #ifdef HAVE_TORCH_TFS
978 const std::string& torch_lib_path_;
984 int32_t max_num_sessions_{-1};
998 std::optional<DeferredCopyFromState>
operator()(
const std::string& session_id) {
999 std::lock_guard<std::mutex> map_lock(deferred_copy_from_mutex);
1000 auto itr = was_deferred_copy_from.find(session_id);
1001 if (itr == was_deferred_copy_from.end()) {
1002 return std::nullopt;
1008 std::lock_guard<std::mutex> map_lock(deferred_copy_from_mutex);
1009 const auto ret = was_deferred_copy_from.insert(std::make_pair(session_id, state));
1013 void remove(
const std::string& session_id) {
1014 std::lock_guard<std::mutex> map_lock(deferred_copy_from_mutex);
1015 was_deferred_copy_from.erase(session_id);
1025 std::string base_path,
1026 std::string query_file_path);
1032 std::map<const std::string, const PermissionFuncPtr> permissionFuncMap_ = {
1033 {
"database"s, has_database_permission},
1034 {
"dashboard"s, has_dashboard_permission},
1035 {
"table"s, has_table_permission},
1036 {
"view"s, has_view_permission},
1037 {
"server"s, has_server_permission}};
1041 std::string
const createInMemoryCalciteSession(
1042 const std::shared_ptr<Catalog_Namespace::Catalog>& catalog_ptr);
1043 void removeInMemoryCalciteSession(
const std::string& session_id);
1046 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr);
1052 std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr);
1054 void get_queries_info(std::vector<TQueryInfo>& _return,
1055 const TSessionId& session)
override;
1059 const std::string& target_session);
1061 void alterSystemClear(
const std::string& sesson_id,
1063 const std::string& cache_type,
1064 int64_t& execution_time_ms);
1066 void alterSession(
const std::string& sesson_id,
1068 const std::pair<std::string, std::string>& session_parameter,
1069 int64_t& execution_time_ms);
1075 void importGeoTableGlobFilterSort(
const TSessionId& session,
1076 const std::string& table_name,
1077 const std::string& file_name,
1079 const TRowDescriptor& row_desc,
1080 const TCreateParams& create_params);
1082 void importGeoTableSingle(
const TSessionId& session,
1083 const std::string& table_name,
1084 const std::string& file_name,
1086 const TRowDescriptor& row_desc,
1087 const TCreateParams& create_params);
1089 void resetSessionsStore();
std::lock_guard< T > lock_guard
Classes used to wrap parser calls for calcite redirection.
std::vector< LeafHostInfo > string_leaves_
auto get_users(SysCatalog &syscat, std::unique_ptr< SqliteConnector > &sqliteConnector, const int32_t dbId=-1)
const std::vector< std::string > & clang_options_
boost::filesystem::path import_path_
std::unique_ptr< QueryDispatchQueue > dispatch_queue_
std::vector< std::unique_ptr< lockmgr::AbstractLockContainer< const TableDescriptor * >>> LockedTableDescriptors
const bool renderer_use_parallel_executors_
const std::string & udf_filename_
const int render_oom_retry_threshold_
class for a per-database catalog. also includes metadata for the current database and the current use...
void run_warmup_queries(std::shared_ptr< DBHandler > handler, std::string base_path, std::string query_file_path)
std::mutex handle_to_dev_ptr_mutex_
std::mutex deferred_copy_from_mutex
std::shared_ptr< query_state::QueryState > create_query_state(ARGS &&...args)
static thread_local std::string client_address
void add(const std::string &session_id, const DeferredCopyFromState &state)
bool user_can_access_table(const Catalog_Namespace::SessionInfo &session_info, const TableDescriptor *td, const AccessPrivileges access_priv)
bool(*)(const AccessPrivileges &, const TDBObjectPermissions &) PermissionFuncPtr
static thread_local ClientProtocol client_protocol
LeafAggregator leaf_aggregator_
const unsigned renderer_vulkan_timeout_
const std::string base_data_path_
const size_t render_mem_bytes_
std::map< TSessionId, std::shared_ptr< Catalog_Namespace::SessionInfo >> SessionMap
DeferredCopyFromSessions deferred_copy_from_sessions
import_export::CopyParams copy_params
std::unordered_map< std::string, Catalog_Namespace::SessionInfoPtr > calcite_sessions_
This file contains the class specification and related data structures for Catalog.
static size_t max_bytes_for_thrift()
query_state::QueryStates query_states_
Supported runtime functions management and retrieval.
const size_t reserved_gpu_mem_
std::optional< DeferredCopyFromState > operator()(const std::string &session_id)
Classes representing a parse tree.
const bool render_compositor_use_last_gpu_
void check_not_info_schema_db(const std::string &db_name, bool throw_db_exception)
const int max_session_duration_
ExecutorDeviceType executor_device_type_
std::vector< LeafHostInfo > db_leaves_
const File_Namespace::DiskCacheConfig & disk_cache_config_
const std::string & clang_path_
std::unique_ptr< RenderHandler > render_handler_
Checked json field retrieval.
std::shared_ptr< QueryEngine > query_engine_
SystemParameters & system_parameters_
const size_t num_reader_threads_
specifies the content in-memory of a row in the column metadata table
const bool enable_auto_clear_render_mem_
const bool renderer_prefer_igpu_
heavyai::shared_mutex calcite_sessions_mtx_
std::map< std::string, std::string > get_device_parameters(bool cpu_only)
bool is_info_schema_db(const std::string &db_name)
const bool allow_loop_joins_
heavyai::shared_mutex sessions_mutex_
std::unique_ptr< HeavyDBAggHandler > agg_handler_
heavyai::shared_mutex custom_expressions_mutex_
const bool enable_rendering_
std::unordered_map< std::string, DeferredCopyFromState > was_deferred_copy_from
const bool intel_jit_profile_
const bool renderer_enable_slab_allocation_
std::unique_ptr< Catalog_Namespace::SessionsStore > sessions_store_
std::shared_ptr< Calcite > calcite_
std::shared_ptr< Data_Namespace::DataMgr > data_mgr_
bool process(std::shared_ptr<::apache::thrift::protocol::TProtocol > in, std::shared_ptr<::apache::thrift::protocol::TProtocol > out, void *connectionContext) override
const bool legacy_syntax_
std::unique_ptr< HeavyDBLeafHandler > leaf_handler_
const int idle_session_duration_
std::unordered_map< std::string, std::string > ipc_handle_to_dev_ptr_
const size_t max_concurrent_render_sessions_
boost::variant< ScalarTargetValue, ArrayTargetValue, GeoTargetValue, GeoTargetValuePtr > TargetValue
std::shared_timed_mutex shared_mutex
const AuthMetadata & authMetadata_
TrackingProcessor(std::shared_ptr< HeavyIf > handler, const bool check_origin)
std::default_random_engine random_gen_
std::uniform_int_distribution< int64_t > session_id_dist_
std::shared_ptr< SessionInfo > SessionInfoPtr