OmniSciDB  04ee39c94c
RelAlgExecutor Class Reference

#include <RelAlgExecutor.h>

+ Inheritance diagram for RelAlgExecutor:
+ Collaboration diagram for RelAlgExecutor:

Classes

struct  WorkUnit
 

Public Types

using TargetInfoList = std::vector< TargetInfo >
 

Public Member Functions

 RelAlgExecutor (Executor *executor, const Catalog_Namespace::Catalog &cat)
 
ExecutionResult executeRelAlgQuery (const std::string &query_ra, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
 
ExecutionResult executeRelAlgQueryWithFilterPushDown (std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
 
FirstStepExecutionResult executeRelAlgQuerySingleStep (const RaExecutionDesc &exec_desc, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
 
void prepareLeafExecution (const AggregatedColRange &agg_col_range, const StringDictionaryGenerations &string_dictionary_generations, const TableGenerations &table_generations)
 
ExecutionResult executeRelAlgSubQuery (const RexSubQuery *subquery, const CompilationOptions &co, const ExecutionOptions &eo)
 
ExecutionResult executeRelAlgSeq (std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
 
ExecutionResult executeRelAlgSubSeq (std::vector< RaExecutionDesc >::iterator start_desc, std::vector< RaExecutionDesc >::iterator end_desc, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
 
void addLeafResult (const unsigned id, const AggregatedResult &result)
 
void registerSubquery (std::shared_ptr< RexSubQuery > subquery) noexcept
 
const std::vector< std::shared_ptr< RexSubQuery > > & getSubqueries () const noexcept
 
AggregatedColRange computeColRangesCache (const RelAlgNode *ra)
 
StringDictionaryGenerations computeStringDictionaryGenerations (const RelAlgNode *ra)
 
TableGenerations computeTableGenerations (const RelAlgNode *ra)
 
ExecutorgetExecutor () const
 
void cleanupPostExecution ()
 

Static Public Member Functions

static std::string getErrorMessageFromCode (const int32_t error_code)
 

Private Member Functions

ExecutionResult executeRelAlgQueryNoRetry (const std::string &query_ra, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
 
void executeRelAlgStep (const size_t step_idx, std::vector< RaExecutionDesc >::iterator exec_desc_itr, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
void executeUpdateViaCompound (const RelCompound *compound, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
 
void executeUpdateViaProject (const RelProject *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
void executeDeleteViaCompound (const RelCompound *compound, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
 
void executeDeleteViaProject (const RelProject *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
ExecutionResult executeCompound (const RelCompound *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
ExecutionResult executeAggregate (const RelAggregate *aggregate, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
 
ExecutionResult executeProject (const RelProject *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count)
 
void computeWindow (const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co, const ExecutionOptions &eo, ColumnCacheMap &column_cache_map, const int64_t queue_time_ms)
 
std::unique_ptr< WindowFunctionContextcreateWindowFunctionContext (const Analyzer::WindowFunction *window_func, const std::shared_ptr< Analyzer::BinOper > &partition_key_cond, const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const CompilationOptions &co, ColumnCacheMap &column_cache_map)
 
ExecutionResult executeFilter (const RelFilter *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
ExecutionResult executeSort (const RelSort *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
ExecutionResult executeLogicalValues (const RelLogicalValues *, const ExecutionOptions &)
 
ExecutionResult executeModify (const RelModify *modify, const ExecutionOptions &eo)
 
WorkUnit createSortInputWorkUnit (const RelSort *, const bool just_explain)
 
ExecutionResult executeWorkUnit (const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count=-1)
 
size_t getNDVEstimation (const WorkUnit &work_unit, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo)
 
ssize_t getFilteredCountAll (const WorkUnit &work_unit, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo)
 
FilterSelectivity getFilterSelectivity (const std::vector< std::shared_ptr< Analyzer::Expr >> &filter_expressions, const CompilationOptions &co, const ExecutionOptions &eo)
 
std::vector< PushedDownFilterInfoselectFiltersToBePushedDown (const RelAlgExecutor::WorkUnit &work_unit, const CompilationOptions &co, const ExecutionOptions &eo)
 
bool isRowidLookup (const WorkUnit &work_unit)
 
ExecutionResult handleOutOfMemoryRetry (const RelAlgExecutor::WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const bool was_multifrag_kernel_launch, const int64_t queue_time_ms)
 
WorkUnit createWorkUnit (const RelAlgNode *, const SortInfo &, const bool just_explain)
 
WorkUnit createModifyCompoundWorkUnit (const RelCompound *compound, const SortInfo &sort_info, const bool just_explain)
 
WorkUnit createCompoundWorkUnit (const RelCompound *, const SortInfo &, const bool just_explain)
 
WorkUnit createAggregateWorkUnit (const RelAggregate *, const SortInfo &, const bool just_explain)
 
WorkUnit createModifyProjectWorkUnit (const RelProject *project, const SortInfo &sort_info, const bool just_explain)
 
WorkUnit createProjectWorkUnit (const RelProject *, const SortInfo &, const bool just_explain)
 
WorkUnit createFilterWorkUnit (const RelFilter *, const SortInfo &, const bool just_explain)
 
WorkUnit createJoinWorkUnit (const RelJoin *, const SortInfo &, const bool just_explain)
 
void addTemporaryTable (const int table_id, const ResultSetPtr &result)
 
void eraseFromTemporaryTables (const int table_id)
 
void handleNop (RaExecutionDesc &ed)
 
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)
 
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
 
- Private Member Functions inherited from StorageIOFacility< RelAlgExecutorTraits >
 StorageIOFacility (ExecutorType *executor, CatalogType const &catalog)
 
ColumnValidationFunction yieldColumnValidator (TableDescriptorType const *table_descriptor)
 
UpdateCallback yieldUpdateCallback (UpdateTransactionParameters &update_parameters)
 
UpdateCallback yieldDeleteCallback (DeleteTransactionParameters &delete_parameters)
 

Static Private Member Functions

static void handlePersistentError (const int32_t error_code)
 

Private Attributes

Executorexecutor_
 
const Catalog_Namespace::Catalogcat_
 
TemporaryTables temporary_tables_
 
time_t now_
 
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
 
std::vector< std::shared_ptr< RexSubQuery > > subqueries_
 
std::unordered_map< unsigned, AggregatedResultleaf_results_
 
int64_t queue_time_ms_
 

Static Private Attributes

static SpeculativeTopNBlacklist speculative_topn_blacklist_
 
static const size_t max_groups_buffer_entry_default_guess {16384}
 

Friends

class PendingExecutionClosure
 

Additional Inherited Members

- Private Types inherited from StorageIOFacility< RelAlgExecutorTraits >
using ExecutorType = typename RelAlgExecutorTraits ::ExecutorType
 
using CatalogType = typename RelAlgExecutorTraits ::CatalogType
 
using FragmentUpdaterType = UpdateLogForFragment
 
using UpdateCallback = typename FragmentUpdaterType::Callback
 
using IOFacility = DefaultIOFacet<>
 
using TableDescriptorType = typename RelAlgExecutorTraits ::TableDescriptorType
 
using DeleteVictimOffsetList = typename IOFacility::DeleteVictimOffsetList
 
using UpdateTargetOffsetList = typename IOFacility::UpdateTargetOffsetList
 
using UpdateTargetTypeList = typename IOFacility::UpdateTargetTypeList
 
using UpdateTargetColumnNamesList = typename IOFacility::UpdateTargetColumnNamesList
 
using UpdateTargetColumnNameType = typename UpdateTargetColumnNamesList::value_type
 
using ColumnValidationFunction = typename IOFacility::ColumnValidationFunction
 
using StringSelector = Experimental::MetaTypeClass< Experimental::String >
 
using NonStringSelector = Experimental::UncapturedMetaTypeClass
 

Detailed Description

Definition at line 52 of file RelAlgExecutor.h.

Member Typedef Documentation

◆ TargetInfoList

Definition at line 54 of file RelAlgExecutor.h.

Constructor & Destructor Documentation

◆ RelAlgExecutor()

RelAlgExecutor::RelAlgExecutor ( Executor executor,
const Catalog_Namespace::Catalog cat 
)
inline

Definition at line 56 of file RelAlgExecutor.h.

57  : StorageIOFacility(executor, cat)
58  , executor_(executor)
59  , cat_(cat)
60  , now_(0)
61  , queue_time_ms_(0) {}
int64_t queue_time_ms_
const Catalog_Namespace::Catalog & cat_
StorageIOFacility(ExecutorType *executor, CatalogType const &catalog)
Executor * executor_

Member Function Documentation

◆ addLeafResult()

void RelAlgExecutor::addLeafResult ( const unsigned  id,
const AggregatedResult result 
)
inline

Definition at line 103 of file RelAlgExecutor.h.

References CHECK.

103  {
104  const auto it_ok = leaf_results_.emplace(id, result);
105  CHECK(it_ok.second);
106  }
std::unordered_map< unsigned, AggregatedResult > leaf_results_
#define CHECK(condition)
Definition: Logger.h:187

◆ addTemporaryTable()

void RelAlgExecutor::addTemporaryTable ( const int  table_id,
const ResultSetPtr result 
)
inlineprivate

Definition at line 297 of file RelAlgExecutor.h.

References CHECK, and CHECK_LT.

297  {
298  CHECK_LT(size_t(0), result->colCount());
299  CHECK_LT(table_id, 0);
300  const auto it_ok = temporary_tables_.emplace(table_id, result);
301  CHECK(it_ok.second);
302  }
TemporaryTables temporary_tables_
#define CHECK_LT(x, y)
Definition: Logger.h:197
#define CHECK(condition)
Definition: Logger.h:187

◆ cleanupPostExecution()

void RelAlgExecutor::cleanupPostExecution ( )

Definition at line 231 of file RelAlgExecutor.cpp.

References CHECK, and ResultSet::executor_.

231  {
232  CHECK(executor_);
233  executor_->row_set_mem_owner_ = nullptr;
234  executor_->lit_str_dict_proxy_ = nullptr;
235 }
#define CHECK(condition)
Definition: Logger.h:187
Executor * executor_

◆ computeColRangesCache()

AggregatedColRange RelAlgExecutor::computeColRangesCache ( const RelAlgNode ra)

Definition at line 170 of file RelAlgExecutor.cpp.

References CHECK, ResultSet::executor_, anonymous_namespace{RelAlgExecutor.cpp}::get_physical_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::get_physical_table_ids(), getLeafColumnRange(), kENCODING_DICT, and AggregatedColRange::setColRange().

170  {
171  AggregatedColRange agg_col_range_cache;
172  const auto phys_inputs = get_physical_inputs(cat_, ra);
173  const auto phys_table_ids = get_physical_table_ids(phys_inputs);
174  std::vector<InputTableInfo> query_infos;
175  executor_->catalog_ = &cat_;
176  for (const int table_id : phys_table_ids) {
177  query_infos.emplace_back(InputTableInfo{table_id, executor_->getTableInfo(table_id)});
178  }
179  for (const auto& phys_input : phys_inputs) {
180  const auto cd = cat_.getMetadataForColumn(phys_input.table_id, phys_input.col_id);
181  CHECK(cd);
182  const auto& col_ti =
183  cd->columnType.is_array() ? cd->columnType.get_elem_type() : cd->columnType;
184  if (col_ti.is_number() || col_ti.is_boolean() || col_ti.is_time() ||
185  (col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT)) {
186  const auto col_var = boost::make_unique<Analyzer::ColumnVar>(
187  cd->columnType, phys_input.table_id, phys_input.col_id, 0);
188  const auto col_range =
189  getLeafColumnRange(col_var.get(), query_infos, executor_, false);
190  agg_col_range_cache.setColRange(phys_input, col_range);
191  }
192  }
193  return agg_col_range_cache;
194 }
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
const Catalog_Namespace::Catalog & cat_
ExpressionRange getLeafColumnRange(const Analyzer::ColumnVar *col_expr, const std::vector< InputTableInfo > &query_infos, const Executor *executor, const bool is_outer_join_proj)
std::unordered_set< PhysicalInput > get_physical_inputs(const Catalog_Namespace::Catalog &cat, const RelAlgNode *ra)
#define CHECK(condition)
Definition: Logger.h:187
void setColRange(const PhysicalInput &, const ExpressionRange &)
std::unordered_set< int > get_physical_table_ids(const std::unordered_set< PhysicalInput > &phys_inputs)
Executor * executor_
+ Here is the call graph for this function:

◆ computeStringDictionaryGenerations()

StringDictionaryGenerations RelAlgExecutor::computeStringDictionaryGenerations ( const RelAlgNode ra)

Definition at line 196 of file RelAlgExecutor.cpp.

References CHECK, anonymous_namespace{RelAlgExecutor.cpp}::get_physical_inputs(), kENCODING_DICT, and StringDictionaryGenerations::setGeneration().

197  {
198  StringDictionaryGenerations string_dictionary_generations;
199  const auto phys_inputs = get_physical_inputs(cat_, ra);
200  for (const auto& phys_input : phys_inputs) {
201  const auto cd = cat_.getMetadataForColumn(phys_input.table_id, phys_input.col_id);
202  CHECK(cd);
203  const auto& col_ti =
204  cd->columnType.is_array() ? cd->columnType.get_elem_type() : cd->columnType;
205  if (col_ti.is_string() && col_ti.get_compression() == kENCODING_DICT) {
206  const int dict_id = col_ti.get_comp_param();
207  const auto dd = cat_.getMetadataForDict(dict_id);
208  CHECK(dd && dd->stringDict);
209  string_dictionary_generations.setGeneration(dict_id,
210  dd->stringDict->storageEntryCount());
211  }
212  }
213  return string_dictionary_generations;
214 }
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
const Catalog_Namespace::Catalog & cat_
void setGeneration(const uint32_t id, const size_t generation)
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1348
std::unordered_set< PhysicalInput > get_physical_inputs(const Catalog_Namespace::Catalog &cat, const RelAlgNode *ra)
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

◆ computeTableGenerations()

TableGenerations RelAlgExecutor::computeTableGenerations ( const RelAlgNode ra)

Definition at line 216 of file RelAlgExecutor.cpp.

References ResultSet::executor_, get_physical_table_inputs(), and TableGenerations::setGeneration().

216  {
217  const auto phys_table_ids = get_physical_table_inputs(ra);
218  TableGenerations table_generations;
219  for (const int table_id : phys_table_ids) {
220  const auto table_info = executor_->getTableInfo(table_id);
221  table_generations.setGeneration(
222  table_id, TableGeneration{table_info.getPhysicalNumTuples(), 0});
223  }
224  return table_generations;
225 }
void setGeneration(const uint32_t id, const TableGeneration &generation)
Executor * executor_
std::unordered_set< int > get_physical_table_inputs(const RelAlgNode *ra)
+ Here is the call graph for this function:

◆ computeWindow()

void RelAlgExecutor::computeWindow ( const RelAlgExecutionUnit ra_exe_unit,
const CompilationOptions co,
const ExecutionOptions eo,
ColumnCacheMap column_cache_map,
const int64_t  queue_time_ms 
)
private

Definition at line 1397 of file RelAlgExecutor.cpp.

References CHECK_EQ, WindowProjectNodeContext::create(), ResultSet::executor_, get_table_infos(), Analyzer::WindowFunction::getPartitionKeys(), RelAlgExecutionUnit::input_descs, kBOOLEAN, kBW_EQ, kONE, RelAlgExecutionUnit::target_exprs, and anonymous_namespace{RelAlgExecutor.cpp}::transform_to_inner().

1401  {
1402  auto query_infos = get_table_infos(ra_exe_unit.input_descs, executor_);
1403  CHECK_EQ(query_infos.size(), size_t(1));
1404  if (query_infos.front().info.fragments.size() != 1) {
1405  throw std::runtime_error(
1406  "Only single fragment tables supported for window functions for now");
1407  }
1408  query_infos.push_back(query_infos.front());
1409  auto window_project_node_context = WindowProjectNodeContext::create();
1410  for (size_t target_index = 0; target_index < ra_exe_unit.target_exprs.size();
1411  ++target_index) {
1412  const auto& target_expr = ra_exe_unit.target_exprs[target_index];
1413  const auto window_func = dynamic_cast<const Analyzer::WindowFunction*>(target_expr);
1414  if (!window_func) {
1415  continue;
1416  }
1417  // Always use baseline layout hash tables for now, make the expression a tuple.
1418  const auto& partition_keys = window_func->getPartitionKeys();
1419  std::shared_ptr<Analyzer::Expr> partition_key_tuple;
1420  if (partition_keys.size() > 1) {
1421  partition_key_tuple = makeExpr<Analyzer::ExpressionTuple>(partition_keys);
1422  } else {
1423  if (partition_keys.empty()) {
1424  throw std::runtime_error(
1425  "Empty window function partitions are not supported yet");
1426  }
1427  CHECK_EQ(partition_keys.size(), size_t(1));
1428  partition_key_tuple = partition_keys.front();
1429  }
1430  // Creates a tautology equality with the partition expression on both sides.
1431  const auto partition_key_cond =
1432  makeExpr<Analyzer::BinOper>(kBOOLEAN,
1433  kBW_EQ,
1434  kONE,
1435  partition_key_tuple,
1436  transform_to_inner(partition_key_tuple.get()));
1437  auto context = createWindowFunctionContext(
1438  window_func, partition_key_cond, ra_exe_unit, query_infos, co, column_cache_map);
1439  context->compute();
1440  window_project_node_context->addWindowFunctionContext(std::move(context),
1441  target_index);
1442  }
1443 }
std::vector< Analyzer::Expr * > target_exprs
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const std::vector< InputDescriptor > input_descs
std::shared_ptr< Analyzer::Expr > transform_to_inner(const Analyzer::Expr *expr)
static WindowProjectNodeContext * create()
Definition: sqldefs.h:69
const std::vector< std::shared_ptr< Analyzer::Expr > > & getPartitionKeys() const
Definition: Analyzer.h:1343
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
Definition: sqldefs.h:31
std::unique_ptr< WindowFunctionContext > createWindowFunctionContext(const Analyzer::WindowFunction *window_func, const std::shared_ptr< Analyzer::BinOper > &partition_key_cond, const RelAlgExecutionUnit &ra_exe_unit, const std::vector< InputTableInfo > &query_infos, const CompilationOptions &co, ColumnCacheMap &column_cache_map)
Executor * executor_
+ Here is the call graph for this function:

◆ createAggregateWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createAggregateWorkUnit ( const RelAggregate aggregate,
const SortInfo sort_info,
const bool  just_explain 
)
private

Definition at line 2846 of file RelAlgExecutor.cpp.

References CHECK_EQ, ResultSet::executor_, anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_type(), anonymous_namespace{RelAlgExecutor.cpp}::get_targets_meta(), RelAlgNode::getInput(), RelAlgNode::getOutputMetainfo(), RelAlgNode::inputCount(), RelAlgNode::setOutputMetainfo(), anonymous_namespace{RelAlgExecutor.cpp}::synthesize_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs(), and anonymous_namespace{RelAlgExecutor.cpp}::translate_targets().

2849  {
2850  std::vector<InputDescriptor> input_descs;
2851  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
2852  std::vector<std::shared_ptr<RexInput>> used_inputs_owned;
2853  const auto input_to_nest_level = get_input_nest_levels(aggregate, {});
2854  std::tie(input_descs, input_col_descs, used_inputs_owned) =
2855  get_input_desc(aggregate, input_to_nest_level, {}, cat_);
2856  const auto join_type = get_join_type(aggregate);
2857  QueryFeatureDescriptor query_features;
2858  RelAlgTranslator translator(cat_,
2859  executor_,
2860  input_to_nest_level,
2861  {join_type},
2862  now_,
2863  just_explain,
2864  query_features);
2865  CHECK_EQ(size_t(1), aggregate->inputCount());
2866  const auto source = aggregate->getInput(0);
2867  const auto& in_metainfo = source->getOutputMetainfo();
2868  const auto scalar_sources =
2869  synthesize_inputs(aggregate, size_t(0), in_metainfo, input_to_nest_level);
2870  const auto groupby_exprs = translate_groupby_exprs(aggregate, scalar_sources);
2871  const auto target_exprs = translate_targets(
2872  target_exprs_owned_, scalar_sources, groupby_exprs, aggregate, translator);
2873  const auto targets_meta = get_targets_meta(aggregate, target_exprs);
2874  aggregate->setOutputMetainfo(targets_meta);
2875  return {{input_descs,
2876  input_col_descs,
2877  {},
2878  {},
2879  {},
2880  groupby_exprs,
2881  target_exprs,
2882  nullptr,
2883  sort_info,
2884  0,
2885  query_features,
2886  false},
2887  aggregate,
2889  nullptr};
2890 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::list< std::shared_ptr< Analyzer::Expr > > translate_groupby_exprs(const RelAggregate *aggregate, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources)
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
std::vector< std::shared_ptr< Analyzer::Expr > > synthesize_inputs(const RelAlgNode *ra_node, const size_t nest_level, const std::vector< TargetMetaInfo > &in_metainfo, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level)
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr *> &target_exprs)
static const size_t max_groups_buffer_entry_default_guess
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
const Catalog_Namespace::Catalog & cat_
JoinType get_join_type(const RelAlgNode *ra)
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
const size_t inputCount() const
const RelAlgNode * getInput(const size_t idx) const
std::tuple< std::vector< InputDescriptor >, std::list< std::shared_ptr< const InputColDescriptor > >, std::vector< std::shared_ptr< RexInput > > > get_input_desc(const RA *ra_node, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const std::vector< size_t > &input_permutation, const Catalog_Namespace::Catalog &cat)
Executor * executor_
std::vector< Analyzer::Expr * > translate_targets(std::vector< std::shared_ptr< Analyzer::Expr >> &target_exprs_owned, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources, const std::list< std::shared_ptr< Analyzer::Expr >> &groupby_exprs, const RelAggregate *aggregate, const RelAlgTranslator &translator)
+ Here is the call graph for this function:

◆ createCompoundWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createCompoundWorkUnit ( const RelCompound compound,
const SortInfo sort_info,
const bool  just_explain 
)
private

Definition at line 2572 of file RelAlgExecutor.cpp.

References CHECK_EQ, anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering(), ResultSet::executor_, g_from_table_reordering, anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_type(), anonymous_namespace{RelAlgExecutor.cpp}::get_left_deep_join_input_sizes(), get_table_infos(), anonymous_namespace{RelAlgExecutor.cpp}::get_targets_meta(), RelAlgNode::getInput(), RelAlgNode::inputCount(), LEFT, anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), anonymous_namespace{RelAlgExecutor.cpp}::rewrite_quals(), RelAlgNode::setOutputMetainfo(), RelAlgExecutionUnit::simple_quals, RelCompound::size(), anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs(), anonymous_namespace{RelAlgExecutor.cpp}::translate_quals(), anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources(), and anonymous_namespace{RelAlgExecutor.cpp}::translate_targets().

2575  {
2576  std::vector<InputDescriptor> input_descs;
2577  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
2578  auto input_to_nest_level = get_input_nest_levels(compound, {});
2579  std::tie(input_descs, input_col_descs, std::ignore) =
2580  get_input_desc(compound, input_to_nest_level, {}, cat_);
2581  const auto query_infos = get_table_infos(input_descs, executor_);
2582  CHECK_EQ(size_t(1), compound->inputCount());
2583  const auto left_deep_join =
2584  dynamic_cast<const RelLeftDeepInnerJoin*>(compound->getInput(0));
2585  JoinQualsPerNestingLevel left_deep_join_quals;
2586  const auto join_types = left_deep_join ? left_deep_join_types(left_deep_join)
2587  : std::vector<JoinType>{get_join_type(compound)};
2588  std::vector<size_t> input_permutation;
2589  std::vector<size_t> left_deep_join_input_sizes;
2590  if (left_deep_join) {
2591  left_deep_join_input_sizes = get_left_deep_join_input_sizes(left_deep_join);
2592  left_deep_join_quals = translateLeftDeepJoinFilter(
2593  left_deep_join, input_descs, input_to_nest_level, just_explain);
2595  std::find(join_types.begin(), join_types.end(), JoinType::LEFT) ==
2596  join_types.end()) {
2597  input_permutation = do_table_reordering(input_descs,
2598  input_col_descs,
2599  left_deep_join_quals,
2600  input_to_nest_level,
2601  compound,
2602  query_infos,
2603  executor_);
2604  input_to_nest_level = get_input_nest_levels(compound, input_permutation);
2605  std::tie(input_descs, input_col_descs, std::ignore) =
2606  get_input_desc(compound, input_to_nest_level, input_permutation, cat_);
2607  left_deep_join_quals = translateLeftDeepJoinFilter(
2608  left_deep_join, input_descs, input_to_nest_level, just_explain);
2609  }
2610  }
2611  QueryFeatureDescriptor query_features;
2612  RelAlgTranslator translator(cat_,
2613  executor_,
2614  input_to_nest_level,
2615  join_types,
2616  now_,
2617  just_explain,
2618  query_features);
2619  const auto scalar_sources = translate_scalar_sources(compound, translator);
2620  const auto groupby_exprs = translate_groupby_exprs(compound, scalar_sources);
2621  const auto quals_cf = translate_quals(compound, translator);
2622  const auto target_exprs = translate_targets(
2623  target_exprs_owned_, scalar_sources, groupby_exprs, compound, translator);
2624  CHECK_EQ(compound->size(), target_exprs.size());
2625  const RelAlgExecutionUnit exe_unit = {input_descs,
2626  input_col_descs,
2627  quals_cf.simple_quals,
2628  rewrite_quals(quals_cf.quals),
2629  left_deep_join_quals,
2630  groupby_exprs,
2631  target_exprs,
2632  nullptr,
2633  sort_info,
2634  0,
2635  query_features,
2636  false};
2637  auto query_rewriter = std::make_unique<QueryRewriter>(query_infos, executor_);
2638  const auto rewritten_exe_unit = query_rewriter->rewrite(exe_unit);
2639  const auto targets_meta = get_targets_meta(compound, rewritten_exe_unit.target_exprs);
2640  compound->setOutputMetainfo(targets_meta);
2641  return {rewritten_exe_unit,
2642  compound,
2644  std::move(query_rewriter),
2645  input_permutation,
2646  left_deep_join_input_sizes};
2647 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::list< std::shared_ptr< Analyzer::Expr > > translate_groupby_exprs(const RelAggregate *aggregate, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources)
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
std::vector< JoinType > left_deep_join_types(const RelLeftDeepInnerJoin *left_deep_join)
JoinType
Definition: sqldefs.h:98
std::vector< size_t > do_table_reordering(std::vector< InputDescriptor > &input_descs, std::list< std::shared_ptr< const InputColDescriptor >> &input_col_descs, const JoinQualsPerNestingLevel &left_deep_join_quals, std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const RA *node, const std::vector< InputTableInfo > &query_infos, const Executor *executor)
size_t size() const override
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr *> &target_exprs)
static const size_t max_groups_buffer_entry_default_guess
std::vector< JoinCondition > JoinQualsPerNestingLevel
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
bool g_from_table_reordering
Definition: Execute.cpp:75
const Catalog_Namespace::Catalog & cat_
JoinType get_join_type(const RelAlgNode *ra)
std::vector< std::shared_ptr< Analyzer::Expr > > translate_scalar_sources(const RA *ra_node, const RelAlgTranslator &translator)
const size_t inputCount() const
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
const RelAlgNode * getInput(const size_t idx) const
QualsConjunctiveForm translate_quals(const RelCompound *compound, const RelAlgTranslator &translator)
std::tuple< std::vector< InputDescriptor >, std::list< std::shared_ptr< const InputColDescriptor > >, std::vector< std::shared_ptr< RexInput > > > get_input_desc(const RA *ra_node, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const std::vector< size_t > &input_permutation, const Catalog_Namespace::Catalog &cat)
Executor * executor_
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals
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)
std::vector< Analyzer::Expr * > translate_targets(std::vector< std::shared_ptr< Analyzer::Expr >> &target_exprs_owned, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources, const std::list< std::shared_ptr< Analyzer::Expr >> &groupby_exprs, const RelAggregate *aggregate, const RelAlgTranslator &translator)
std::vector< size_t > get_left_deep_join_input_sizes(const RelLeftDeepInnerJoin *left_deep_join)
std::list< std::shared_ptr< Analyzer::Expr > > rewrite_quals(const std::list< std::shared_ptr< Analyzer::Expr >> &quals)
+ Here is the call graph for this function:

◆ createFilterWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createFilterWorkUnit ( const RelFilter filter,
const SortInfo sort_info,
const bool  just_explain 
)
private

Definition at line 3089 of file RelAlgExecutor.cpp.

References CHECK_EQ, ResultSet::executor_, fold_expr(), get_exprs_not_owned(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), anonymous_namespace{RelAlgExecutor.cpp}::get_inputs_meta(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_type(), RelFilter::getCondition(), RelAlgNode::inputCount(), rewrite_expr(), RelAlgNode::setOutputMetainfo(), and speculative_topn_blacklist_.

3091  {
3092  CHECK_EQ(size_t(1), filter->inputCount());
3093  std::vector<InputDescriptor> input_descs;
3094  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
3095  std::vector<TargetMetaInfo> in_metainfo;
3096  std::vector<std::shared_ptr<RexInput>> used_inputs_owned;
3097  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned;
3098 
3099  const auto input_to_nest_level = get_input_nest_levels(filter, {});
3100  std::tie(input_descs, input_col_descs, used_inputs_owned) =
3101  get_input_desc(filter, input_to_nest_level, {}, cat_);
3102  const auto join_type = get_join_type(filter);
3103  QueryFeatureDescriptor query_features;
3104  RelAlgTranslator translator(cat_,
3105  executor_,
3106  input_to_nest_level,
3107  {join_type},
3108  now_,
3109  just_explain,
3110  query_features);
3111  std::tie(in_metainfo, target_exprs_owned) =
3112  get_inputs_meta(filter, translator, used_inputs_owned, input_to_nest_level);
3113  const auto filter_expr = translator.translateScalarRex(filter->getCondition());
3114  const auto qual = fold_expr(filter_expr.get());
3115  target_exprs_owned_.insert(
3116  target_exprs_owned_.end(), target_exprs_owned.begin(), target_exprs_owned.end());
3117  const auto target_exprs = get_exprs_not_owned(target_exprs_owned);
3118  filter->setOutputMetainfo(in_metainfo);
3119  const auto rewritten_qual = rewrite_expr(qual.get());
3120  return {{input_descs,
3121  input_col_descs,
3122  {},
3123  {rewritten_qual ? rewritten_qual : qual},
3124  {},
3125  {nullptr},
3126  target_exprs,
3127  nullptr,
3128  sort_info,
3129  0},
3130  filter,
3132  nullptr};
3133 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
std::pair< std::vector< TargetMetaInfo >, std::vector< std::shared_ptr< Analyzer::Expr > > > get_inputs_meta(const RelFilter *filter, const RelAlgTranslator &translator, const std::vector< std::shared_ptr< RexInput >> &inputs_owned, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level)
static const size_t max_groups_buffer_entry_default_guess
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:211
Analyzer::ExpressionPtr rewrite_expr(const Analyzer::Expr *expr)
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
const Catalog_Namespace::Catalog & cat_
JoinType get_join_type(const RelAlgNode *ra)
const RexScalar * getCondition() const
const size_t inputCount() const
std::tuple< std::vector< InputDescriptor >, std::list< std::shared_ptr< const InputColDescriptor > >, std::vector< std::shared_ptr< RexInput > > > get_input_desc(const RA *ra_node, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const std::vector< size_t > &input_permutation, const Catalog_Namespace::Catalog &cat)
Executor * executor_
std::shared_ptr< Analyzer::Expr > fold_expr(const Analyzer::Expr *expr)
+ Here is the call graph for this function:

◆ createJoinWorkUnit()

WorkUnit RelAlgExecutor::createJoinWorkUnit ( const RelJoin ,
const SortInfo ,
const bool  just_explain 
)
private

◆ createModifyCompoundWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createModifyCompoundWorkUnit ( const RelCompound compound,
const SortInfo sort_info,
const bool  just_explain 
)
private

Definition at line 2465 of file RelAlgExecutor.cpp.

References CHECK_EQ, CHECK_GT, ResultSet::executor_, get_exprs_not_owned(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_type(), anonymous_namespace{RelAlgExecutor.cpp}::get_modify_manipulated_targets_meta(), anonymous_namespace{RelAlgExecutor.cpp}::get_scalar_sources_size(), get_table_infos(), RelAlgNode::getInput(), ModifyManipulationTarget::getModifiedTableDescriptor(), ModifyManipulationTarget::getTargetColumnCount(), ModifyManipulationTarget::getTargetColumns(), RelAlgNode::inputCount(), anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), anonymous_namespace{RelAlgExecutor.cpp}::rewrite_quals(), RelAlgNode::setOutputMetainfo(), RelAlgExecutionUnit::simple_quals, RelCompound::size(), TableDescriptor::tableId, anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs(), anonymous_namespace{RelAlgExecutor.cpp}::translate_quals(), anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources_for_update(), anonymous_namespace{RelAlgExecutor.cpp}::translate_targets_for_update(), and ScalarExprVisitor< T >::visit().

2468  {
2469  std::vector<InputDescriptor> input_descs;
2470  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
2471  auto input_to_nest_level = get_input_nest_levels(compound, {});
2472  std::tie(input_descs, input_col_descs, std::ignore) =
2473  get_input_desc(compound, input_to_nest_level, {}, cat_);
2474  const auto query_infos = get_table_infos(input_descs, executor_);
2475  CHECK_EQ(size_t(1), compound->inputCount());
2476  const auto left_deep_join =
2477  dynamic_cast<const RelLeftDeepInnerJoin*>(compound->getInput(0));
2478  JoinQualsPerNestingLevel left_deep_join_quals;
2479  const auto join_types = left_deep_join ? left_deep_join_types(left_deep_join)
2480  : std::vector<JoinType>{get_join_type(compound)};
2481  if (left_deep_join) {
2482  left_deep_join_quals = translateLeftDeepJoinFilter(
2483  left_deep_join, input_descs, input_to_nest_level, just_explain);
2484  }
2485  QueryFeatureDescriptor query_features;
2486  RelAlgTranslator translator(cat_,
2487  executor_,
2488  input_to_nest_level,
2489  join_types,
2490  now_,
2491  just_explain,
2492  query_features);
2493  size_t starting_projection_column_idx =
2494  get_scalar_sources_size(compound) - compound->getTargetColumnCount() - 1;
2495  CHECK_GT(starting_projection_column_idx, 0u);
2496  const auto scalar_sources =
2498  translator,
2499  compound->getModifiedTableDescriptor()->tableId,
2500  cat_,
2501  compound->getTargetColumns(),
2502  starting_projection_column_idx);
2503  const auto groupby_exprs = translate_groupby_exprs(compound, scalar_sources);
2504  const auto quals_cf = translate_quals(compound, translator);
2505  decltype(target_exprs_owned_) target_exprs_owned;
2506  translate_targets_for_update(target_exprs_owned,
2507  scalar_sources,
2508  groupby_exprs,
2509  compound,
2510  translator,
2511  compound->getModifiedTableDescriptor()->tableId,
2512  cat_,
2513  compound->getTargetColumns(),
2514  starting_projection_column_idx);
2515  target_exprs_owned_.insert(
2516  target_exprs_owned_.end(), target_exprs_owned.begin(), target_exprs_owned.end());
2517  const auto target_exprs = get_exprs_not_owned(target_exprs_owned);
2518  CHECK_EQ(compound->size(), target_exprs.size());
2519 
2520  const auto update_expr_iter =
2521  std::next(target_exprs.cbegin(), starting_projection_column_idx);
2522  decltype(target_exprs) filtered_target_exprs(update_expr_iter, target_exprs.end());
2523 
2524  UsedColumnsVisitor used_columns_visitor;
2525  std::unordered_set<int> id_accumulator;
2526 
2527  for (auto const& expr :
2528  boost::make_iterator_range(update_expr_iter, target_exprs.end())) {
2529  auto used_column_ids = used_columns_visitor.visit(expr);
2530  id_accumulator.insert(used_column_ids.begin(), used_column_ids.end());
2531  }
2532  for (auto const& expr : quals_cf.simple_quals) {
2533  auto simple_quals_used_column_ids = used_columns_visitor.visit(expr.get());
2534  id_accumulator.insert(simple_quals_used_column_ids.begin(),
2535  simple_quals_used_column_ids.end());
2536  }
2537  for (auto const& expr : quals_cf.quals) {
2538  auto quals_used_column_ids = used_columns_visitor.visit(expr.get());
2539  id_accumulator.insert(quals_used_column_ids.begin(), quals_used_column_ids.end());
2540  }
2541 
2542  decltype(input_col_descs) filtered_input_col_descs;
2543  for (auto col_desc : input_col_descs) {
2544  if (id_accumulator.find(col_desc->getColId()) != id_accumulator.end()) {
2545  filtered_input_col_descs.push_back(col_desc);
2546  }
2547  }
2548 
2549  const RelAlgExecutionUnit exe_unit = {input_descs,
2550  filtered_input_col_descs,
2551  quals_cf.simple_quals,
2552  rewrite_quals(quals_cf.quals),
2553  left_deep_join_quals,
2554  groupby_exprs,
2555  filtered_target_exprs,
2556  nullptr,
2557  sort_info,
2558  0,
2559  query_features,
2560  false};
2561  auto query_rewriter = std::make_unique<QueryRewriter>(query_infos, executor_);
2562  const auto rewritten_exe_unit = query_rewriter->rewrite(exe_unit);
2563  const auto targets_meta =
2564  get_modify_manipulated_targets_meta(compound, rewritten_exe_unit.target_exprs);
2565  compound->setOutputMetainfo(targets_meta);
2566  return {rewritten_exe_unit,
2567  compound,
2569  std::move(query_rewriter)};
2570 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::list< std::shared_ptr< Analyzer::Expr > > translate_groupby_exprs(const RelAggregate *aggregate, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources)
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
std::vector< JoinType > left_deep_join_types(const RelLeftDeepInnerJoin *left_deep_join)
JoinType
Definition: sqldefs.h:98
size_t size() const override
static const size_t max_groups_buffer_entry_default_guess
std::vector< std::shared_ptr< Analyzer::Expr > > translate_scalar_sources_for_update(const RA *ra_node, const RelAlgTranslator &translator, int32_t tableId, const Catalog_Namespace::Catalog &cat, const ColumnNameList &colNames, size_t starting_projection_column_idx)
std::vector< TargetMetaInfo > get_modify_manipulated_targets_meta(ModifyManipulationTarget const *manip_node, const std::vector< Analyzer::Expr *> &target_exprs)
std::vector< JoinCondition > JoinQualsPerNestingLevel
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:211
TableDescriptor const * getModifiedTableDescriptor() const
#define CHECK_GT(x, y)
Definition: Logger.h:199
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
std::vector< Analyzer::Expr * > translate_targets_for_update(std::vector< std::shared_ptr< Analyzer::Expr >> &target_exprs_owned, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources, const std::list< std::shared_ptr< Analyzer::Expr >> &groupby_exprs, const RelCompound *compound, const RelAlgTranslator &translator, int32_t tableId, const Catalog_Namespace::Catalog &cat, const ColumnNameList &colNames, size_t starting_projection_column_idx)
ColumnNameList const & getTargetColumns() const
const Catalog_Namespace::Catalog & cat_
JoinType get_join_type(const RelAlgNode *ra)
const size_t inputCount() const
size_t get_scalar_sources_size(const RelProject *project)
T visit(const Analyzer::Expr *expr) const
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
const RelAlgNode * getInput(const size_t idx) const
QualsConjunctiveForm translate_quals(const RelCompound *compound, const RelAlgTranslator &translator)
std::tuple< std::vector< InputDescriptor >, std::list< std::shared_ptr< const InputColDescriptor > >, std::vector< std::shared_ptr< RexInput > > > get_input_desc(const RA *ra_node, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const std::vector< size_t > &input_permutation, const Catalog_Namespace::Catalog &cat)
Executor * executor_
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals
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)
std::list< std::shared_ptr< Analyzer::Expr > > rewrite_quals(const std::list< std::shared_ptr< Analyzer::Expr >> &quals)
+ Here is the call graph for this function:

◆ createModifyProjectWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createModifyProjectWorkUnit ( const RelProject project,
const SortInfo sort_info,
const bool  just_explain 
)
private

Definition at line 2892 of file RelAlgExecutor.cpp.

References CHECK_EQ, CHECK_GT, ResultSet::executor_, get_exprs_not_owned(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_type(), anonymous_namespace{RelAlgExecutor.cpp}::get_modify_manipulated_targets_meta(), anonymous_namespace{RelAlgExecutor.cpp}::get_scalar_sources_size(), RelAlgNode::getInput(), ModifyManipulationTarget::getModifiedTableDescriptor(), ModifyManipulationTarget::getTargetColumnCount(), ModifyManipulationTarget::getTargetColumns(), anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), RelAlgNode::setOutputMetainfo(), RelProject::size(), TableDescriptor::tableId, anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources_for_update(), and ScalarExprVisitor< T >::visit().

2895  {
2896  std::vector<InputDescriptor> input_descs;
2897  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
2898  auto input_to_nest_level = get_input_nest_levels(project, {});
2899  std::tie(input_descs, input_col_descs, std::ignore) =
2900  get_input_desc(project, input_to_nest_level, {}, cat_);
2901  const auto left_deep_join =
2902  dynamic_cast<const RelLeftDeepInnerJoin*>(project->getInput(0));
2903  JoinQualsPerNestingLevel left_deep_join_quals;
2904  const auto join_types = left_deep_join ? left_deep_join_types(left_deep_join)
2905  : std::vector<JoinType>{get_join_type(project)};
2906  if (left_deep_join) {
2907  left_deep_join_quals = translateLeftDeepJoinFilter(
2908  left_deep_join, input_descs, input_to_nest_level, just_explain);
2909  }
2910  QueryFeatureDescriptor query_features;
2911  RelAlgTranslator translator(cat_,
2912  executor_,
2913  input_to_nest_level,
2914  join_types,
2915  now_,
2916  just_explain,
2917  query_features);
2918  size_t starting_projection_column_idx =
2919  get_scalar_sources_size(project) - project->getTargetColumnCount() - 1;
2920  CHECK_GT(starting_projection_column_idx, 0u);
2921  auto target_exprs_owned =
2923  translator,
2924  project->getModifiedTableDescriptor()->tableId,
2925  cat_,
2926  project->getTargetColumns(),
2927  starting_projection_column_idx);
2928  target_exprs_owned_.insert(
2929  target_exprs_owned_.end(), target_exprs_owned.begin(), target_exprs_owned.end());
2930  const auto target_exprs = get_exprs_not_owned(target_exprs_owned);
2931  CHECK_EQ(project->size(), target_exprs.size());
2932 
2933  const auto update_expr_iter =
2934  std::next(target_exprs.cbegin(), starting_projection_column_idx);
2935  decltype(target_exprs) filtered_target_exprs(update_expr_iter, target_exprs.end());
2936 
2937  UsedColumnsVisitor used_columns_visitor;
2938  std::unordered_set<int> id_accumulator;
2939 
2940  for (auto const& expr :
2941  boost::make_iterator_range(update_expr_iter, target_exprs.end())) {
2942  auto used_column_ids = used_columns_visitor.visit(expr);
2943  id_accumulator.insert(used_column_ids.begin(), used_column_ids.end());
2944  }
2945 
2946  decltype(input_col_descs) filtered_input_col_descs;
2947  for (auto col_desc : input_col_descs) {
2948  if (id_accumulator.find(col_desc->getColId()) != id_accumulator.end()) {
2949  filtered_input_col_descs.push_back(col_desc);
2950  }
2951  }
2952 
2953  const auto targets_meta =
2954  get_modify_manipulated_targets_meta(project, filtered_target_exprs);
2955  project->setOutputMetainfo(targets_meta);
2956  return {{input_descs,
2957  filtered_input_col_descs,
2958  {},
2959  {},
2960  left_deep_join_quals,
2961  {nullptr},
2962  filtered_target_exprs,
2963  nullptr,
2964  sort_info,
2965  0,
2966  query_features,
2967  false},
2968  project,
2970  nullptr};
2971 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
std::vector< JoinType > left_deep_join_types(const RelLeftDeepInnerJoin *left_deep_join)
JoinType
Definition: sqldefs.h:98
size_t size() const override
static const size_t max_groups_buffer_entry_default_guess
std::vector< std::shared_ptr< Analyzer::Expr > > translate_scalar_sources_for_update(const RA *ra_node, const RelAlgTranslator &translator, int32_t tableId, const Catalog_Namespace::Catalog &cat, const ColumnNameList &colNames, size_t starting_projection_column_idx)
std::vector< TargetMetaInfo > get_modify_manipulated_targets_meta(ModifyManipulationTarget const *manip_node, const std::vector< Analyzer::Expr *> &target_exprs)
std::vector< JoinCondition > JoinQualsPerNestingLevel
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:211
TableDescriptor const * getModifiedTableDescriptor() const
#define CHECK_GT(x, y)
Definition: Logger.h:199
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
ColumnNameList const & getTargetColumns() const
const Catalog_Namespace::Catalog & cat_
JoinType get_join_type(const RelAlgNode *ra)
size_t get_scalar_sources_size(const RelProject *project)
T visit(const Analyzer::Expr *expr) const
const RelAlgNode * getInput(const size_t idx) const
std::tuple< std::vector< InputDescriptor >, std::list< std::shared_ptr< const InputColDescriptor > >, std::vector< std::shared_ptr< RexInput > > > get_input_desc(const RA *ra_node, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const std::vector< size_t > &input_permutation, const Catalog_Namespace::Catalog &cat)
Executor * executor_
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)
+ Here is the call graph for this function:

◆ createProjectWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createProjectWorkUnit ( const RelProject project,
const SortInfo sort_info,
const bool  just_explain 
)
private

Definition at line 2973 of file RelAlgExecutor.cpp.

References anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering(), ResultSet::executor_, g_from_table_reordering, get_exprs_not_owned(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), anonymous_namespace{RelAlgExecutor.cpp}::get_join_type(), anonymous_namespace{RelAlgExecutor.cpp}::get_left_deep_join_input_sizes(), get_table_infos(), anonymous_namespace{RelAlgExecutor.cpp}::get_targets_meta(), RelAlgNode::getInput(), anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), RelAlgNode::setOutputMetainfo(), and anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources().

2975  {
2976  std::vector<InputDescriptor> input_descs;
2977  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
2978  auto input_to_nest_level = get_input_nest_levels(project, {});
2979  std::tie(input_descs, input_col_descs, std::ignore) =
2980  get_input_desc(project, input_to_nest_level, {}, cat_);
2981  const auto query_infos = get_table_infos(input_descs, executor_);
2982 
2983  const auto left_deep_join =
2984  dynamic_cast<const RelLeftDeepInnerJoin*>(project->getInput(0));
2985  JoinQualsPerNestingLevel left_deep_join_quals;
2986  const auto join_types = left_deep_join ? left_deep_join_types(left_deep_join)
2987  : std::vector<JoinType>{get_join_type(project)};
2988  std::vector<size_t> input_permutation;
2989  std::vector<size_t> left_deep_join_input_sizes;
2990  if (left_deep_join) {
2991  left_deep_join_input_sizes = get_left_deep_join_input_sizes(left_deep_join);
2992  const auto query_infos = get_table_infos(input_descs, executor_);
2993  left_deep_join_quals = translateLeftDeepJoinFilter(
2994  left_deep_join, input_descs, input_to_nest_level, just_explain);
2996  input_permutation = do_table_reordering(input_descs,
2997  input_col_descs,
2998  left_deep_join_quals,
2999  input_to_nest_level,
3000  project,
3001  query_infos,
3002  executor_);
3003  input_to_nest_level = get_input_nest_levels(project, input_permutation);
3004  std::tie(input_descs, input_col_descs, std::ignore) =
3005  get_input_desc(project, input_to_nest_level, input_permutation, cat_);
3006  left_deep_join_quals = translateLeftDeepJoinFilter(
3007  left_deep_join, input_descs, input_to_nest_level, just_explain);
3008  }
3009  }
3010 
3011  QueryFeatureDescriptor query_features;
3012  RelAlgTranslator translator(cat_,
3013  executor_,
3014  input_to_nest_level,
3015  join_types,
3016  now_,
3017  just_explain,
3018  query_features);
3019  const auto target_exprs_owned = translate_scalar_sources(project, translator);
3020  target_exprs_owned_.insert(
3021  target_exprs_owned_.end(), target_exprs_owned.begin(), target_exprs_owned.end());
3022  const auto target_exprs = get_exprs_not_owned(target_exprs_owned);
3023  const RelAlgExecutionUnit exe_unit = {input_descs,
3024  input_col_descs,
3025  {},
3026  {},
3027  left_deep_join_quals,
3028  {nullptr},
3029  target_exprs,
3030  nullptr,
3031  sort_info,
3032  0,
3033  query_features,
3034  false};
3035  auto query_rewriter = std::make_unique<QueryRewriter>(query_infos, executor_);
3036  const auto rewritten_exe_unit = query_rewriter->rewrite(exe_unit);
3037  const auto targets_meta = get_targets_meta(project, rewritten_exe_unit.target_exprs);
3038  project->setOutputMetainfo(targets_meta);
3039  return {rewritten_exe_unit,
3040  project,
3042  std::move(query_rewriter),
3043  input_permutation,
3044  left_deep_join_input_sizes};
3045 }
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
std::vector< JoinType > left_deep_join_types(const RelLeftDeepInnerJoin *left_deep_join)
JoinType
Definition: sqldefs.h:98
std::vector< size_t > do_table_reordering(std::vector< InputDescriptor > &input_descs, std::list< std::shared_ptr< const InputColDescriptor >> &input_col_descs, const JoinQualsPerNestingLevel &left_deep_join_quals, std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const RA *node, const std::vector< InputTableInfo > &query_infos, const Executor *executor)
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr *> &target_exprs)
static const size_t max_groups_buffer_entry_default_guess
std::vector< JoinCondition > JoinQualsPerNestingLevel
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:211
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
bool g_from_table_reordering
Definition: Execute.cpp:75
const Catalog_Namespace::Catalog & cat_
JoinType get_join_type(const RelAlgNode *ra)
std::vector< std::shared_ptr< Analyzer::Expr > > translate_scalar_sources(const RA *ra_node, const RelAlgTranslator &translator)
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
const RelAlgNode * getInput(const size_t idx) const
std::tuple< std::vector< InputDescriptor >, std::list< std::shared_ptr< const InputColDescriptor > >, std::vector< std::shared_ptr< RexInput > > > get_input_desc(const RA *ra_node, const std::unordered_map< const RelAlgNode *, int > &input_to_nest_level, const std::vector< size_t > &input_permutation, const Catalog_Namespace::Catalog &cat)
Executor * executor_
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)
std::vector< size_t > get_left_deep_join_input_sizes(const RelLeftDeepInnerJoin *left_deep_join)
+ Here is the call graph for this function:

◆ createSortInputWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createSortInputWorkUnit ( const RelSort sort,
const bool  just_explain 
)
private

Definition at line 1688 of file RelAlgExecutor.cpp.

References RelSort::collationCount(), Default, anonymous_namespace{RelAlgExecutor.cpp}::first_oe_is_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_order_entries(), anonymous_namespace{RelAlgExecutor.cpp}::get_scan_limit(), RelAlgNode::getInput(), RelSort::getLimit(), RelSort::getOffset(), RelAlgNode::setOutputMetainfo(), SpeculativeTopN, and StreamingTopN.

1690  {
1691  const auto source = sort->getInput(0);
1692  const size_t limit = sort->getLimit();
1693  const size_t offset = sort->getOffset();
1694  const size_t scan_limit = sort->collationCount() ? 0 : get_scan_limit(source, limit);
1695  const size_t scan_total_limit =
1696  scan_limit ? get_scan_limit(source, scan_limit + offset) : 0;
1697  size_t max_groups_buffer_entry_guess{
1698  scan_total_limit ? scan_total_limit : max_groups_buffer_entry_default_guess};
1700  const auto order_entries = get_order_entries(sort);
1701  SortInfo sort_info{order_entries, sort_algorithm, limit, offset};
1702  auto source_work_unit = createWorkUnit(source, sort_info, just_explain);
1703  const auto& source_exe_unit = source_work_unit.exe_unit;
1704  if (source_exe_unit.groupby_exprs.size() == 1) {
1705  if (!source_exe_unit.groupby_exprs.front()) {
1706  sort_algorithm = SortAlgorithm::StreamingTopN;
1707  } else {
1708  if (speculative_topn_blacklist_.contains(source_exe_unit.groupby_exprs.front(),
1709  first_oe_is_desc(order_entries))) {
1710  sort_algorithm = SortAlgorithm::Default;
1711  }
1712  }
1713  }
1714 
1715  sort->setOutputMetainfo(source->getOutputMetainfo());
1716  // NB: the `body` field of the returned `WorkUnit` needs to be the `source` node,
1717  // not the `sort`. The aggregator needs the pre-sorted result from leaves.
1718  return {{source_exe_unit.input_descs,
1719  std::move(source_exe_unit.input_col_descs),
1720  source_exe_unit.simple_quals,
1721  source_exe_unit.quals,
1722  source_exe_unit.join_quals,
1723  source_exe_unit.groupby_exprs,
1724  source_exe_unit.target_exprs,
1725  nullptr,
1726  {sort_info.order_entries, sort_algorithm, limit, offset},
1727  scan_total_limit,
1728  source_exe_unit.query_features},
1729  source,
1730  max_groups_buffer_entry_guess,
1731  std::move(source_work_unit.query_rewriter),
1732  source_work_unit.input_permutation,
1733  source_work_unit.left_deep_join_input_sizes};
1734 }
size_t collationCount() const
WorkUnit createWorkUnit(const RelAlgNode *, const SortInfo &, const bool just_explain)
size_t get_scan_limit(const RelAlgNode *ra, const size_t limit)
static SpeculativeTopNBlacklist speculative_topn_blacklist_
static const size_t max_groups_buffer_entry_default_guess
bool contains(const std::shared_ptr< Analyzer::Expr > expr, const bool desc) const
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
SortAlgorithm
size_t getOffset() const
size_t getLimit() const
std::list< Analyzer::OrderEntry > get_order_entries(const RelSort *sort)
const RelAlgNode * getInput(const size_t idx) const
bool first_oe_is_desc(const std::list< Analyzer::OrderEntry > &order_entries)
+ Here is the call graph for this function:

◆ createWindowFunctionContext()

std::unique_ptr< WindowFunctionContext > RelAlgExecutor::createWindowFunctionContext ( const Analyzer::WindowFunction window_func,
const std::shared_ptr< Analyzer::BinOper > &  partition_key_cond,
const RelAlgExecutionUnit ra_exe_unit,
const std::vector< InputTableInfo > &  query_infos,
const CompilationOptions co,
ColumnCacheMap column_cache_map 
)
private

Definition at line 1445 of file RelAlgExecutor.cpp.

References CHECK, CHECK_EQ, Data_Namespace::CPU_LEVEL, CompilationOptions::device_type_, ResultSet::executor_, ColumnFetcher::getOneColumnFragment(), Analyzer::WindowFunction::getOrderKeys(), GPU, Data_Namespace::GPU_LEVEL, and JoinHashTableInterface::OneToMany.

1451  {
1452  const auto memory_level = co.device_type_ == ExecutorDeviceType::GPU
1455  const auto join_table_or_err =
1456  executor_->buildHashTableForQualifier(partition_key_cond,
1457  query_infos,
1458  memory_level,
1460  column_cache_map);
1461  if (!join_table_or_err.fail_reason.empty()) {
1462  throw std::runtime_error(join_table_or_err.fail_reason);
1463  }
1464  CHECK(join_table_or_err.hash_table->getHashType() ==
1466  const auto& order_keys = window_func->getOrderKeys();
1467  std::vector<std::shared_ptr<Chunk_NS::Chunk>> chunks_owner;
1468  const size_t elem_count = query_infos.front().info.fragments.front().getNumTuples();
1469  auto context = std::make_unique<WindowFunctionContext>(
1470  window_func, join_table_or_err.hash_table, elem_count, co.device_type_);
1471  for (const auto& order_key : order_keys) {
1472  const auto order_col =
1473  std::dynamic_pointer_cast<const Analyzer::ColumnVar>(order_key);
1474  if (!order_col) {
1475  throw std::runtime_error("Only order by columns supported for now");
1476  }
1477  const int8_t* column;
1478  size_t join_col_elem_count;
1479  std::tie(column, join_col_elem_count) =
1481  *order_col,
1482  query_infos.front().info.fragments.front(),
1483  memory_level,
1484  0,
1485  chunks_owner,
1486  column_cache_map);
1487  CHECK_EQ(join_col_elem_count, elem_count);
1488  context->addOrderColumn(column, order_col.get(), chunks_owner);
1489  }
1490  return context;
1491 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
const std::vector< std::shared_ptr< Analyzer::Expr > > & getOrderKeys() const
Definition: Analyzer.h:1347
static std::pair< const int8_t *, size_t > getOneColumnFragment(Executor *executor, const Analyzer::ColumnVar &hash_col, const Fragmenter_Namespace::FragmentInfo &fragment, const Data_Namespace::MemoryLevel effective_mem_lvl, const int device_id, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, ColumnCacheMap &column_cache)
ExecutorDeviceType device_type_
#define CHECK(condition)
Definition: Logger.h:187
Executor * executor_
+ Here is the call graph for this function:

◆ createWorkUnit()

RelAlgExecutor::WorkUnit RelAlgExecutor::createWorkUnit ( const RelAlgNode node,
const SortInfo sort_info,
const bool  just_explain 
)
private

Definition at line 2296 of file RelAlgExecutor.cpp.

References CHECK.

2298  {
2299  const auto compound = dynamic_cast<const RelCompound*>(node);
2300  if (compound) {
2301  return createCompoundWorkUnit(compound, sort_info, just_explain);
2302  }
2303  const auto project = dynamic_cast<const RelProject*>(node);
2304  if (project) {
2305  return createProjectWorkUnit(project, sort_info, just_explain);
2306  }
2307  const auto aggregate = dynamic_cast<const RelAggregate*>(node);
2308  if (aggregate) {
2309  return createAggregateWorkUnit(aggregate, sort_info, just_explain);
2310  }
2311  const auto filter = dynamic_cast<const RelFilter*>(node);
2312  CHECK(filter);
2313  return createFilterWorkUnit(filter, sort_info, just_explain);
2314 }
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const bool just_explain)
WorkUnit createAggregateWorkUnit(const RelAggregate *, const SortInfo &, const bool just_explain)
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const bool just_explain)
#define CHECK(condition)
Definition: Logger.h:187
WorkUnit createFilterWorkUnit(const RelFilter *, const SortInfo &, const bool just_explain)

◆ eraseFromTemporaryTables()

void RelAlgExecutor::eraseFromTemporaryTables ( const int  table_id)
inlineprivate

Definition at line 304 of file RelAlgExecutor.h.

References join().

304 { temporary_tables_.erase(table_id); }
TemporaryTables temporary_tables_
+ Here is the call graph for this function:

◆ executeAggregate()

ExecutionResult RelAlgExecutor::executeAggregate ( const RelAggregate aggregate,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1312 of file RelAlgExecutor.cpp.

References Default, RelAlgNode::getOutputMetainfo(), and ExecutionOptions::just_explain.

1316  {
1317  const auto work_unit = createAggregateWorkUnit(
1318  aggregate, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1319  return executeWorkUnit(work_unit,
1320  aggregate->getOutputMetainfo(),
1321  true,
1322  co,
1323  eo,
1324  render_info,
1325  queue_time_ms);
1326 }
WorkUnit createAggregateWorkUnit(const RelAggregate *, const SortInfo &, const bool just_explain)
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
ExecutionResult executeWorkUnit(const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count=-1)
+ Here is the call graph for this function:

◆ executeCompound()

ExecutionResult RelAlgExecutor::executeCompound ( const RelCompound compound,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1295 of file RelAlgExecutor.cpp.

References Default, RelAlgNode::getOutputMetainfo(), RelCompound::isAggregate(), and ExecutionOptions::just_explain.

1299  {
1300  const auto work_unit = createCompoundWorkUnit(
1301  compound, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1302  CompilationOptions co_compound = co;
1303  return executeWorkUnit(work_unit,
1304  compound->getOutputMetainfo(),
1305  compound->isAggregate(),
1306  co_compound,
1307  eo,
1308  render_info,
1309  queue_time_ms);
1310 }
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const bool just_explain)
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
ExecutionResult executeWorkUnit(const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count=-1)
+ Here is the call graph for this function:

◆ executeDeleteViaCompound()

void RelAlgExecutor::executeDeleteViaCompound ( const RelCompound compound,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1210 of file RelAlgExecutor.cpp.

References CPU, Default, CompilationOptions::device_type_, ResultSet::executor_, get_table_infos(), ModifyManipulationTarget::getModifiedTableDescriptor(), logger::INFO, CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), ExecutionOptions::just_explain, and LOG.

1214  {
1215  auto* table_descriptor = compound->getModifiedTableDescriptor();
1216  if (!table_descriptor->hasDeletedCol) {
1217  throw std::runtime_error(
1218  "DELETE only supported on tables with the vacuum attribute set to 'delayed'");
1219  }
1220 
1221  const auto work_unit = createModifyCompoundWorkUnit(
1222  compound, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1223  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
1224  CompilationOptions co_project = co;
1226 
1227  try {
1229 
1230  DeleteTransactionParameters delete_params;
1231  auto delete_callback = yieldDeleteCallback(delete_params);
1232 
1233  executor_->executeUpdate(work_unit.exe_unit,
1234  table_infos.front(),
1235  co_project,
1236  eo,
1237  cat_,
1238  executor_->row_set_mem_owner_,
1239  delete_callback);
1240  delete_params.finalizeTransaction();
1241  } catch (...) {
1242  LOG(INFO) << "Delete operation failed.";
1243  throw;
1244  }
1245 }
#define LOG(tag)
Definition: Logger.h:182
TableDescriptor const * getModifiedTableDescriptor() const
static void invalidateCaches()
const Catalog_Namespace::Catalog & cat_
WorkUnit createModifyCompoundWorkUnit(const RelCompound *compound, const SortInfo &sort_info, const bool just_explain)
ExecutorDeviceType device_type_
UpdateCallback yieldDeleteCallback(DeleteTransactionParameters &delete_parameters)
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
Executor * executor_
+ Here is the call graph for this function:

◆ executeDeleteViaProject()

void RelAlgExecutor::executeDeleteViaProject ( const RelProject project,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1247 of file RelAlgExecutor.cpp.

References CHECK, CHECK_EQ, CPU, Default, CompilationOptions::device_type_, ResultSet::executor_, get_table_infos(), get_temporary_table(), RelAlgNode::getInput(), ModifyManipulationTarget::getModifiedTableDescriptor(), logger::INFO, RelAlgNode::inputCount(), CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), RelProject::isSimple(), ExecutionOptions::just_explain, and LOG.

1251  {
1252  auto* table_descriptor = project->getModifiedTableDescriptor();
1253  if (!table_descriptor->hasDeletedCol) {
1254  throw std::runtime_error(
1255  "DELETE only supported on tables with the vacuum attribute set to 'delayed'");
1256  }
1257 
1258  auto work_unit = createModifyProjectWorkUnit(
1259  project, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1260  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
1261  CompilationOptions co_project = co;
1263 
1264  if (project->isSimple()) {
1265  CHECK_EQ(size_t(1), project->inputCount());
1266  const auto input_ra = project->getInput(0);
1267  if (dynamic_cast<const RelSort*>(input_ra)) {
1268  const auto& input_table =
1269  get_temporary_table(&temporary_tables_, -input_ra->getId());
1270  CHECK(input_table);
1271  work_unit.exe_unit.scan_limit = input_table->rowCount();
1272  }
1273  }
1274 
1275  try {
1277 
1278  DeleteTransactionParameters delete_params;
1279  auto delete_callback = yieldDeleteCallback(delete_params);
1280 
1281  executor_->executeUpdate(work_unit.exe_unit,
1282  table_infos.front(),
1283  co_project,
1284  eo,
1285  cat_,
1286  executor_->row_set_mem_owner_,
1287  delete_callback);
1288  delete_params.finalizeTransaction();
1289  } catch (...) {
1290  LOG(INFO) << "Delete operation failed.";
1291  throw;
1292  }
1293 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define LOG(tag)
Definition: Logger.h:182
TemporaryTables temporary_tables_
TableDescriptor const * getModifiedTableDescriptor() const
static void invalidateCaches()
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:176
WorkUnit createModifyProjectWorkUnit(const RelProject *project, const SortInfo &sort_info, const bool just_explain)
const Catalog_Namespace::Catalog & cat_
ExecutorDeviceType device_type_
UpdateCallback yieldDeleteCallback(DeleteTransactionParameters &delete_parameters)
const size_t inputCount() const
#define CHECK(condition)
Definition: Logger.h:187
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
const RelAlgNode * getInput(const size_t idx) const
Executor * executor_
+ Here is the call graph for this function:

◆ executeFilter()

ExecutionResult RelAlgExecutor::executeFilter ( const RelFilter filter,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1493 of file RelAlgExecutor.cpp.

References Default, RelAlgNode::getOutputMetainfo(), and ExecutionOptions::just_explain.

1497  {
1498  const auto work_unit =
1499  createFilterWorkUnit(filter, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1500  return executeWorkUnit(
1501  work_unit, filter->getOutputMetainfo(), false, co, eo, render_info, queue_time_ms);
1502 }
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
ExecutionResult executeWorkUnit(const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count=-1)
WorkUnit createFilterWorkUnit(const RelFilter *, const SortInfo &, const bool just_explain)
+ Here is the call graph for this function:

◆ executeLogicalValues()

ExecutionResult RelAlgExecutor::executeLogicalValues ( const RelLogicalValues logical_values,
const ExecutionOptions eo 
)
private

Definition at line 1520 of file RelAlgExecutor.cpp.

References QueryMemoryDescriptor::addColSlotInfo(), CPU, ResultSet::executor_, RelLogicalValues::getTupleType(), ExecutionOptions::just_explain, kCOUNT, kNULLT, NonGroupedAggregate, and RelAlgNode::setOutputMetainfo().

1522  {
1523  if (eo.just_explain) {
1524  throw std::runtime_error("EXPLAIN not supported for LogicalValues");
1525  }
1526  QueryMemoryDescriptor query_mem_desc(
1528 
1529  const auto& tuple_type = logical_values->getTupleType();
1530  for (size_t i = 0; i < tuple_type.size(); ++i) {
1531  query_mem_desc.addColSlotInfo({std::make_tuple(8, 8)});
1532  }
1533  logical_values->setOutputMetainfo(tuple_type);
1534  std::vector<std::unique_ptr<Analyzer::ColumnVar>> owned_column_expressions;
1535  std::vector<Analyzer::Expr*> target_expressions;
1536  for (const auto& tuple_component : tuple_type) {
1537  const auto column_var =
1538  new Analyzer::ColumnVar(tuple_component.get_type_info(), 0, 0, 0);
1539  target_expressions.push_back(column_var);
1540  owned_column_expressions.emplace_back(column_var);
1541  }
1542  std::vector<TargetInfo> target_infos;
1543  for (const auto& tuple_type_component : tuple_type) {
1544  target_infos.emplace_back(TargetInfo{false,
1545  kCOUNT,
1546  tuple_type_component.get_type_info(),
1547  SQLTypeInfo(kNULLT, false),
1548  false,
1549  false});
1550  }
1551  auto rs = std::make_shared<ResultSet>(target_infos,
1553  query_mem_desc,
1554  executor_->getRowSetMemoryOwner(),
1555  executor_);
1556  return {rs, tuple_type};
1557 }
const std::vector< TargetMetaInfo > getTupleType() const
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
Definition: sqldefs.h:71
Executor * executor_
+ Here is the call graph for this function:

◆ executeModify()

ExecutionResult RelAlgExecutor::executeModify ( const RelModify modify,
const ExecutionOptions eo 
)
private

Definition at line 1504 of file RelAlgExecutor.cpp.

References CPU, ResultSet::executor_, and ExecutionOptions::just_explain.

1505  {
1506  if (eo.just_explain) {
1507  throw std::runtime_error("EXPLAIN not supported for ModifyTable");
1508  }
1509 
1510  auto rs = std::make_shared<ResultSet>(TargetInfoList{},
1513  executor_->getRowSetMemoryOwner(),
1514  executor_);
1515 
1516  std::vector<TargetMetaInfo> empty_targets;
1517  return {rs, empty_targets};
1518 }
std::vector< TargetInfo > TargetInfoList
Executor * executor_

◆ executeProject()

ExecutionResult RelAlgExecutor::executeProject ( const RelProject project,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms,
const ssize_t  previous_count 
)
private

Definition at line 1341 of file RelAlgExecutor.cpp.

References CHECK, CHECK_EQ, CPU, Default, get_temporary_table(), RelAlgNode::getInput(), RelAlgNode::getOutputMetainfo(), RelAlgNode::inputCount(), RelProject::isSimple(), and ExecutionOptions::just_explain.

1346  {
1347  auto work_unit =
1348  createProjectWorkUnit(project, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1349  CompilationOptions co_project = co;
1350  if (project->isSimple()) {
1351  CHECK_EQ(size_t(1), project->inputCount());
1352  const auto input_ra = project->getInput(0);
1353  if (dynamic_cast<const RelSort*>(input_ra)) {
1354  co_project.device_type_ = ExecutorDeviceType::CPU;
1355  const auto& input_table =
1356  get_temporary_table(&temporary_tables_, -input_ra->getId());
1357  CHECK(input_table);
1358  work_unit.exe_unit.scan_limit =
1359  std::min(input_table->getLimit(), input_table->rowCount());
1360  }
1361  }
1362  return executeWorkUnit(work_unit,
1363  project->getOutputMetainfo(),
1364  false,
1365  co_project,
1366  eo,
1367  render_info,
1368  queue_time_ms,
1369  previous_count);
1370 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const bool just_explain)
TemporaryTables temporary_tables_
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:176
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
const size_t inputCount() const
ExecutionResult executeWorkUnit(const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count=-1)
#define CHECK(condition)
Definition: Logger.h:187
const RelAlgNode * getInput(const size_t idx) const
+ Here is the call graph for this function:

◆ executeRelAlgQuery()

ExecutionResult RelAlgExecutor::executeRelAlgQuery ( const std::string &  query_ra,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info 
)

Definition at line 53 of file RelAlgExecutor.cpp.

References CPU, CompilationOptions::explain_type_, g_allow_cpu_retry, CompilationOptions::hoist_literals_, logger::INFO, INJECT_TIMER, LOG, CompilationOptions::opt_level_, CompilationOptions::register_intel_jit_listener_, RenderInfo::setForceNonInSituData(), and CompilationOptions::with_dynamic_watchdog_.

Referenced by QueryRunner::QueryRunner::runSelectQuery().

56  {
58  try {
59  return executeRelAlgQueryNoRetry(query_ra, co, eo, render_info);
60  } catch (const QueryMustRunOnCpu&) {
61  if (!g_allow_cpu_retry) {
62  throw;
63  }
64  }
65  LOG(INFO) << "Query unable to run in GPU mode, retrying on CPU";
67  co.hoist_literals_,
68  co.opt_level_,
70  co.explain_type_,
72  if (render_info) {
73  render_info->setForceNonInSituData();
74  }
75  return executeRelAlgQueryNoRetry(query_ra, co_cpu, eo, render_info);
76 }
ExecutionResult executeRelAlgQueryNoRetry(const std::string &query_ra, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
void setForceNonInSituData()
Definition: RenderInfo.cpp:36
#define LOG(tag)
Definition: Logger.h:182
const ExecutorOptLevel opt_level_
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const bool register_intel_jit_listener_
const ExecutorExplainType explain_type_
bool g_allow_cpu_retry
Definition: Execute.cpp:72
ExecutionResult executeRelAlgQuery(const std::string &query_ra, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
const bool with_dynamic_watchdog_
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeRelAlgQueryNoRetry()

ExecutionResult RelAlgExecutor::executeRelAlgQueryNoRetry ( const std::string &  query_ra,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info 
)
private

Definition at line 78 of file RelAlgExecutor.cpp.

References CHECK, deserialize_ra_dag(), RenderInfo::disallow_in_situ_only_if_final_ED_is_aggregate, executeRelAlgSubQuery(), ResultSet::executor_, ExecutionOptions::find_push_down_candidates, g_enable_dynamic_watchdog, get_execution_descriptors(), RenderInfo::getRenderQueryOptsPtr(), INJECT_TIMER, run-benchmark-import::result, RenderInfo::row_set_mem_owner, RenderInfo::setInSituDataIfUnset(), timer_start(), and timer_stop().

81  {
83  decltype(subqueries_)().swap(subqueries_);
84 
85  const auto ra = deserialize_ra_dag(
86  query_ra, cat_, this, render_info ? render_info->getRenderQueryOptsPtr() : nullptr);
87 
88  // capture the lock acquistion time
89  auto clock_begin = timer_start();
90  std::lock_guard<std::mutex> lock(executor_->execute_mutex_);
91  int64_t queue_time_ms = timer_stop(clock_begin);
93  executor_->resetInterrupt();
94  }
95  ScopeGuard row_set_holder = [this, &render_info] {
96  if (render_info) {
97  // need to hold onto the RowSetMemOwner for potential
98  // string id lookups during render vega validation
99  render_info->row_set_mem_owner = executor_->row_set_mem_owner_;
100  }
102  };
103  executor_->row_set_mem_owner_ = std::make_shared<RowSetMemoryOwner>();
104  executor_->catalog_ = &cat_;
105  executor_->agg_col_range_cache_ = computeColRangesCache(ra.get());
106  executor_->string_dictionary_generations_ =
108  executor_->table_generations_ = computeTableGenerations(ra.get());
109 
110  ScopeGuard restore_metainfo_cache = [this] { executor_->clearMetaInfoCache(); };
111  auto ed_list = get_execution_descriptors(ra.get());
112 
113  if (render_info) {
114  // set render to be non-insitu in certain situations.
116  ed_list.size() > 1) {
117  // old logic
118  // disallow if more than one ED
119  render_info->setInSituDataIfUnset(false);
120  }
121  }
122 
123  if (eo.find_push_down_candidates) {
124  // this extra logic is mainly due to current limitations on multi-step queries
125  // and/or subqueries.
127  ed_list, co, eo, render_info, queue_time_ms);
128  }
129 
130  // Dispatch the subqueries first
131  for (auto subquery : subqueries_) {
132  const auto subquery_ra = subquery->getRelAlg();
133  CHECK(subquery_ra);
134  if (subquery_ra->hasContextData()) {
135  continue;
136  }
137  // Execute the subquery and cache the result.
138  RelAlgExecutor ra_executor(executor_, cat_);
139  auto result = ra_executor.executeRelAlgSubQuery(subquery.get(), co, eo);
140  subquery->setExecutionResult(std::make_shared<ExecutionResult>(result));
141  }
142  return executeRelAlgSeq(ed_list, co, eo, render_info, queue_time_ms);
143 }
const RenderQueryOptions * getRenderQueryOptsPtr() const
Definition: RenderInfo.cpp:94
ExecutionResult executeRelAlgQueryNoRetry(const std::string &query_ra, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
AggregatedColRange computeColRangesCache(const RelAlgNode *ra)
std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner
Definition: RenderInfo.h:34
std::vector< std::shared_ptr< RexSubQuery > > subqueries_
ExecutionResult executeRelAlgSeq(std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
TableGenerations computeTableGenerations(const RelAlgNode *ra)
bool setInSituDataIfUnset(const bool is_in_situ_data)
Definition: RenderInfo.cpp:89
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:46
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:70
std::shared_ptr< const RelAlgNode > deserialize_ra_dag(const std::string &query_ra, const Catalog_Namespace::Catalog &cat, RelAlgExecutor *ra_executor, const RenderQueryOptions *render_opts)
bool disallow_in_situ_only_if_final_ED_is_aggregate
Definition: RenderInfo.h:42
const bool find_push_down_candidates
ExecutionResult executeRelAlgQueryWithFilterPushDown(std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
std::vector< RaExecutionDesc > get_execution_descriptors(const RelAlgNode *ra_node)
#define CHECK(condition)
Definition: Logger.h:187
void cleanupPostExecution()
Executor * executor_
Type timer_start()
Definition: measure.h:40
StringDictionaryGenerations computeStringDictionaryGenerations(const RelAlgNode *ra)
+ Here is the call graph for this function:

◆ executeRelAlgQuerySingleStep()

FirstStepExecutionResult RelAlgExecutor::executeRelAlgQuerySingleStep ( const RaExecutionDesc exec_desc,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info 
)

Definition at line 237 of file RelAlgExecutor.cpp.

References CHECK_EQ, ResultSet::executor_, INJECT_TIMER, ExecutionOptions::just_explain, anonymous_namespace{RelAlgExecutor.cpp}::node_is_aggregate(), ResultSet::queue_time_ms_, Reduce, GroupByAndAggregate::shard_count_for_top_groups(), ResultSet::sort(), and Union.

241  {
242  INJECT_TIMER(executeRelAlgQueryStep);
243  auto first_exec_desc = exec_desc;
244  const auto sort = dynamic_cast<const RelSort*>(first_exec_desc.getBody());
245  size_t shard_count{0};
246  if (sort) {
247  const auto source_work_unit = createSortInputWorkUnit(sort, eo.just_explain);
249  source_work_unit.exe_unit, *executor_->getCatalog());
250  if (!shard_count) {
251  // No point in sorting on the leaf, only execute the input to the sort node.
252  CHECK_EQ(size_t(1), sort->inputCount());
253  const auto source = sort->getInput(0);
254  if (sort->collationCount() || node_is_aggregate(source)) {
255  first_exec_desc = RaExecutionDesc(source);
256  }
257  }
258  }
259  std::vector<RaExecutionDesc> first_exec_desc_singleton_list{first_exec_desc};
260  const auto merge_type = (node_is_aggregate(first_exec_desc.getBody()) && !shard_count)
263  // Execute the current step. Keep the existing temporary table map intact, since we may
264  // need to use results from previous query steps.
265  return {executeRelAlgSeq(
266  first_exec_desc_singleton_list, co, eo, render_info, queue_time_ms_, true),
267  merge_type,
268  first_exec_desc.getBody()->getId(),
269  false};
270 }
int64_t queue_time_ms_
#define CHECK_EQ(x, y)
Definition: Logger.h:195
ExecutionResult executeRelAlgSeq(std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
#define INJECT_TIMER(DESC)
Definition: measure.h:91
bool node_is_aggregate(const RelAlgNode *ra)
WorkUnit createSortInputWorkUnit(const RelSort *, const bool just_explain)
Executor * executor_
static size_t shard_count_for_top_groups(const RelAlgExecutionUnit &ra_exe_unit, const Catalog_Namespace::Catalog &catalog)
+ Here is the call graph for this function:

◆ executeRelAlgQueryWithFilterPushDown()

ExecutionResult RelAlgExecutor::executeRelAlgQueryWithFilterPushDown ( std::vector< RaExecutionDesc > &  ed_list,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)

Definition at line 154 of file JoinFilterPushDown.cpp.

References ExecutionOptions::allow_loop_joins, ExecutionOptions::allow_multifrag, ExecutionOptions::dynamic_watchdog_time_limit, executeRelAlgSubQuery(), ExecutionOptions::find_push_down_candidates, ExecutionOptions::gpu_input_mem_limit_percent, ExecutionOptions::jit_debug, ExecutionOptions::just_calcite_explain, ExecutionOptions::just_explain, ExecutionOptions::just_validate, ExecutionOptions::output_columnar_hint, run-benchmark-import::result, ExecutionOptions::with_dynamic_watchdog, and ExecutionOptions::with_watchdog.

159  {
160  // we currently do not fully support filter push down with
161  // multi-step execution and/or with subqueries
162  // TODO(Saman): add proper caching to enable filter push down for all cases
163  if (ed_list.size() > 1 || !subqueries_.empty()) {
164  if (eo.just_calcite_explain) {
165  return ExecutionResult(std::vector<PushedDownFilterInfo>{},
167  }
168  const ExecutionOptions eo_modified{eo.output_columnar_hint,
169  eo.allow_multifrag,
170  eo.just_explain,
171  eo.allow_loop_joins,
172  eo.with_watchdog,
173  eo.jit_debug,
174  eo.just_validate,
177  /*find_push_down_candidates=*/false,
178  /*just_calcite_explain=*/false,
180 
181  // Dispatch the subqueries first
182  for (auto subquery : subqueries_) {
183  // Execute the subquery and cache the result.
184  RelAlgExecutor ra_executor(executor_, cat_);
185  auto result = ra_executor.executeRelAlgSubQuery(subquery.get(), co, eo_modified);
186  subquery->setExecutionResult(std::make_shared<ExecutionResult>(result));
187  }
188  return executeRelAlgSeq(ed_list, co, eo_modified, render_info, queue_time_ms);
189  } else {
190  // Dispatch the subqueries first
191  for (auto subquery : subqueries_) {
192  // Execute the subquery and cache the result.
193  RelAlgExecutor ra_executor(executor_, cat_);
194  auto result = ra_executor.executeRelAlgSubQuery(subquery.get(), co, eo);
195  subquery->setExecutionResult(std::make_shared<ExecutionResult>(result));
196  }
197  return executeRelAlgSeq(ed_list, co, eo, render_info, queue_time_ms);
198  }
199 }
std::vector< std::shared_ptr< RexSubQuery > > subqueries_
ExecutionResult executeRelAlgSeq(std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
const bool allow_multifrag
const bool find_push_down_candidates
const bool just_validate
const bool with_dynamic_watchdog
const double gpu_input_mem_limit_percent
const Catalog_Namespace::Catalog & cat_
const bool output_columnar_hint
const bool just_calcite_explain
const bool allow_loop_joins
const unsigned dynamic_watchdog_time_limit
Executor * executor_
const bool with_watchdog
+ Here is the call graph for this function:

◆ executeRelAlgSeq()

ExecutionResult RelAlgExecutor::executeRelAlgSeq ( std::vector< RaExecutionDesc > &  ed_list,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms,
const bool  with_existing_temp_tables = false 
)

Definition at line 296 of file RelAlgExecutor.cpp.

References CHECK, ResultSet::executor_, INJECT_TIMER, and ExecutionOptions::just_explain.

301  {
303  if (!with_existing_temp_tables) {
304  decltype(temporary_tables_)().swap(temporary_tables_);
305  }
306  decltype(target_exprs_owned_)().swap(target_exprs_owned_);
307  executor_->catalog_ = &cat_;
308  executor_->temporary_tables_ = &temporary_tables_;
309 
310  time(&now_);
311  CHECK(!exec_descs.empty());
312  const auto exec_desc_count = eo.just_explain ? size_t(1) : exec_descs.size();
313 
314  size_t i = 0;
315  for (auto it = exec_descs.begin(); it != exec_descs.end(); ++it, i++) {
316  // only render on the last step
318  it,
319  co,
320  eo,
321  (it == std::prev(exec_descs.end()) ? render_info : nullptr),
322  queue_time_ms);
323  }
324 
325  return exec_descs[exec_desc_count - 1].getResult();
326 }
TemporaryTables temporary_tables_
ExecutionResult executeRelAlgSeq(std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
#define CHECK(condition)
Definition: Logger.h:187
Executor * executor_
void executeRelAlgStep(const size_t step_idx, std::vector< RaExecutionDesc >::iterator exec_desc_itr, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)

◆ executeRelAlgStep()

void RelAlgExecutor::executeRelAlgStep ( const size_t  step_idx,
std::vector< RaExecutionDesc >::iterator  exec_desc_itr,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 356 of file RelAlgExecutor.cpp.

References ExecutionOptions::allow_loop_joins, ExecutionOptions::allow_multifrag, CHECK, ExecutionOptions::dynamic_watchdog_time_limit, ExecutionOptions::find_push_down_candidates, g_cluster, g_skip_intermediate_count, ExecutionOptions::gpu_input_mem_limit_percent, INJECT_TIMER, ExecutionOptions::jit_debug, ExecutionOptions::just_calcite_explain, ExecutionOptions::just_explain, ExecutionOptions::just_validate, ExecutionOptions::output_columnar_hint, WindowProjectNodeContext::reset(), ResultSet::sort(), ExecutionOptions::with_dynamic_watchdog, and ExecutionOptions::with_watchdog.

362  {
365  auto& exec_desc = *exec_desc_itr;
366  const auto body = exec_desc.getBody();
367  if (body->isNop()) {
368  handleNop(exec_desc);
369  return;
370  }
371  const ExecutionOptions eo_work_unit{
373  eo.allow_multifrag,
374  eo.just_explain,
375  eo.allow_loop_joins,
376  eo.with_watchdog && (i == 0 || dynamic_cast<const RelProject*>(body)),
377  eo.jit_debug,
378  eo.just_validate,
384 
385  const auto compound = dynamic_cast<const RelCompound*>(body);
386  if (compound) {
387  if (compound->isDeleteViaSelect()) {
388  executeDeleteViaCompound(compound, co, eo_work_unit, render_info, queue_time_ms);
389  } else if (compound->isUpdateViaSelect()) {
390  executeUpdateViaCompound(compound, co, eo_work_unit, render_info, queue_time_ms);
391  } else {
392  exec_desc.setResult(
393  executeCompound(compound, co, eo_work_unit, render_info, queue_time_ms));
394  if (exec_desc.getResult().isFilterPushDownEnabled()) {
395  return;
396  }
397  addTemporaryTable(-compound->getId(), exec_desc.getResult().getDataPtr());
398  }
399  return;
400  }
401  const auto project = dynamic_cast<const RelProject*>(body);
402  if (project) {
403  if (project->isDeleteViaSelect()) {
404  executeDeleteViaProject(project, co, eo_work_unit, render_info, queue_time_ms);
405  } else if (project->isUpdateViaSelect()) {
406  executeUpdateViaProject(project, co, eo_work_unit, render_info, queue_time_ms);
407  } else {
408  ssize_t prev_count = -1;
409  // Disabling the intermediate count optimization in distributed, as the previous
410  // execution descriptor will likely not hold the aggregated result.
411  if (g_skip_intermediate_count && i > 0 && !g_cluster) {
412  auto& prev_exec_desc = *(exec_desc_itr - 1);
413  if (dynamic_cast<const RelCompound*>(prev_exec_desc.getBody())) {
414  auto prev_desc = prev_exec_desc;
415  const auto& prev_exe_result = prev_desc.getResult();
416  const auto prev_result = prev_exe_result.getRows();
417  if (prev_result) {
418  prev_count = static_cast<ssize_t>(prev_result->rowCount());
419  }
420  }
421  }
422  exec_desc.setResult(executeProject(
423  project, co, eo_work_unit, render_info, queue_time_ms, prev_count));
424  if (exec_desc.getResult().isFilterPushDownEnabled()) {
425  return;
426  }
427  addTemporaryTable(-project->getId(), exec_desc.getResult().getDataPtr());
428  }
429  return;
430  }
431  const auto aggregate = dynamic_cast<const RelAggregate*>(body);
432  if (aggregate) {
433  exec_desc.setResult(
434  executeAggregate(aggregate, co, eo_work_unit, render_info, queue_time_ms));
435  addTemporaryTable(-aggregate->getId(), exec_desc.getResult().getDataPtr());
436  return;
437  }
438  const auto filter = dynamic_cast<const RelFilter*>(body);
439  if (filter) {
440  exec_desc.setResult(
441  executeFilter(filter, co, eo_work_unit, render_info, queue_time_ms));
442  addTemporaryTable(-filter->getId(), exec_desc.getResult().getDataPtr());
443  return;
444  }
445  const auto sort = dynamic_cast<const RelSort*>(body);
446  if (sort) {
447  exec_desc.setResult(executeSort(sort, co, eo_work_unit, render_info, queue_time_ms));
448  if (exec_desc.getResult().isFilterPushDownEnabled()) {
449  return;
450  }
451  addTemporaryTable(-sort->getId(), exec_desc.getResult().getDataPtr());
452  return;
453  }
454  const auto logical_values = dynamic_cast<const RelLogicalValues*>(body);
455  if (logical_values) {
456  exec_desc.setResult(executeLogicalValues(logical_values, eo_work_unit));
457  addTemporaryTable(-logical_values->getId(), exec_desc.getResult().getDataPtr());
458  return;
459  }
460  const auto modify = dynamic_cast<const RelModify*>(body);
461  if (modify) {
462  exec_desc.setResult(executeModify(modify, eo_work_unit));
463  return;
464  }
465  CHECK(false);
466 }
ExecutionResult executeAggregate(const RelAggregate *aggregate, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
ExecutionResult executeProject(const RelProject *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count)
bool g_skip_intermediate_count
ExecutionResult executeModify(const RelModify *modify, const ExecutionOptions &eo)
void addTemporaryTable(const int table_id, const ResultSetPtr &result)
ExecutionResult executeLogicalValues(const RelLogicalValues *, const ExecutionOptions &)
ExecutionResult executeFilter(const RelFilter *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
void handleNop(RaExecutionDesc &ed)
const bool allow_multifrag
const bool find_push_down_candidates
const bool just_validate
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const bool with_dynamic_watchdog
const double gpu_input_mem_limit_percent
const bool output_columnar_hint
const bool just_calcite_explain
void executeDeleteViaCompound(const RelCompound *compound, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
void executeUpdateViaProject(const RelProject *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
ExecutionResult executeSort(const RelSort *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
void executeDeleteViaProject(const RelProject *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
const bool allow_loop_joins
void executeUpdateViaCompound(const RelCompound *compound, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
#define CHECK(condition)
Definition: Logger.h:187
ExecutionResult executeCompound(const RelCompound *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
bool g_cluster
const unsigned dynamic_watchdog_time_limit
void executeRelAlgStep(const size_t step_idx, std::vector< RaExecutionDesc >::iterator exec_desc_itr, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
const bool with_watchdog
+ Here is the call graph for this function:

◆ executeRelAlgSubQuery()

ExecutionResult RelAlgExecutor::executeRelAlgSubQuery ( const RexSubQuery subquery,
const CompilationOptions co,
const ExecutionOptions eo 
)

Definition at line 288 of file RelAlgExecutor.cpp.

References get_execution_descriptors(), and INJECT_TIMER.

Referenced by executeRelAlgQueryNoRetry(), and executeRelAlgQueryWithFilterPushDown().

290  {
292  auto ed_list = get_execution_descriptors(subquery->getRelAlg());
293  return executeRelAlgSeq(ed_list, co, eo, nullptr, 0);
294 }
ExecutionResult executeRelAlgSeq(std::vector< RaExecutionDesc > &ed_list, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
#define INJECT_TIMER(DESC)
Definition: measure.h:91
ExecutionResult executeRelAlgSubQuery(const RexSubQuery *subquery, const CompilationOptions &co, const ExecutionOptions &eo)
std::vector< RaExecutionDesc > get_execution_descriptors(const RelAlgNode *ra_node)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeRelAlgSubSeq()

ExecutionResult RelAlgExecutor::executeRelAlgSubSeq ( std::vector< RaExecutionDesc >::iterator  start_desc,
std::vector< RaExecutionDesc >::iterator  end_desc,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)

Definition at line 328 of file RelAlgExecutor.cpp.

References CHECK, ResultSet::executor_, INJECT_TIMER, and ExecutionOptions::just_explain.

334  {
336  executor_->catalog_ = &cat_;
337  executor_->temporary_tables_ = &temporary_tables_;
338 
339  time(&now_);
340  CHECK(!eo.just_explain);
341 
342  size_t i = 0;
343  for (auto it = start_desc; it != end_desc; ++it, i++) {
344  // only render on the last step
346  it,
347  co,
348  eo,
349  (it == std::prev(end_desc) ? render_info : nullptr),
350  queue_time_ms);
351  }
352 
353  return std::prev(end_desc)->getResult();
354 }
ExecutionResult executeRelAlgSubSeq(std::vector< RaExecutionDesc >::iterator start_desc, std::vector< RaExecutionDesc >::iterator end_desc, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
TemporaryTables temporary_tables_
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
#define CHECK(condition)
Definition: Logger.h:187
Executor * executor_
void executeRelAlgStep(const size_t step_idx, std::vector< RaExecutionDesc >::iterator exec_desc_itr, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)

◆ executeSort()

ExecutionResult RelAlgExecutor::executeSort ( const RelSort sort,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1589 of file RelAlgExecutor.cpp.

References GroupByAndAggregate::addTransientStringLiterals(), CHECK, CHECK_EQ, RelSort::collationCount(), CompilationOptions::device_type_, ResultSet::executor_, anonymous_namespace{RelAlgExecutor.cpp}::first_oe_is_desc(), g_cluster, anonymous_namespace{RelAlgExecutor.cpp}::get_order_entries(), RelAlgNode::getId(), RelAlgNode::getInput(), RelSort::getLimit(), RelSort::getOffset(), RelAlgNode::inputCount(), ExecutionOptions::just_explain, anonymous_namespace{RelAlgExecutor.cpp}::node_is_aggregate(), run-benchmark-import::result, RelAlgNode::setOutputMetainfo(), and use_speculative_top_n().

1593  {
1594  CHECK_EQ(size_t(1), sort->inputCount());
1595  const auto source = sort->getInput(0);
1596  if (dynamic_cast<const RelSort*>(source)) {
1597  throw std::runtime_error("Sort node not supported as input to another sort");
1598  }
1599  const bool is_aggregate = node_is_aggregate(source);
1600  auto it = leaf_results_.find(sort->getId());
1601  if (it != leaf_results_.end()) {
1602  // Add any transient string literals to the sdp on the agg
1603  const auto source_work_unit = createSortInputWorkUnit(sort, eo.just_explain);
1605  source_work_unit.exe_unit, executor_, executor_->row_set_mem_owner_);
1606 
1607  // Handle push-down for LIMIT for multi-node
1608  auto& aggregated_result = it->second;
1609  auto& result_rows = aggregated_result.rs;
1610  const size_t limit = sort->getLimit();
1611  const size_t offset = sort->getOffset();
1612  const auto order_entries = get_order_entries(sort);
1613  if (limit || offset) {
1614  if (!order_entries.empty()) {
1615  result_rows->sort(order_entries, limit + offset);
1616  }
1617  result_rows->dropFirstN(offset);
1618  if (limit) {
1619  result_rows->keepFirstN(limit);
1620  }
1621  }
1622  ExecutionResult result(result_rows, aggregated_result.targets_meta);
1623  sort->setOutputMetainfo(aggregated_result.targets_meta);
1624 
1625  return result;
1626  }
1627  while (true) {
1628  std::list<std::shared_ptr<Analyzer::Expr>> groupby_exprs;
1629  bool is_desc{false};
1630  try {
1631  const auto source_work_unit = createSortInputWorkUnit(sort, eo.just_explain);
1632  is_desc = first_oe_is_desc(source_work_unit.exe_unit.sort_info.order_entries);
1633  groupby_exprs = source_work_unit.exe_unit.groupby_exprs;
1634  auto source_result = executeWorkUnit(source_work_unit,
1635  source->getOutputMetainfo(),
1636  is_aggregate,
1637  co,
1638  eo,
1639  render_info,
1640  queue_time_ms);
1641  if (render_info && render_info->isPotentialInSituRender()) {
1642  return source_result;
1643  }
1644  if (source_result.isFilterPushDownEnabled()) {
1645  return source_result;
1646  }
1647  auto rows_to_sort = source_result.getRows();
1648  if (eo.just_explain) {
1649  return {rows_to_sort, {}};
1650  }
1651  const size_t limit = sort->getLimit();
1652  const size_t offset = sort->getOffset();
1653  if (sort->collationCount() != 0 && !rows_to_sort->definitelyHasNoRows() &&
1654  !use_speculative_top_n(source_work_unit.exe_unit,
1655  rows_to_sort->getQueryMemDesc())) {
1656  rows_to_sort->sort(source_work_unit.exe_unit.sort_info.order_entries,
1657  limit + offset);
1658  }
1659  if (limit || offset) {
1660  if (g_cluster && sort->collationCount() == 0) {
1661  if (offset >= rows_to_sort->rowCount()) {
1662  rows_to_sort->dropFirstN(offset);
1663  } else {
1664  rows_to_sort->keepFirstN(limit + offset);
1665  }
1666  } else {
1667  rows_to_sort->dropFirstN(offset);
1668  if (limit) {
1669  rows_to_sort->keepFirstN(limit);
1670  }
1671  }
1672  }
1673  return {rows_to_sort, source_result.getTargetsMeta()};
1674  } catch (const SpeculativeTopNFailed&) {
1675  CHECK_EQ(size_t(1), groupby_exprs.size());
1676  speculative_topn_blacklist_.add(groupby_exprs.front(), is_desc);
1677  }
1678  }
1679  CHECK(false);
1680  return {std::make_shared<ResultSet>(std::vector<TargetInfo>{},
1681  co.device_type_,
1683  nullptr,
1684  executor_),
1685  {}};
1686 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
size_t collationCount() const
unsigned getId() const
static SpeculativeTopNBlacklist speculative_topn_blacklist_
bool use_speculative_top_n(const RelAlgExecutionUnit &ra_exe_unit, const QueryMemoryDescriptor &query_mem_desc)
std::unordered_map< unsigned, AggregatedResult > leaf_results_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
size_t getOffset() const
bool node_is_aggregate(const RelAlgNode *ra)
const std::shared_ptr< ResultSet > & getRows() const
size_t getLimit() const
const size_t inputCount() const
ExecutionResult executeWorkUnit(const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count=-1)
#define CHECK(condition)
Definition: Logger.h:187
std::list< Analyzer::OrderEntry > get_order_entries(const RelSort *sort)
bool g_cluster
WorkUnit createSortInputWorkUnit(const RelSort *, const bool just_explain)
const RelAlgNode * getInput(const size_t idx) const
void add(const std::shared_ptr< Analyzer::Expr > expr, const bool desc)
Executor * executor_
bool first_oe_is_desc(const std::list< Analyzer::OrderEntry > &order_entries)
+ Here is the call graph for this function:

◆ executeUpdateViaCompound()

void RelAlgExecutor::executeUpdateViaCompound ( const RelCompound compound,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1119 of file RelAlgExecutor.cpp.

References CPU, Default, CompilationOptions::device_type_, ResultSet::executor_, get_table_infos(), ModifyManipulationTarget::getModifiedTableDescriptor(), RelAlgNode::getOutputMetainfo(), ModifyManipulationTarget::getTargetColumns(), logger::INFO, CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), ModifyManipulationTarget::isVarlenUpdateRequired(), ExecutionOptions::just_explain, LOG, and ModifyManipulationTarget::validateTargetColumns().

1123  {
1124  if (!compound->validateTargetColumns(
1126  throw std::runtime_error(
1127  "Unsupported update operation encountered. (None-encoded string column updates "
1128  "are not supported.)");
1129  }
1130 
1131  const auto work_unit = createModifyCompoundWorkUnit(
1132  compound, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1133  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
1134  CompilationOptions co_project = co;
1136 
1137  try {
1139 
1140  UpdateTransactionParameters update_params(compound->getModifiedTableDescriptor(),
1141  compound->getTargetColumns(),
1142  compound->getOutputMetainfo(),
1143  compound->isVarlenUpdateRequired());
1144  auto update_callback = yieldUpdateCallback(update_params);
1145  executor_->executeUpdate(work_unit.exe_unit,
1146  table_infos.front(),
1147  co_project,
1148  eo,
1149  cat_,
1150  executor_->row_set_mem_owner_,
1151  update_callback);
1152  update_params.finalizeTransaction();
1153  } catch (...) {
1154  LOG(INFO) << "Update operation failed.";
1155  throw;
1156  }
1157 }
#define LOG(tag)
Definition: Logger.h:182
bool validateTargetColumns(VALIDATION_FUNCTOR validator) const
TableDescriptor const * getModifiedTableDescriptor() const
static void invalidateCaches()
auto const isVarlenUpdateRequired() const
ColumnNameList const & getTargetColumns() const
const Catalog_Namespace::Catalog & cat_
ColumnValidationFunction yieldColumnValidator(TableDescriptorType const *table_descriptor)
WorkUnit createModifyCompoundWorkUnit(const RelCompound *compound, const SortInfo &sort_info, const bool just_explain)
ExecutorDeviceType device_type_
UpdateCallback yieldUpdateCallback(UpdateTransactionParameters &update_parameters)
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
Executor * executor_
+ Here is the call graph for this function:

◆ executeUpdateViaProject()

void RelAlgExecutor::executeUpdateViaProject ( const RelProject project,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1159 of file RelAlgExecutor.cpp.

References CHECK, CHECK_EQ, CPU, Default, CompilationOptions::device_type_, ResultSet::executor_, get_table_infos(), get_temporary_table(), RelAlgNode::getInput(), ModifyManipulationTarget::getModifiedTableDescriptor(), RelAlgNode::getOutputMetainfo(), ModifyManipulationTarget::getTargetColumns(), logger::INFO, RelAlgNode::inputCount(), CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), RelProject::isSimple(), ModifyManipulationTarget::isVarlenUpdateRequired(), ExecutionOptions::just_explain, LOG, and ModifyManipulationTarget::validateTargetColumns().

1163  {
1164  if (!project->validateTargetColumns(
1166  throw std::runtime_error(
1167  "Unsupported update operation encountered. (None-encoded string column updates "
1168  "are not supported.)");
1169  }
1170 
1171  auto work_unit = createModifyProjectWorkUnit(
1172  project, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1173  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
1174  CompilationOptions co_project = co;
1176 
1177  if (project->isSimple()) {
1178  CHECK_EQ(size_t(1), project->inputCount());
1179  const auto input_ra = project->getInput(0);
1180  if (dynamic_cast<const RelSort*>(input_ra)) {
1181  const auto& input_table =
1182  get_temporary_table(&temporary_tables_, -input_ra->getId());
1183  CHECK(input_table);
1184  work_unit.exe_unit.scan_limit = input_table->rowCount();
1185  }
1186  }
1187 
1188  try {
1190 
1191  UpdateTransactionParameters update_params(project->getModifiedTableDescriptor(),
1192  project->getTargetColumns(),
1193  project->getOutputMetainfo(),
1194  project->isVarlenUpdateRequired());
1195  auto update_callback = yieldUpdateCallback(update_params);
1196  executor_->executeUpdate(work_unit.exe_unit,
1197  table_infos.front(),
1198  co_project,
1199  eo,
1200  cat_,
1201  executor_->row_set_mem_owner_,
1202  update_callback);
1203  update_params.finalizeTransaction();
1204  } catch (...) {
1205  LOG(INFO) << "Update operation failed.";
1206  throw;
1207  }
1208 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define LOG(tag)
Definition: Logger.h:182
TemporaryTables temporary_tables_
bool validateTargetColumns(VALIDATION_FUNCTOR validator) const
TableDescriptor const * getModifiedTableDescriptor() const
static void invalidateCaches()
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:176
auto const isVarlenUpdateRequired() const
WorkUnit createModifyProjectWorkUnit(const RelProject *project, const SortInfo &sort_info, const bool just_explain)
ColumnNameList const & getTargetColumns() const
const Catalog_Namespace::Catalog & cat_
ColumnValidationFunction yieldColumnValidator(TableDescriptorType const *table_descriptor)
ExecutorDeviceType device_type_
UpdateCallback yieldUpdateCallback(UpdateTransactionParameters &update_parameters)
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
const size_t inputCount() const
#define CHECK(condition)
Definition: Logger.h:187
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
const RelAlgNode * getInput(const size_t idx) const
Executor * executor_
+ Here is the call graph for this function:

◆ executeWorkUnit()

ExecutionResult RelAlgExecutor::executeWorkUnit ( const WorkUnit work_unit,
const std::vector< TargetMetaInfo > &  targets_meta,
const bool  is_agg,
const CompilationOptions co_in,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms,
const ssize_t  previous_count = -1 
)
private

Definition at line 1890 of file RelAlgExecutor.cpp.

References GroupByAndAggregate::addTransientStringLiterals(), RelAlgExecutor::WorkUnit::body, anonymous_namespace{RelAlgExecutor.cpp}::build_render_targets(), anonymous_namespace{RelAlgExecutor.cpp}::can_use_bump_allocator(), CHECK, CHECK_EQ, CHECK_GT, anonymous_namespace{RelAlgExecutor.cpp}::compute_output_buffer_size(), CPU, anonymous_namespace{RelAlgExecutor.cpp}::decide_approx_count_distinct_implementation(), RelAlgExecutor::WorkUnit::exe_unit, anonymous_namespace{RelAlgExecutor.cpp}::exe_unit_has_quals(), ResultSet::executor_, ExecutionOptions::find_push_down_candidates, g_big_group_threshold, g_cluster, g_enable_window_functions, get_table_infos(), QueryExecutionError::getErrorCode(), anonymous_namespace{RelAlgExecutor.cpp}::groups_approx_upper_bound(), INJECT_TIMER, anonymous_namespace{RelAlgExecutor.cpp}::is_window_execution_unit(), RenderInfo::isPotentialInSituRender(), ExecutionOptions::just_calcite_explain, ExecutionOptions::just_explain, RelAlgExecutor::WorkUnit::max_groups_buffer_entry_guess, run-benchmark-import::result, RelAlgExecutionUnit::target_exprs, and QueryExecutionError::wasMultifragKernelLaunch().

1898  {
1900 
1901  auto co = co_in;
1902  ColumnCacheMap column_cache;
1903  if (is_window_execution_unit(work_unit.exe_unit)) {
1904  if (g_cluster) {
1905  throw std::runtime_error(
1906  "Window functions support not supported in distributed mode");
1907  }
1909  throw std::runtime_error("Window functions support is disabled");
1910  }
1911  co.device_type_ = ExecutorDeviceType::CPU;
1912  computeWindow(work_unit.exe_unit, co, eo, column_cache, queue_time_ms);
1913  }
1914  if (!eo.just_explain && eo.find_push_down_candidates) {
1915  // find potential candidates:
1916  auto selected_filters = selectFiltersToBePushedDown(work_unit, co, eo);
1917  if (!selected_filters.empty() || eo.just_calcite_explain) {
1918  return ExecutionResult(selected_filters, eo.find_push_down_candidates);
1919  }
1920  }
1921  const auto body = work_unit.body;
1922  CHECK(body);
1923  auto it = leaf_results_.find(body->getId());
1924  if (it != leaf_results_.end()) {
1926  work_unit.exe_unit, executor_, executor_->row_set_mem_owner_);
1927  auto& aggregated_result = it->second;
1928  auto& result_rows = aggregated_result.rs;
1929  ExecutionResult result(result_rows, aggregated_result.targets_meta);
1930  body->setOutputMetainfo(aggregated_result.targets_meta);
1931  if (render_info) {
1932  build_render_targets(*render_info,
1933  work_unit.exe_unit.target_exprs,
1935  targets_meta);
1936  }
1937  return result;
1938  }
1939  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
1940 
1942  work_unit.exe_unit, table_infos, executor_, co.device_type_, target_exprs_owned_);
1943  auto max_groups_buffer_entry_guess = work_unit.max_groups_buffer_entry_guess;
1944  if (is_window_execution_unit(ra_exe_unit)) {
1945  CHECK_EQ(table_infos.size(), size_t(1));
1946  CHECK_EQ(table_infos.front().info.fragments.size(), size_t(1));
1947  max_groups_buffer_entry_guess =
1948  table_infos.front().info.fragments.front().getNumTuples();
1949  ra_exe_unit.scan_limit = max_groups_buffer_entry_guess;
1950  } else if (compute_output_buffer_size(ra_exe_unit) && !isRowidLookup(work_unit)) {
1951  if (previous_count > 0 && !exe_unit_has_quals(ra_exe_unit)) {
1952  ra_exe_unit.scan_limit = static_cast<size_t>(previous_count);
1953  } else {
1954  // TODO(adb): enable bump allocator path for render queries
1955  if (can_use_bump_allocator(ra_exe_unit, co, eo) && !render_info) {
1956  ra_exe_unit.scan_limit = 0;
1957  ra_exe_unit.use_bump_allocator = true;
1958  } else if (!eo.just_explain) {
1959  const auto filter_count_all = getFilteredCountAll(work_unit, true, co, eo);
1960  if (filter_count_all >= 0) {
1961  ra_exe_unit.scan_limit = std::max(filter_count_all, ssize_t(1));
1962  }
1963  }
1964  }
1965  }
1966 
1967  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
1968  co.device_type_,
1970  nullptr,
1971  executor_),
1972  {}};
1973 
1974  auto execute_and_handle_errors =
1975  [&](const auto max_groups_buffer_entry_guess_in,
1976  const bool has_cardinality_estimation) -> ExecutionResult {
1977  // Note that the groups buffer entry guess may be modified during query execution.
1978  // Create a local copy so we can track those changes if we need to attempt a retry due
1979  // to OOM
1980  auto local_groups_buffer_entry_guess = max_groups_buffer_entry_guess_in;
1981  try {
1982  return {executor_->executeWorkUnit(local_groups_buffer_entry_guess,
1983  is_agg,
1984  table_infos,
1985  ra_exe_unit,
1986  co,
1987  eo,
1988  cat_,
1989  executor_->row_set_mem_owner_,
1990  render_info,
1991  has_cardinality_estimation,
1992  column_cache),
1993  targets_meta};
1994  } catch (const QueryExecutionError& e) {
1996  return handleOutOfMemoryRetry(
1997  {ra_exe_unit, work_unit.body, local_groups_buffer_entry_guess},
1998  targets_meta,
1999  is_agg,
2000  co,
2001  eo,
2002  render_info,
2004  queue_time_ms);
2005  }
2006  };
2007 
2008  try {
2009  result = execute_and_handle_errors(
2010  max_groups_buffer_entry_guess,
2012  } catch (const CardinalityEstimationRequired&) {
2013  const auto estimated_groups_buffer_entry_guess =
2014  2 * std::min(groups_approx_upper_bound(table_infos),
2015  getNDVEstimation(work_unit, is_agg, co, eo));
2016  CHECK_GT(estimated_groups_buffer_entry_guess, size_t(0));
2017  result = execute_and_handle_errors(estimated_groups_buffer_entry_guess, true);
2018  }
2019 
2020  result.setQueueTime(queue_time_ms);
2021  if (render_info) {
2023  *render_info, work_unit.exe_unit.target_exprs, target_exprs_owned_, targets_meta);
2024  if (render_info->isPotentialInSituRender()) {
2025  // return an empty result (with the same queue time, and zero render time)
2026  return {
2027  std::make_shared<ResultSet>(queue_time_ms, 0, executor_->row_set_mem_owner_),
2028  {}};
2029  }
2030  }
2031  return result;
2032 }
int32_t getErrorCode() const
Definition: ErrorHandling.h:55
#define CHECK_EQ(x, y)
Definition: Logger.h:195
bool can_use_bump_allocator(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co, const ExecutionOptions &eo)
bool wasMultifragKernelLaunch() const
Definition: ErrorHandling.h:57
std::vector< PushedDownFilterInfo > selectFiltersToBePushedDown(const RelAlgExecutor::WorkUnit &work_unit, const CompilationOptions &co, const ExecutionOptions &eo)
std::unordered_map< unsigned, AggregatedResult > leaf_results_
void build_render_targets(RenderInfo &render_info, const std::vector< Analyzer::Expr *> &work_unit_target_exprs, const std::vector< std::shared_ptr< Analyzer::Expr >> &owned_target_exprs, const std::vector< TargetMetaInfo > &targets_meta)
size_t getNDVEstimation(const WorkUnit &work_unit, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo)
#define CHECK_GT(x, y)
Definition: Logger.h:199
bool is_window_execution_unit(const RelAlgExecutionUnit &ra_exe_unit)
void computeWindow(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co, const ExecutionOptions &eo, ColumnCacheMap &column_cache_map, const int64_t queue_time_ms)
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
bool isPotentialInSituRender() const
Definition: RenderInfo.cpp:55
const bool find_push_down_candidates
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
size_t g_big_group_threshold
Definition: Execute.cpp:90
ExecutionResult handleOutOfMemoryRetry(const RelAlgExecutor::WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const bool was_multifrag_kernel_launch, const int64_t queue_time_ms)
size_t groups_approx_upper_bound(const std::vector< InputTableInfo > &table_infos)
bool g_enable_window_functions
Definition: Execute.cpp:91
ssize_t getFilteredCountAll(const WorkUnit &work_unit, const bool is_agg, const CompilationOptions &co, const ExecutionOptions &eo)
const bool just_calcite_explain
bool isRowidLookup(const WorkUnit &work_unit)
bool exe_unit_has_quals(const RelAlgExecutionUnit ra_exe_unit)
static void handlePersistentError(const int32_t error_code)
bool compute_output_buffer_size(const RelAlgExecutionUnit &ra_exe_unit)
ExecutionResult executeWorkUnit(const WorkUnit &work_unit, const std::vector< TargetMetaInfo > &targets_meta, const bool is_agg, const CompilationOptions &co_in, const ExecutionOptions &eo, RenderInfo *, const int64_t queue_time_ms, const ssize_t previous_count=-1)
#define CHECK(condition)
Definition: Logger.h:187
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
bool g_cluster
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > > > ColumnCacheMap
RelAlgExecutionUnit decide_approx_count_distinct_implementation(const RelAlgExecutionUnit &ra_exe_unit_in, const std::vector< InputTableInfo > &table_infos, const Executor *executor, const ExecutorDeviceType device_type_in, std::vector< std::shared_ptr< Analyzer::Expr >> &target_exprs_owned)
Executor * executor_
+ Here is the call graph for this function:

◆ getErrorMessageFromCode()

std::string RelAlgExecutor::getErrorMessageFromCode ( const int32_t  error_code)
static

Definition at line 2263 of file RelAlgExecutor.cpp.

References Executor::ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED, Executor::ERR_DIV_BY_ZERO, Executor::ERR_INTERRUPTED, Executor::ERR_OUT_OF_CPU_MEM, Executor::ERR_OUT_OF_GPU_MEM, Executor::ERR_OUT_OF_RENDER_MEM, Executor::ERR_OUT_OF_TIME, Executor::ERR_OVERFLOW_OR_UNDERFLOW, Executor::ERR_STREAMING_TOP_N_NOT_SUPPORTED_IN_RENDER_QUERY, Executor::ERR_STRING_CONST_IN_RESULTSET, Executor::ERR_TOO_MANY_LITERALS, Executor::ERR_UNSUPPORTED_SELF_JOIN, and to_string().

Referenced by getNDVEstimation().

2263  {
2264  if (error_code < 0) {
2265  return "Ran out of slots in the query output buffer";
2266  }
2267  switch (error_code) {
2269  return "Division by zero";
2271  return "Query couldn't keep the entire working set of columns in GPU memory";
2273  return "Self joins not supported yet";
2275  return "Not enough host memory to execute the query";
2277  return "Overflow or underflow";
2279  return "Query execution has exceeded the time limit";
2281  return "Query execution has been interrupted";
2283  return "Columnar conversion not supported for variable length types";
2285  return "Too many literals in the query";
2287  return "NONE ENCODED String types are not supported as input result set.";
2289  return "Not enough OpenGL memory to render the query results";
2291  return "Streaming-Top-N not supported in Render Query";
2292  }
2293  return "Other error: code " + std::to_string(error_code);
2294 }
static const int32_t ERR_INTERRUPTED
Definition: Execute.h:1013
static const int32_t ERR_TOO_MANY_LITERALS
Definition: Execute.h:1015
std::string to_string(char const *&&v)
static const int32_t ERR_STRING_CONST_IN_RESULTSET
Definition: Execute.h:1016
static const int32_t ERR_STREAMING_TOP_N_NOT_SUPPORTED_IN_RENDER_QUERY
Definition: Execute.h:1017
static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED
Definition: Execute.h:1014
static const int32_t ERR_DIV_BY_ZERO
Definition: Execute.h:1004
static const int32_t ERR_OUT_OF_RENDER_MEM
Definition: Execute.h:1008
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t uint32_t const int64_t int32_t * error_code
static const int32_t ERR_OVERFLOW_OR_UNDERFLOW
Definition: Execute.h:1010
static const int32_t ERR_OUT_OF_TIME
Definition: Execute.h:1012
static const int32_t ERR_UNSUPPORTED_SELF_JOIN
Definition: Execute.h:1007
static const int32_t ERR_OUT_OF_GPU_MEM
Definition: Execute.h:1005
static const int32_t ERR_OUT_OF_CPU_MEM
Definition: Execute.h:1009
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getExecutor()

Executor * RelAlgExecutor::getExecutor ( ) const

Definition at line 227 of file RelAlgExecutor.cpp.

References ResultSet::executor_.

227  {
228  return executor_;
229 }
Executor * executor_

◆ getFilteredCountAll()

ssize_t RelAlgExecutor::getFilteredCountAll ( const WorkUnit work_unit,
const bool  is_agg,
const CompilationOptions co,
const ExecutionOptions eo 
)
private

Definition at line 2034 of file RelAlgExecutor.cpp.

References CHECK, CHECK_EQ, CHECK_GE, create_count_all_execution_unit(), RelAlgExecutor::WorkUnit::exe_unit, ResultSet::executor_, g_bigint_count, get_table_infos(), kBIGINT, kCOUNT, kINT, LOG, and logger::WARNING.

2037  {
2038  const auto count =
2039  makeExpr<Analyzer::AggExpr>(SQLTypeInfo(g_bigint_count ? kBIGINT : kINT, false),
2040  kCOUNT,
2041  nullptr,
2042  false,
2043  nullptr);
2044  const auto count_all_exe_unit =
2045  create_count_all_execution_unit(work_unit.exe_unit, count);
2046  size_t one{1};
2047  ResultSetPtr count_all_result;
2048  try {
2049  ColumnCacheMap column_cache;
2050  count_all_result =
2051  executor_->executeWorkUnit(one,
2052  is_agg,
2053  get_table_infos(work_unit.exe_unit, executor_),
2054  count_all_exe_unit,
2055  co,
2056  eo,
2057  cat_,
2058  executor_->row_set_mem_owner_,
2059  nullptr,
2060  false,
2061  column_cache);
2062  } catch (const std::exception& e) {
2063  LOG(WARNING) << "Failed to run pre-flight filtered count with error " << e.what();
2064  return -1;
2065  }
2066  const auto count_row = count_all_result->getNextRow(false, false);
2067  CHECK_EQ(size_t(1), count_row.size());
2068  const auto& count_tv = count_row.front();
2069  const auto count_scalar_tv = boost::get<ScalarTargetValue>(&count_tv);
2070  CHECK(count_scalar_tv);
2071  const auto count_ptr = boost::get<int64_t>(count_scalar_tv);
2072  CHECK(count_ptr);
2073  CHECK_GE(*count_ptr, 0);
2074  auto count_upper_bound = static_cast<size_t>(*count_ptr);
2075  return std::max(count_upper_bound, size_t(1));
2076 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
#define LOG(tag)
Definition: Logger.h:182
#define CHECK_GE(x, y)
Definition: Logger.h:200
std::shared_ptr< ResultSet > ResultSetPtr
RelAlgExecutionUnit create_count_all_execution_unit(const RelAlgExecutionUnit &ra_exe_unit, std::shared_ptr< Analyzer::Expr > replacement_target)
const Catalog_Namespace::Catalog & cat_
bool g_bigint_count
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
Definition: sqldefs.h:71
#define CHECK(condition)
Definition: Logger.h:187
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > > > ColumnCacheMap
Definition: sqltypes.h:47
Executor * executor_
+ Here is the call graph for this function:

◆ getFilterSelectivity()

FilterSelectivity RelAlgExecutor::getFilterSelectivity ( const std::vector< std::shared_ptr< Analyzer::Expr >> &  filter_expressions,
const CompilationOptions co,
const ExecutionOptions eo 
)
private

Given a set of filter expressions for a table, it launches a new COUNT query to compute the number of passing rows, and then generates a set of statistics related to those filters. Later, these stats are used to decide whether a filter should be pushed down or not.

Definition at line 57 of file JoinFilterPushDown.cpp.

References CHECK, CHECK_EQ, Default, g_bigint_count, get_table_infos(), kBIGINT, kCOUNT, and kINT.

60  {
61  CollectInputColumnsVisitor input_columns_visitor;
62  std::list<std::shared_ptr<Analyzer::Expr>> quals;
63  std::unordered_set<InputColDescriptor> input_column_descriptors;
64  BindFilterToOutermostVisitor bind_filter_to_outermost;
65  for (const auto& filter_expr : filter_expressions) {
66  input_column_descriptors = input_columns_visitor.aggregateResult(
67  input_column_descriptors, input_columns_visitor.visit(filter_expr.get()));
68  quals.push_back(bind_filter_to_outermost.visit(filter_expr.get()));
69  }
70  std::vector<InputDescriptor> input_descs;
71  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
72  for (const auto& input_col_desc : input_column_descriptors) {
73  if (input_descs.empty()) {
74  input_descs.push_back(input_col_desc.getScanDesc());
75  } else {
76  CHECK(input_col_desc.getScanDesc() == input_descs.front());
77  }
78  input_col_descs.push_back(std::make_shared<const InputColDescriptor>(input_col_desc));
79  }
80  const auto count_expr =
81  makeExpr<Analyzer::AggExpr>(SQLTypeInfo(g_bigint_count ? kBIGINT : kINT, false),
82  kCOUNT,
83  nullptr,
84  false,
85  nullptr);
86  RelAlgExecutionUnit ra_exe_unit{input_descs,
87  input_col_descs,
88  {},
89  quals,
90  {},
91  {},
92  {count_expr.get()},
93  nullptr,
94  {{}, SortAlgorithm::Default, 0, 0},
95  0};
96  size_t one{1};
97  ResultSetPtr filtered_result;
98  const auto table_infos = get_table_infos(input_descs, executor_);
99  CHECK_EQ(size_t(1), table_infos.size());
100  const size_t total_rows_upper_bound = table_infos.front().info.getNumTuplesUpperBound();
101  try {
102  ColumnCacheMap column_cache;
103  filtered_result = executor_->executeWorkUnit(one,
104  true,
105  table_infos,
106  ra_exe_unit,
107  co,
108  eo,
109  cat_,
110  executor_->getRowSetMemoryOwner(),
111  nullptr,
112  false,
113  column_cache);
114  } catch (...) {
115  return {false, 1.0, 0};
116  }
117  const auto count_row = filtered_result->getNextRow(false, false);
118  CHECK_EQ(size_t(1), count_row.size());
119  const auto& count_tv = count_row.front();
120  const auto count_scalar_tv = boost::get<ScalarTargetValue>(&count_tv);
121  CHECK(count_scalar_tv);
122  const auto count_ptr = boost::get<int64_t>(count_scalar_tv);
123  CHECK(count_ptr);
124  const auto rows_passing = *count_ptr;
125  const auto rows_total = std::max(total_rows_upper_bound, size_t(1));
126  return {true, static_cast<float>(rows_passing) / rows_total, total_rows_upper_bound};
127 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
std::shared_ptr< ResultSet > ResultSetPtr
const Catalog_Namespace::Catalog & cat_
bool g_bigint_count
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:823
Definition: sqldefs.h:71
#define CHECK(condition)
Definition: Logger.h:187
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > > > ColumnCacheMap
Definition: sqltypes.h:47
Executor * executor_
+ Here is the call graph for this function:

◆ getNDVEstimation()

size_t RelAlgExecutor::getNDVEstimation ( const WorkUnit work_unit,
const bool  is_agg,
const CompilationOptions co,
const ExecutionOptions eo 
)
private

Definition at line 36 of file CardinalityEstimator.cpp.

References cat_, create_ndv_execution_unit(), Executor::ERR_INTERRUPTED, Executor::ERR_OUT_OF_TIME, RelAlgExecutor::WorkUnit::exe_unit, executor_, get_table_infos(), QueryExecutionError::getErrorCode(), getErrorMessageFromCode(), and UNREACHABLE.

39  {
40  const auto estimator_exe_unit = create_ndv_execution_unit(work_unit.exe_unit);
41  size_t one{1};
42  ColumnCacheMap column_cache;
43  try {
44  const auto estimator_result =
45  executor_->executeWorkUnit(one,
46  is_agg,
47  get_table_infos(work_unit.exe_unit, executor_),
48  estimator_exe_unit,
49  co,
50  eo,
51  cat_,
52  executor_->row_set_mem_owner_,
53  nullptr,
54  false,
55  column_cache);
56  if (!estimator_result) {
57  return 1;
58  }
59  return std::max(estimator_result->getNDVEstimator(), size_t(1));
60  } catch (const QueryExecutionError& e) {
62  throw std::runtime_error("Cardinality estimation query ran out of time");
63  }
65  throw std::runtime_error("Cardinality estimation query has been interrupted");
66  }
67  throw std::runtime_error("Failed to run the cardinality estimation query: " +
69  }
70  UNREACHABLE();
71  return 1;
72 }
int32_t getErrorCode() const
Definition: ErrorHandling.h:55
static const int32_t ERR_INTERRUPTED
Definition: Execute.h:1013
#define UNREACHABLE()
Definition: Logger.h:231
RelAlgExecutionUnit create_ndv_execution_unit(const RelAlgExecutionUnit &ra_exe_unit)
const Catalog_Namespace::Catalog & cat_
static const int32_t ERR_OUT_OF_TIME
Definition: Execute.h:1012
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
static std::string getErrorMessageFromCode(const int32_t error_code)
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > > > ColumnCacheMap
Executor * executor_
+ Here is the call graph for this function:

◆ getSubqueries()

const std::vector<std::shared_ptr<RexSubQuery> >& RelAlgExecutor::getSubqueries ( ) const
inlinenoexcept

Definition at line 112 of file RelAlgExecutor.h.

References error_code.

112  {
113  return subqueries_;
114  };
std::vector< std::shared_ptr< RexSubQuery > > subqueries_

◆ handleNop()

void RelAlgExecutor::handleNop ( RaExecutionDesc ed)
private

Definition at line 468 of file RelAlgExecutor.cpp.

References CHECK, CHECK_EQ, RaExecutionDesc::getBody(), and RaExecutionDesc::setResult().

468  {
469  // just set the result of the previous node as the result of no op
470  auto body = ed.getBody();
471  CHECK(dynamic_cast<const RelAggregate*>(body));
472  CHECK_EQ(size_t(1), body->inputCount());
473  const auto input = body->getInput(0);
474  body->setOutputMetainfo(input->getOutputMetainfo());
475  const auto it = temporary_tables_.find(-input->getId());
476  CHECK(it != temporary_tables_.end());
477  // set up temp table as it could be used by the outer query or next step
478  addTemporaryTable(-body->getId(), it->second);
479 
480  ed.setResult({it->second, input->getOutputMetainfo()});
481 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
TemporaryTables temporary_tables_
void addTemporaryTable(const int table_id, const ResultSetPtr &result)
const RelAlgNode * getBody() const
#define CHECK(condition)
Definition: Logger.h:187
void setResult(const ExecutionResult &result)
+ Here is the call graph for this function:

◆ handleOutOfMemoryRetry()

ExecutionResult RelAlgExecutor::handleOutOfMemoryRetry ( const RelAlgExecutor::WorkUnit work_unit,
const std::vector< TargetMetaInfo > &  targets_meta,
const bool  is_agg,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const bool  was_multifrag_kernel_launch,
const int64_t  queue_time_ms 
)
private

Definition at line 2113 of file RelAlgExecutor.cpp.

References ExecutionOptions::allow_loop_joins, CHECK, CPU, anonymous_namespace{RelAlgExecutor.cpp}::decide_approx_count_distinct_implementation(), CompilationOptions::device_type_, ExecutionOptions::dynamic_watchdog_time_limit, RelAlgExecutor::WorkUnit::exe_unit, ResultSet::executor_, g_enable_watchdog, get_table_infos(), QueryExecutionError::getErrorCode(), ExecutionOptions::gpu_input_mem_limit_percent, CompilationOptions::hoist_literals_, ExecutionOptions::jit_debug, LOG, RelAlgExecutor::WorkUnit::max_groups_buffer_entry_guess, CompilationOptions::opt_level_, ExecutionOptions::output_columnar_hint, run-benchmark-import::result, RenderInfo::setForceNonInSituData(), RelAlgExecutionUnit::use_bump_allocator, VLOG, logger::WARNING, ExecutionOptions::with_dynamic_watchdog, CompilationOptions::with_dynamic_watchdog_, and ExecutionOptions::with_watchdog.

2121  {
2122  // Disable the bump allocator
2123  // Note that this will have basically the same affect as using the bump allocator for
2124  // the kernel per fragment path. Need to unify the max_groups_buffer_entry_guess = 0
2125  // path and the bump allocator path for kernel per fragment execution.
2126  auto ra_exe_unit_in = work_unit.exe_unit;
2127  ra_exe_unit_in.use_bump_allocator = false;
2128 
2129  auto result = ExecutionResult{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
2130  co.device_type_,
2132  nullptr,
2133  executor_),
2134  {}};
2135 
2136  const auto table_infos = get_table_infos(ra_exe_unit_in, executor_);
2137  auto max_groups_buffer_entry_guess = work_unit.max_groups_buffer_entry_guess;
2138  ExecutionOptions eo_no_multifrag{eo.output_columnar_hint,
2139  false,
2140  false,
2141  eo.allow_loop_joins,
2142  eo.with_watchdog,
2143  eo.jit_debug,
2144  false,
2147  false,
2148  false,
2150 
2151  if (was_multifrag_kernel_launch) {
2152  try {
2153  // Attempt to retry using the kernel per fragment path. The smaller input size
2154  // required may allow the entire kernel to execute in GPU memory.
2155  LOG(WARNING) << "Multifrag query ran out of memory, retrying with multifragment "
2156  "kernels disabled.";
2157  const auto ra_exe_unit = decide_approx_count_distinct_implementation(
2158  ra_exe_unit_in, table_infos, executor_, co.device_type_, target_exprs_owned_);
2159  ColumnCacheMap column_cache;
2160  result = {executor_->executeWorkUnit(max_groups_buffer_entry_guess,
2161  is_agg,
2162  table_infos,
2163  ra_exe_unit,
2164  co,
2165  eo_no_multifrag,
2166  cat_,
2167  executor_->row_set_mem_owner_,
2168  nullptr,
2169  true,
2170  column_cache),
2171  targets_meta};
2172  result.setQueueTime(queue_time_ms);
2173  } catch (const QueryExecutionError& e) {
2175  LOG(WARNING) << "Kernel per fragment query ran out of memory, retrying on CPU.";
2176  }
2177  }
2178 
2179  if (render_info) {
2180  render_info->setForceNonInSituData();
2181  }
2182 
2184  co.hoist_literals_,
2185  co.opt_level_,
2187 
2188  // Only reset the group buffer entry guess if we ran out of slots, which
2189  // suggests a
2190  // highly pathological input which prevented a good estimation of distinct tuple
2191  // count. For projection queries, this will force a per-fragment scan limit, which is
2192  // compatible with the CPU path
2193  VLOG(1) << "Resetting max groups buffer entry guess.";
2194  max_groups_buffer_entry_guess = 0;
2195 
2196  int iteration_ctr = -1;
2197  while (true) {
2198  iteration_ctr++;
2200  ra_exe_unit_in, table_infos, executor_, co_cpu.device_type_, target_exprs_owned_);
2201  ColumnCacheMap column_cache;
2202  try {
2203  result = {executor_->executeWorkUnit(max_groups_buffer_entry_guess,
2204  is_agg,
2205  table_infos,
2206  ra_exe_unit,
2207  co_cpu,
2208  eo_no_multifrag,
2209  cat_,
2210  executor_->row_set_mem_owner_,
2211  nullptr,
2212  true,
2213  column_cache),
2214  targets_meta};
2215  } catch (const QueryExecutionError& e) {
2216  // Ran out of slots
2217  if (e.getErrorCode() < 0) {
2218  // Even the conservative guess failed; it should only happen when we group
2219  // by a huge cardinality array. Maybe we should throw an exception instead?
2220  // Such a heavy query is entirely capable of exhausting all the host memory.
2221  CHECK(max_groups_buffer_entry_guess);
2222  // Only allow two iterations of increasingly large entry guesses up to a maximum
2223  // of 512MB per column per kernel
2224  if (g_enable_watchdog || iteration_ctr > 1) {
2225  throw std::runtime_error("Query ran out of output slots in the result");
2226  }
2227  max_groups_buffer_entry_guess *= 2;
2228  LOG(WARNING) << "Query ran out of slots in the output buffer, retrying with max "
2229  "groups buffer entry "
2230  "guess equal to "
2231  << max_groups_buffer_entry_guess;
2232  } else {
2234  }
2235  continue;
2236  }
2237  result.setQueueTime(queue_time_ms);
2238  return result;
2239  }
2240  return result;
2241 }
int32_t getErrorCode() const
Definition: ErrorHandling.h:55
void setForceNonInSituData()
Definition: RenderInfo.cpp:36
#define LOG(tag)
Definition: Logger.h:182
RelAlgExecutionUnit exe_unit
const ExecutorOptLevel opt_level_
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
const bool with_dynamic_watchdog
const double gpu_input_mem_limit_percent
const Catalog_Namespace::Catalog & cat_
const bool output_columnar_hint
ExecutorDeviceType device_type_
static void handlePersistentError(const int32_t error_code)
const size_t max_groups_buffer_entry_guess
const bool allow_loop_joins
#define CHECK(condition)
Definition: Logger.h:187
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults > > > ColumnCacheMap
bool g_enable_watchdog
Definition: Execute.cpp:69
const bool with_dynamic_watchdog_
RelAlgExecutionUnit decide_approx_count_distinct_implementation(const RelAlgExecutionUnit &ra_exe_unit_in, const std::vector< InputTableInfo > &table_infos, const Executor *executor, const ExecutorDeviceType device_type_in, std::vector< std::shared_ptr< Analyzer::Expr >> &target_exprs_owned)
const unsigned dynamic_watchdog_time_limit
Executor * executor_
#define VLOG(n)
Definition: Logger.h:277
const bool with_watchdog
+ Here is the call graph for this function:

◆ handlePersistentError()

void RelAlgExecutor::handlePersistentError ( const int32_t  error_code)
staticprivate

Definition at line 2243 of file RelAlgExecutor.cpp.

References Executor::ERR_OUT_OF_GPU_MEM, Executor::ERR_SPECULATIVE_TOP_OOM, logger::ERROR, g_allow_cpu_retry, logger::INFO, and LOG.

2243  {
2244  LOG(ERROR) << "Query execution failed with error "
2247  throw SpeculativeTopNFailed();
2248  }
2250  // We ran out of GPU memory, this doesn't count as an error if the query is
2251  // allowed to continue on CPU because retry on CPU is explicitly allowed through
2252  // --allow-cpu-retry.
2253  LOG(INFO) << "Query ran out of GPU memory, attempting punt to CPU";
2254  if (!g_allow_cpu_retry) {
2255  throw std::runtime_error(
2256  "Query ran out of GPU memory, unable to automatically retry on CPU");
2257  }
2258  return;
2259  }
2260  throw std::runtime_error(getErrorMessageFromCode(error_code));
2261 }
#define LOG(tag)
Definition: Logger.h:182
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t uint32_t const int64_t int32_t * error_code
static const int32_t ERR_OUT_OF_GPU_MEM
Definition: Execute.h:1005
static const int32_t ERR_SPECULATIVE_TOP_OOM
Definition: Execute.h:1011
bool g_allow_cpu_retry
Definition: Execute.cpp:72
static std::string getErrorMessageFromCode(const int32_t error_code)

◆ isRowidLookup()

bool RelAlgExecutor::isRowidLookup ( const WorkUnit work_unit)
private

Definition at line 2078 of file RelAlgExecutor.cpp.

References CHECK_EQ, RelAlgExecutor::WorkUnit::exe_unit, get_column_descriptor(), Analyzer::BinOper::get_left_operand(), RelAlgExecutionUnit::input_descs, kEQ, and TABLE.

2078  {
2079  const auto& ra_exe_unit = work_unit.exe_unit;
2080  if (ra_exe_unit.input_descs.size() != 1) {
2081  return false;
2082  }
2083  const auto& table_desc = ra_exe_unit.input_descs.front();
2084  if (table_desc.getSourceType() != InputSourceType::TABLE) {
2085  return false;
2086  }
2087  const int table_id = table_desc.getTableId();
2088  for (const auto simple_qual : ra_exe_unit.simple_quals) {
2089  const auto comp_expr =
2090  std::dynamic_pointer_cast<const Analyzer::BinOper>(simple_qual);
2091  if (!comp_expr || comp_expr->get_optype() != kEQ) {
2092  return false;
2093  }
2094  const auto lhs = comp_expr->get_left_operand();
2095  const auto lhs_col = dynamic_cast<const Analyzer::ColumnVar*>(lhs);
2096  if (!lhs_col || !lhs_col->get_table_id() || lhs_col->get_rte_idx()) {
2097  return false;
2098  }
2099  const auto rhs = comp_expr->get_right_operand();
2100  const auto rhs_const = dynamic_cast<const Analyzer::Constant*>(rhs);
2101  if (!rhs_const) {
2102  return false;
2103  }
2104  auto cd = get_column_descriptor(lhs_col->get_column_id(), table_id, cat_);
2105  if (cd->isVirtualCol) {
2106  CHECK_EQ("rowid", cd->columnName);
2107  return true;
2108  }
2109  }
2110  return false;
2111 }
#define CHECK_EQ(x, y)
Definition: Logger.h:195
Definition: sqldefs.h:30
const Catalog_Namespace::Catalog & cat_
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:139
const Expr * get_left_operand() const
Definition: Analyzer.h:435
+ Here is the call graph for this function:

◆ makeJoinQuals()

std::list< std::shared_ptr< Analyzer::Expr > > RelAlgExecutor::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
private

Definition at line 2743 of file RelAlgExecutor.cpp.

References combine_equi_join_conditions(), ResultSet::executor_, anonymous_namespace{RelAlgExecutor.cpp}::get_bitwise_equals_conjunction(), qual_to_conjunctive_form(), anonymous_namespace{RelAlgExecutor.cpp}::reverse_logical_distribution(), anonymous_namespace{RelAlgExecutor.cpp}::rex_to_conjunctive_form(), and RelAlgTranslator::translateScalarRex().

2747  {
2748  QueryFeatureDescriptor query_features;
2749  RelAlgTranslator translator(cat_,
2750  executor_,
2751  input_to_nest_level,
2752  join_types,
2753  now_,
2754  just_explain,
2755  query_features);
2756  const auto rex_condition_cf = rex_to_conjunctive_form(join_condition);
2757  std::list<std::shared_ptr<Analyzer::Expr>> join_condition_quals;
2758  for (const auto rex_condition_component : rex_condition_cf) {
2759  const auto bw_equals = get_bitwise_equals_conjunction(rex_condition_component);
2760  const auto join_condition =
2761  reverse_logical_distribution(translator.translateScalarRex(
2762  bw_equals ? bw_equals.get() : rex_condition_component));
2763  auto join_condition_cf = qual_to_conjunctive_form(join_condition);
2764  join_condition_quals.insert(join_condition_quals.end(),
2765  join_condition_cf.quals.begin(),
2766  join_condition_cf.quals.end());
2767  join_condition_quals.insert(join_condition_quals.end(),
2768  join_condition_cf.simple_quals.begin(),
2769  join_condition_cf.simple_quals.end());
2770  }
2771  return combine_equi_join_conditions(join_condition_quals);
2772 }
std::unique_ptr< const RexOperator > get_bitwise_equals_conjunction(const RexScalar *scalar)
QualsConjunctiveForm qual_to_conjunctive_form(const std::shared_ptr< Analyzer::Expr > qual_expr)
std::vector< const RexScalar * > rex_to_conjunctive_form(const RexScalar *qual_expr)
const Catalog_Namespace::Catalog & cat_
std::shared_ptr< Analyzer::Expr > reverse_logical_distribution(const std::shared_ptr< Analyzer::Expr > &expr)
Executor * executor_
std::list< std::shared_ptr< Analyzer::Expr > > combine_equi_join_conditions(const std::list< std::shared_ptr< Analyzer::Expr >> &join_quals)
+ Here is the call graph for this function:

◆ prepareLeafExecution()

void RelAlgExecutor::prepareLeafExecution ( const AggregatedColRange agg_col_range,
const StringDictionaryGenerations string_dictionary_generations,
const TableGenerations table_generations 
)

Definition at line 272 of file RelAlgExecutor.cpp.

References ResultSet::executor_, g_enable_dynamic_watchdog, ResultSet::queue_time_ms_, timer_start(), and timer_stop().

275  {
276  // capture the lock acquistion time
277  auto clock_begin = timer_start();
279  executor_->resetInterrupt();
280  }
281  queue_time_ms_ = timer_stop(clock_begin);
282  executor_->row_set_mem_owner_ = std::make_shared<RowSetMemoryOwner>();
283  executor_->table_generations_ = table_generations;
284  executor_->agg_col_range_cache_ = agg_col_range;
285  executor_->string_dictionary_generations_ = string_dictionary_generations;
286 }
int64_t queue_time_ms_
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:46
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:70
Executor * executor_
Type timer_start()
Definition: measure.h:40
+ Here is the call graph for this function:

◆ registerSubquery()

void RelAlgExecutor::registerSubquery ( std::shared_ptr< RexSubQuery subquery)
inlinenoexcept

Definition at line 108 of file RelAlgExecutor.h.

Referenced by anonymous_namespace{RelAlgAbstractInterpreter.cpp}::parse_subquery().

108  {
109  subqueries_.push_back(subquery);
110  }
std::vector< std::shared_ptr< RexSubQuery > > subqueries_
+ Here is the caller graph for this function:

◆ selectFiltersToBePushedDown()

std::vector< PushedDownFilterInfo > RelAlgExecutor::selectFiltersToBePushedDown ( const RelAlgExecutor::WorkUnit work_unit,
const CompilationOptions co,
const ExecutionOptions eo 
)
private

Goes through all candidate filters and evaluate whether they pass the selectivity criteria or not.

Definition at line 133 of file JoinFilterPushDown.cpp.

References RelAlgExecutor::WorkUnit::exe_unit, find_push_down_filters(), get_table_infos(), RelAlgExecutionUnit::input_descs, RelAlgExecutor::WorkUnit::input_permutation, RelAlgExecutor::WorkUnit::left_deep_join_input_sizes, and to_gather_info_for_filter_selectivity().

136  {
137  const auto all_push_down_candidates =
139  work_unit.input_permutation,
140  work_unit.left_deep_join_input_sizes);
141  std::vector<PushedDownFilterInfo> selective_push_down_candidates;
142  const auto ti = get_table_infos(work_unit.exe_unit.input_descs, executor_);
144  for (const auto& candidate : all_push_down_candidates) {
145  const auto selectivity = getFilterSelectivity(candidate.filter_expressions, co, eo);
146  if (selectivity.is_valid && selectivity.isFilterSelectiveEnough()) {
147  selective_push_down_candidates.push_back(candidate);
148  }
149  }
150  }
151  return selective_push_down_candidates;
152 }
const std::vector< size_t > left_deep_join_input_sizes
RelAlgExecutionUnit exe_unit
FilterSelectivity getFilterSelectivity(const std::vector< std::shared_ptr< Analyzer::Expr >> &filter_expressions, const CompilationOptions &co, const ExecutionOptions &eo)
const std::vector< InputDescriptor > input_descs
bool to_gather_info_for_filter_selectivity(const std::vector< InputTableInfo > &table_infos)
std::vector< PushedDownFilterInfo > find_push_down_filters(const RelAlgExecutionUnit &ra_exe_unit, const std::vector< size_t > &input_permutation, const std::vector< size_t > &left_deep_join_input_sizes)
const std::vector< size_t > input_permutation
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
Executor * executor_
+ Here is the call graph for this function:

◆ translateLeftDeepJoinFilter()

JoinQualsPerNestingLevel RelAlgExecutor::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 
)
private

Definition at line 2777 of file RelAlgExecutor.cpp.

References CHECK, CHECK_LE, RelLeftDeepInnerJoin::getInnerCondition(), RelLeftDeepInnerJoin::getOuterCondition(), INNER, LEFT, anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), and run-benchmark-import::result.

2781  {
2782  const auto join_types = left_deep_join_types(join);
2783  const auto join_condition_quals = makeJoinQuals(
2784  join->getInnerCondition(), join_types, input_to_nest_level, just_explain);
2785  MaxRangeTableIndexVisitor rte_idx_visitor;
2786  JoinQualsPerNestingLevel result(input_descs.size() - 1);
2787  std::unordered_set<std::shared_ptr<Analyzer::Expr>> visited_quals;
2788  for (size_t rte_idx = 1; rte_idx < input_descs.size(); ++rte_idx) {
2789  const auto outer_condition = join->getOuterCondition(rte_idx);
2790  if (outer_condition) {
2791  result[rte_idx - 1].quals =
2792  makeJoinQuals(outer_condition, join_types, input_to_nest_level, just_explain);
2793  CHECK_LE(rte_idx, join_types.size());
2794  CHECK(join_types[rte_idx - 1] == JoinType::LEFT);
2795  result[rte_idx - 1].type = JoinType::LEFT;
2796  continue;
2797  }
2798  for (const auto qual : join_condition_quals) {
2799  if (visited_quals.count(qual)) {
2800  continue;
2801  }
2802  const auto qual_rte_idx = rte_idx_visitor.visit(qual.get());
2803  if (static_cast<size_t>(qual_rte_idx) <= rte_idx) {
2804  const auto it_ok = visited_quals.emplace(qual);
2805  CHECK(it_ok.second);
2806  result[rte_idx - 1].quals.push_back(qual);
2807  }
2808  }
2809  CHECK_LE(rte_idx, join_types.size());
2810  CHECK(join_types[rte_idx - 1] == JoinType::INNER);
2811  result[rte_idx - 1].type = JoinType::INNER;
2812  }
2813  return result;
2814 }
std::vector< JoinType > left_deep_join_types(const RelLeftDeepInnerJoin *left_deep_join)
std::vector< JoinCondition > JoinQualsPerNestingLevel
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
const RexScalar * getInnerCondition() const
const RexScalar * getOuterCondition(const size_t nesting_level) const
#define CHECK_LE(x, y)
Definition: Logger.h:198
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ PendingExecutionClosure

friend class PendingExecutionClosure
friend

Definition at line 333 of file RelAlgExecutor.h.

Member Data Documentation

◆ cat_

const Catalog_Namespace::Catalog& RelAlgExecutor::cat_
private

Definition at line 323 of file RelAlgExecutor.h.

Referenced by getNDVEstimation().

◆ executor_

Executor* RelAlgExecutor::executor_
private

Definition at line 322 of file RelAlgExecutor.h.

Referenced by getNDVEstimation().

◆ leaf_results_

std::unordered_map<unsigned, AggregatedResult> RelAlgExecutor::leaf_results_
private

Definition at line 328 of file RelAlgExecutor.h.

◆ max_groups_buffer_entry_default_guess

const size_t RelAlgExecutor::max_groups_buffer_entry_default_guess {16384}
staticprivate

Definition at line 331 of file RelAlgExecutor.h.

◆ now_

time_t RelAlgExecutor::now_
private

Definition at line 325 of file RelAlgExecutor.h.

◆ queue_time_ms_

int64_t RelAlgExecutor::queue_time_ms_
private

Definition at line 329 of file RelAlgExecutor.h.

◆ speculative_topn_blacklist_

SpeculativeTopNBlacklist RelAlgExecutor::speculative_topn_blacklist_
staticprivate

Definition at line 330 of file RelAlgExecutor.h.

Referenced by createFilterWorkUnit().

◆ subqueries_

std::vector<std::shared_ptr<RexSubQuery> > RelAlgExecutor::subqueries_
private

Definition at line 327 of file RelAlgExecutor.h.

◆ target_exprs_owned_

std::vector<std::shared_ptr<Analyzer::Expr> > RelAlgExecutor::target_exprs_owned_
private

Definition at line 326 of file RelAlgExecutor.h.

◆ temporary_tables_

TemporaryTables RelAlgExecutor::temporary_tables_
private

Definition at line 324 of file RelAlgExecutor.h.


The documentation for this class was generated from the following files: