17 #ifndef QUERY_RUNNER_H
18 #define QUERY_RUNNER_H
43 namespace Catalog_Namespace {
58 namespace import_export {
64 namespace QueryRunner {
126 std::cout << std::endl
128 <<
"------------ Buffer Pool Stats ------------" << std::endl;
129 std::cout <<
"Num buffers: " <<
num_buffers << std::endl;
130 std::cout <<
"Num bytes: " <<
num_bytes << std::endl;
131 std::cout <<
"Num tables: " <<
num_tables << std::endl;
132 std::cout <<
"Num columns: " <<
num_columns << std::endl;
133 std::cout <<
"Num fragments: " <<
num_fragments << std::endl;
134 std::cout <<
"Num chunks: " <<
num_chunks << std::endl;
135 std::cout <<
"--------------------------------------------" << std::endl << std::endl;
142 const std::string& udf_filename =
"",
143 const size_t max_gpu_mem = 0,
144 const int reserved_gpu_mem = 256 << 20);
148 const std::vector<LeafHostInfo>& string_servers = {},
149 const std::vector<LeafHostInfo>& leaf_servers = {});
152 const std::vector<LeafHostInfo>& string_servers,
153 const std::vector<LeafHostInfo>& leaf_servers) {
163 const std::string& user,
164 const std::string& pass,
165 const std::string& db_name,
166 const std::vector<LeafHostInfo>& string_servers,
167 const std::vector<LeafHostInfo>& leaf_servers,
168 const std::string& udf_filename =
"",
169 bool uses_gpus =
true,
170 const size_t max_gpu_mem = 0,
171 const int reserved_gpu_mem = 256 << 20,
173 const bool create_db =
false,
183 throw std::runtime_error(
"QueryRunner must be initialized before calling get().");
190 std::shared_ptr<Catalog_Namespace::SessionInfo>
getSession()
const {
197 session_info_ = std::make_unique<Catalog_Namespace::SessionInfo>(
198 session_info_->get_catalog_ptr(), user_info, device_type, session_id);
203 std::shared_ptr<Catalog_Namespace::Catalog>
getCatalog()
const;
214 const bool current_db_only)
const;
216 virtual std::unique_ptr<Parser::Stmt>
createStatement(
const std::string&);
220 virtual std::shared_ptr<ResultSet>
runSQL(
const std::string& query_str,
223 virtual std::shared_ptr<ExecutionResult>
runSelectQuery(
const std::string& query_str,
227 bool just_explain =
false);
236 virtual std::shared_ptr<ResultSet>
runSQL(
const std::string& query_str,
238 const bool hoist_literals =
true,
239 const bool allow_loop_joins =
true);
241 const std::string& query_str,
243 const bool hoist_literals,
244 const bool allow_loop_joins,
245 const bool just_explain =
false);
247 const std::string& query_str,
248 const std::string& session_id,
250 const double running_query_check_freq = 0.9,
251 const unsigned pending_query_check_freq = 1000);
257 virtual std::unique_ptr<import_export::Loader>
getLoader(
262 std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint>>>
265 const std::string& query_str);
267 const std::string& query_str);
269 virtual std::shared_ptr<ResultSet>
getCalcitePlan(
const std::string& query_str,
270 bool enable_watchdog,
271 bool is_explain_as_json_str,
272 bool is_explain_detailed)
const;
275 std::shared_ptr<HashTable>,
276 std::optional<HashtableCacheMetaInfo>>
285 bool with_bbox_intersect_tuning_param =
false)
const;
295 std::unique_ptr<RelAlgDag>
getRelAlgDag(
const std::string&);
297 QueryRunner(std::unique_ptr<Catalog_Namespace::SessionInfo> session);
303 template <
typename... Ts>
314 const std::string& user,
315 const std::string& pass,
316 const std::string& db_name,
317 const std::vector<LeafHostInfo>& string_servers,
318 const std::vector<LeafHostInfo>& leaf_servers,
319 const std::string& udf_filename,
321 const size_t max_gpu_mem,
322 const int reserved_gpu_mem,
324 const bool create_db,
341 const std::string session_id =
"");
344 const std::string& table_name,
345 const bool compression,
347 const bool explode_collections);
352 #endif // QUERY_RUNNER_H
void setExplainType(const ExecutorExplainType explain_type)
static query_state::QueryStates query_states_
bool orig_chunk_metadata_cache_
std::shared_ptr< Catalog_Namespace::SessionInfo > getSession() const
bool g_use_query_resultset_cache
void addSessionId(const std::string &session_id, ExecutorDeviceType device_type=ExecutorDeviceType::GPU)
std::optional< RegisteredQueryHint > getParsedGlobalQueryHints(const std::string &query_str)
std::unique_ptr< QueryDispatchQueue > dispatch_queue_
~DataRecyclerFlagsDisabler()
virtual void clearGpuMemory() const
bool orig_allow_query_step_skipping_
ImportDriver(std::shared_ptr< Catalog_Namespace::Catalog > cat, const Catalog_Namespace::UserMetadata &user, const ExecutorDeviceType dt=ExecutorDeviceType::GPU, const std::string session_id="")
bool g_allow_query_step_skipping
ExecutorExplainType explain_type_
virtual std::unique_ptr< Parser::Stmt > createStatement(const std::string &)
virtual std::vector< std::shared_ptr< ResultSet > > runMultipleStatements(const std::string &, const ExecutorDeviceType)
CircleBuffer::value_type create(ARGS &&...args)
static QueryRunner * init(const char *db_path, const std::vector< LeafHostInfo > &string_servers, const std::vector< LeafHostInfo > &leaf_servers)
bool orig_allow_auto_resultset_caching_
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)
bool g_use_chunk_metadata_cache
std::shared_ptr< CacheItemMetric > getCacheItemMetric(QueryPlanHash cache_key, CacheItemType hash_table_type, DeviceIdentifier device_identifier)
BufferPoolStats getBufferPoolStats(const Data_Namespace::MemoryLevel memory_level, const bool current_db_only) const
std::shared_ptr< QueryEngine > query_engine_
This file contains the class specification and related data structures for SysCatalog.
std::shared_ptr< const RelAlgNode > getRootNodeFromParsedQuery(const std::string &query_str)
const std::string kDefaultDbName
void init(LogOptions const &log_opts)
A container for relational algebra descriptors defining the execution order for a relational algebra ...
virtual std::unique_ptr< import_export::Loader > getLoader(const TableDescriptor *td) const
QueryRunner(std::unique_ptr< Catalog_Namespace::SessionInfo > session)
DataRecyclerFlagsDisabler()
virtual void runImport(Parser::CopyTableStmt *import_stmt)
virtual void runDDLStatement(const std::string &)
static std::unique_ptr< QueryRunner > qr_instance_
bool g_allow_auto_resultset_caching
std::unique_ptr< RelAlgDag > getRelAlgDag(const std::string &)
ExtractedQueryPlanDag extractQueryPlanDag(const std::string &)
RegisteredQueryHint getParsedQueryHint(const std::string &)
virtual void validateDDLStatement(const std::string &)
void importGeoTable(const std::string &file_path, const std::string &table_name, const bool compression, const bool create_table, const bool explode_collections)
std::shared_ptr< const RelAlgNode > root_node
std::shared_ptr< RelAlgTranslator > getRelAlgTranslator(const std::string &, Executor *)
const std::string kRootUsername
std::vector< unsigned > left_deep_trees_id
std::shared_ptr< Executor > getExecutor() const
virtual void clearCpuMemory() const
virtual std::shared_ptr< ResultSet > getCalcitePlan(const std::string &query_str, bool enable_watchdog, bool is_explain_as_json_str, bool is_explain_detailed) const
std::shared_ptr< Catalog_Namespace::SessionInfo > session_info_
virtual std::shared_ptr< ExecutionResult > runSelectQuery(const std::string &query_str, CompilationOptions co, ExecutionOptions eo)
static QueryRunner * init(const char *db_path, const std::string &udf_filename="", const size_t max_gpu_mem=0, const int reserved_gpu_mem=256<< 20)
static std::shared_ptr< query_state::QueryState > create_query_state(Ts &&...args)
std::shared_ptr< Calcite > getCalcite() const
size_t getNumberOfCachedItem(CacheItemStatus item_status, CacheItemType hash_table_type, bool with_bbox_intersect_tuning_param=false) const
QueryPlanDagInfo getQueryInfoForDataRecyclerTest(const std::string &)
void resizeDispatchQueue(const size_t num_executors)
virtual std::shared_ptr< ResultSet > runSQLWithAllowingInterrupt(const std::string &query_str, const std::string &session_id, const ExecutorDeviceType device_type, const double running_query_check_freq=0.9, const unsigned pending_query_check_freq=1000)
static QueryRunner * init(std::unique_ptr< Catalog_Namespace::SessionInfo > &session)
std::shared_ptr< RelAlgTranslator > rel_alg_translator
bool orig_resultset_cache_
std::shared_ptr< Catalog_Namespace::Catalog > getCatalog() const
std::tuple< QueryPlanHash, std::shared_ptr< HashTable >, std::optional< HashtableCacheMetaInfo > > getCachedHashtableWithoutCacheKey(std::set< size_t > &visited, CacheItemType hash_table_type, DeviceIdentifier device_identifier)
std::optional< std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > > getParsedQueryHints(const std::string &query_str)
RaExecutionSequence getRaExecutionSequence(const std::string &query_str)
Execution unit for relational algebra. It's a low-level description of any relational algebra operati...
std::vector< MemoryInfo > getMemoryInfo(const Data_Namespace::MemoryLevel memory_level) const
ResultSet(const std::vector< TargetInfo > &targets, const ExecutorDeviceType device_type, const QueryMemoryDescriptor &query_mem_desc, const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const unsigned block_size, const unsigned grid_size)
virtual ~QueryRunner()=default
std::unordered_map< unsigned, JoinQualsPerNestingLevel > left_deep_trees_info
Catalog_Namespace::UserMetadata & getUserMetadata() const