17 #ifndef QUERYENGINE_RELALGEXECUTOR_H
18 #define QUERYENGINE_RELALGEXECUTOR_H
49 namespace Fragmenter_Namespace {
50 class InsertDataLoader;
58 std::shared_ptr<const query_state::QueryState> query_state =
nullptr)
68 const std::string& query_ra,
69 std::shared_ptr<const query_state::QueryState> query_state =
nullptr)
80 std::unique_ptr<RelAlgDag> query_dag,
81 std::shared_ptr<const query_state::QueryState> query_state =
nullptr)
95 const bool just_explain_plan,
96 const bool explain_verbose,
103 const int64_t queue_time_ms);
114 const int64_t queue_time_ms,
115 const bool with_existing_temp_tables =
false);
118 const std::pair<size_t, size_t> interval,
122 const int64_t queue_time_ms);
125 const size_t step_idx,
159 std::pair<std::vector<unsigned>, std::unordered_map<unsigned, JoinQualsPerNestingLevel>>
164 const std::vector<std::shared_ptr<RexSubQuery>>&
getSubqueries() const noexcept {
174 std::unordered_map<size_t, std::unordered_map<unsigned, RegisteredQueryHint>>>
201 Executor* executor) {
218 const bool just_explain_plan,
219 const bool explain_verbose,
223 const size_t step_idx,
227 const int64_t queue_time_ms);
232 const int64_t queue_time_ms);
237 const int64_t queue_time_ms);
243 const int64_t queue_time_ms);
249 const int64_t queue_time_ms);
255 const int64_t queue_time_ms,
256 const std::optional<size_t> previous_count);
261 const int64_t queue_time_ms);
267 const int64_t queue_time_ms);
273 const int64_t queue_time_ms);
284 const int64_t queue_time_ms);
303 std::list<Analyzer::OrderEntry>& order_entries,
308 const std::vector<TargetMetaInfo>& targets_meta,
313 const int64_t queue_time_ms,
314 const std::optional<size_t> previous_count = std::nullopt);
321 const int64_t queue_time_ms);
326 const std::shared_ptr<Analyzer::BinOper>& partition_key_cond,
327 std::unordered_map<
QueryPlanHash, std::shared_ptr<HashJoin>>& partition_cache,
328 std::unordered_map<QueryPlanHash, size_t>& sorted_partition_key_ref_count_map,
330 const std::vector<InputTableInfo>& query_infos,
333 std::shared_ptr<RowSetMemoryOwner> row_set_mem_owner);
349 const std::vector<std::shared_ptr<Analyzer::Expr>>& filter_expressions,
362 const std::vector<TargetMetaInfo>& targets_meta,
368 const int64_t queue_time_ms);
382 const bool just_explain);
390 const bool just_explain);
399 const bool just_explain,
403 CHECK_LT(
size_t(0), result->colCount());
419 const std::vector<InputDescriptor>& input_descs,
420 const std::unordered_map<const RelAlgNode*, int>& input_to_nest_level,
421 const bool just_explain);
427 const std::vector<JoinType>& join_types,
428 const std::unordered_map<const RelAlgNode*, int>& input_to_nest_level,
429 const bool just_explain)
const;
457 #endif // QUERYENGINE_RELALGEXECUTOR_H
bool is_agg(const Analyzer::Expr *expr)
std::optional< std::function< void()> > post_execution_callback_
ExecutionResult executeAggregate(const RelAggregate *aggregate, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
RelAlgExecutor(Executor *executor, std::unique_ptr< RelAlgDag > query_dag, std::shared_ptr< const query_state::QueryState > query_state=nullptr)
const std::vector< size_t > left_deep_join_input_sizes
ExecutionResult handleOutOfMemoryRetry(const RelAlgExecutor::WorkUnit &work_unit, ColumnCacheMap &column_cache, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const QueryExecutionError &e, const int64_t queue_time_ms)
void addLeafResult(const unsigned id, const AggregatedResult &result)
AggregatedColRange computeColRangesCache()
RelAlgExecutor(Executor *executor, const std::string &query_ra, std::shared_ptr< const query_state::QueryState > query_state=nullptr)
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const ExecutionOptions &eo)
ExecutionResult executeRelAlgSeq(const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
TableFunctionWorkUnit createTableFunctionWorkUnit(const RelTableFunction *table_func, const bool just_explain, const bool is_gpu)
WorkUnit createAggregateWorkUnit(const RelAggregate *, const SortInfo &, const bool just_explain)
bool g_skip_intermediate_count
Streaming Top N algorithm.
TableGenerations computeTableGenerations()
static SpeculativeTopNBlacklist speculative_topn_blacklist_
RelAlgExecutor(Executor *executor, std::shared_ptr< const query_state::QueryState > query_state=nullptr)
RelAlgExecutionUnit exe_unit
TemporaryTables temporary_tables_
ExecutionResult executeRelAlgQueryWithFilterPushDown(const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
void setupCaching(const RelAlgNode *ra)
FilterSelectivity getFilterSelectivity(const std::vector< std::shared_ptr< Analyzer::Expr >> &filter_expressions, const CompilationOptions &co, const ExecutionOptions &eo)
std::unordered_map< unsigned, JoinQualsPerNestingLevel > & getLeftDeepJoinTreesInfo()
std::vector< PushedDownFilterInfo > selectFiltersToBePushedDown(const RelAlgExecutor::WorkUnit &work_unit, const CompilationOptions &co, const ExecutionOptions &eo)
std::optional< std::unordered_map< size_t, std::unordered_map< unsigned, RegisteredQueryHint > > > getParsedQueryHints()
ExecutionResult executeModify(const RelModify *modify, const ExecutionOptions &eo)
void addTemporaryTable(const int table_id, const ResultSetPtr &result)
std::unique_ptr< QueryRewriter > query_rewriter
std::unordered_map< unsigned, AggregatedResult > leaf_results_
std::vector< TargetInfo > TargetInfoList
std::vector< JoinCondition > JoinQualsPerNestingLevel
std::shared_ptr< ResultSet > ResultSetPtr
ExecutionResult executeLogicalValues(const RelLogicalValues *, const ExecutionOptions &)
std::optional< RegisteredQueryHint > getParsedQueryHint(const RelAlgNode *node)
ExecutionResult executeFilter(const RelFilter *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
const std::vector< std::shared_ptr< RexSubQuery > > & getSubqueries() const noexcept
QueryStepExecutionResult executeRelAlgQuerySingleStep(const RaExecutionSequence &seq, const size_t step_idx, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
bool hasStepForUnion() const
void handleNop(RaExecutionDesc &ed)
void computeWindow(const WorkUnit &work_unit, const CompilationOptions &co, const ExecutionOptions &eo, ColumnCacheMap &column_cache_map, const int64_t queue_time_ms)
std::shared_ptr< const RelAlgNode > getRootRelAlgNodeShPtr() const
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const ExecutionOptions &eo)
WorkUnit createWorkUnit(const RelAlgNode *, const SortInfo &, const ExecutionOptions &eo)
RaExecutionSequence getRaExecutionSequence(const RelAlgNode *root_node, Executor *executor)
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
std::unordered_set< shared::TableKey > getPhysicalTableIds() const
std::unique_ptr< WindowFunctionContext > createWindowFunctionContext(const Analyzer::WindowFunction *window_func, const std::shared_ptr< Analyzer::BinOper > &partition_key_cond, std::unordered_map< QueryPlanHash, std::shared_ptr< HashJoin >> &partition_cache, std::unordered_map< QueryPlanHash, size_t > &sorted_partition_key_ref_count_map, const WorkUnit &work_unit, const std::vector< InputTableInfo > &query_infos, const CompilationOptions &co, ColumnCacheMap &column_cache_map, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
size_t getOuterFragmentCount(const CompilationOptions &co, const ExecutionOptions &eo)
void executeUpdate(const RelAlgNode *node, const CompilationOptions &co, const ExecutionOptions &eo, const int64_t queue_time_ms)
A container for relational algebra descriptors defining the execution order for a relational algebra ...
friend class PendingExecutionClosure
std::optional< size_t > getFilteredCountAll(const RelAlgExecutionUnit &ra_exe_unit, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo)
void executePostExecutionCallback()
size_t getNDVEstimation(const WorkUnit &work_unit, const int64_t range, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo)
ExecutionResult executeRelAlgSubSeq(const RaExecutionSequence &seq, const std::pair< size_t, size_t > interval, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
const std::vector< size_t > input_permutation
WorkUnit createUnionWorkUnit(const RelLogicalUnion *, const SortInfo &, const ExecutionOptions &eo)
bool g_enable_smem_group_by true
void executeRelAlgStep(const RaExecutionSequence &seq, const size_t step_idx, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
ExecutionResult executeSimpleInsert(const Analyzer::Query &insert_query, Fragmenter_Namespace::InsertDataLoader &inserter, const Catalog_Namespace::SessionInfo &session)
Executor * getExecutor() const
std::optional< RegisteredQueryHint > getGlobalQueryHint()
ExecutionResult executeTableFunction(const RelTableFunction *, const CompilationOptions &, const ExecutionOptions &, const int64_t queue_time_ms)
std::unique_ptr< RelAlgDag > query_dag_
std::unordered_map< unsigned, JoinQualsPerNestingLevel > left_deep_join_info_
ExecutionResult executeWorkUnit(const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo_in, RenderInfo *, const int64_t queue_time_ms, const std::optional< size_t > previous_count=std::nullopt)
WorkUnit createJoinWorkUnit(const RelJoin *, const SortInfo &, const bool just_explain)
ExecutionResult executeUnion(const RelLogicalUnion *, const RaExecutionSequence &, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
std::shared_ptr< const query_state::QueryState > query_state_
Speculative top N algorithm.
const MergeType merge_type
std::unordered_map< shared::TableKey, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
const RelAlgNode & getRootRelAlgNode() const
void eraseFromTemporaryTables(const int table_id)
bool canUseResultsetCache(const ExecutionOptions &eo, RenderInfo *render_info) const
ExecutionResult executeSort(const RelSort *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
bool isRowidLookup(const WorkUnit &work_unit)
ExecutionResult executeProject(const RelProject *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms, const std::optional< size_t > previous_count)
TableFunctionExecutionUnit exe_unit
bool hasDeletedRowInQuery(std::vector< InputTableInfo > const &) const
static void handlePersistentError(const int32_t error_code)
const size_t max_groups_buffer_entry_guess
void prepareForeignTables()
StringDictionaryGenerations computeStringDictionaryGenerations()
ExecutionResult executeRelAlgQueryNoRetry(const CompilationOptions &co, const ExecutionOptions &eo, const bool just_explain_plan, const bool explain_verbose, RenderInfo *render_info)
ExecutionResult executeCompound(const RelCompound *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
static std::string getErrorMessageFromCode(const int32_t error_code)
void cleanupPostExecution()
void initializeParallelismHints()
std::list< std::shared_ptr< Analyzer::Expr > > makeJoinQuals(const RexScalar *join_condition, const std::vector< JoinType > &join_types, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const bool just_explain) const
ExecutionResult executeRelAlgQuery(const CompilationOptions &co, const ExecutionOptions &eo, const bool just_explain_plan, const bool explain_verbose, RenderInfo *render_info)
std::unique_ptr< RelAlgDag > getOwnedRelAlgDag()
std::unique_ptr< TransactionParameters > dml_transaction_parameters_
std::pair< std::vector< unsigned >, std::unordered_map< unsigned, JoinQualsPerNestingLevel > > getJoinInfo(const RelAlgNode *root_node)
void executeDelete(const RelAlgNode *node, const CompilationOptions &co, const ExecutionOptions &eo_in, const int64_t queue_time_ms)
std::shared_ptr< RelAlgTranslator > getRelAlgTranslator(const RelAlgNode *root_node)
RelAlgDag * getRelAlgDag()
void prepareForSystemTableExecution(const CompilationOptions &co) const
void prepareForeignTable()
WorkUnit createFilterWorkUnit(const RelFilter *, const SortInfo &, const bool just_explain)
JoinQualsPerNestingLevel translateLeftDeepJoinFilter(const RelLeftDeepInnerJoin *join, const std::vector< InputDescriptor > &input_descs, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const bool just_explain)
void setHasStepForUnion(bool flag)
void prepareLeafExecution(const AggregatedColRange &agg_col_range, const StringDictionaryGenerations &string_dictionary_generations, const TableGenerations &table_generations)
WorkUnit createSortInputWorkUnit(const RelSort *, std::list< Analyzer::OrderEntry > &order_entries, const ExecutionOptions &eo)