OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RelAlgExecutor Class Reference

#include <RelAlgExecutor.h>

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

Classes

struct  TableFunctionWorkUnit
 
struct  WorkUnit
 

Public Types

using TargetInfoList = std::vector< TargetInfo >
 

Public Member Functions

 RelAlgExecutor (Executor *executor, const Catalog_Namespace::Catalog &cat, std::shared_ptr< const query_state::QueryState > query_state=nullptr)
 
 RelAlgExecutor (Executor *executor, const Catalog_Namespace::Catalog &cat, const std::string &query_ra, std::shared_ptr< const query_state::QueryState > query_state=nullptr)
 
 RelAlgExecutor (Executor *executor, const Catalog_Namespace::Catalog &cat, std::unique_ptr< RelAlgDagBuilder > query_dag, std::shared_ptr< const query_state::QueryState > query_state=nullptr)
 
size_t getOuterFragmentCount (const CompilationOptions &co, const ExecutionOptions &eo)
 
ExecutionResult executeRelAlgQuery (const CompilationOptions &co, const ExecutionOptions &eo, const bool just_explain_plan, RenderInfo *render_info)
 
ExecutionResult executeRelAlgQueryWithFilterPushDown (const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
 
void prepareLeafExecution (const AggregatedColRange &agg_col_range, const StringDictionaryGenerations &string_dictionary_generations, const TableGenerations &table_generations)
 
ExecutionResult executeRelAlgSeq (const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
 
ExecutionResult executeRelAlgSubSeq (const RaExecutionSequence &seq, const std::pair< size_t, size_t > interval, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
 
FirstStepExecutionResult executeRelAlgQuerySingleStep (const RaExecutionSequence &seq, const size_t step_idx, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info)
 
void addLeafResult (const unsigned id, const AggregatedResult &result)
 
const RelAlgNodegetRootRelAlgNode () const
 
const std::vector
< std::shared_ptr< RexSubQuery > > & 
getSubqueries () const noexcept
 
const QueryHint getParsedQueryHints () const
 
ExecutionResult executeSimpleInsert (const Analyzer::Query &insert_query)
 
AggregatedColRange computeColRangesCache ()
 
StringDictionaryGenerations computeStringDictionaryGenerations ()
 
TableGenerations computeTableGenerations ()
 
ExecutorgetExecutor () const
 
void cleanupPostExecution ()
 

Static Public Member Functions

static std::string getErrorMessageFromCode (const int32_t error_code)
 

Private Member Functions

ExecutionResult executeRelAlgQueryNoRetry (const CompilationOptions &co, const ExecutionOptions &eo, const bool just_explain_plan, RenderInfo *render_info)
 
void executeRelAlgStep (const RaExecutionSequence &seq, const size_t step_idx, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
void executeUpdate (const RelAlgNode *node, const CompilationOptions &co, const ExecutionOptions &eo, const int64_t queue_time_ms)
 
void executeDelete (const RelAlgNode *node, const CompilationOptions &co, const ExecutionOptions &eo_in, 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)
 
ExecutionResult executeTableFunction (const RelTableFunction *, const CompilationOptions &, const ExecutionOptions &, const int64_t queue_time_ms)
 
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
< 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, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)
 
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)
 
ExecutionResult executeUnion (const RelLogicalUnion *, const RaExecutionSequence &, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
 
WorkUnit createSortInputWorkUnit (const RelSort *, const ExecutionOptions &eo)
 
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 ExecutionOptions &eo)
 
WorkUnit createCompoundWorkUnit (const RelCompound *, const SortInfo &, const ExecutionOptions &eo)
 
WorkUnit createAggregateWorkUnit (const RelAggregate *, const SortInfo &, const bool just_explain)
 
WorkUnit createProjectWorkUnit (const RelProject *, const SortInfo &, const ExecutionOptions &eo)
 
WorkUnit createFilterWorkUnit (const RelFilter *, const SortInfo &, const bool just_explain)
 
WorkUnit createJoinWorkUnit (const RelJoin *, const SortInfo &, const bool just_explain)
 
WorkUnit createUnionWorkUnit (const RelLogicalUnion *, const SortInfo &, const ExecutionOptions &eo)
 
TableFunctionWorkUnit createTableFunctionWorkUnit (const RelTableFunction *table_func, 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)
 
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_
 
std::unique_ptr< RelAlgDagBuilderquery_dag_
 
std::shared_ptr< const
query_state::QueryState
query_state_
 
TemporaryTables temporary_tables_
 
time_t now_
 
std::vector< std::shared_ptr
< Analyzer::Expr > > 
target_exprs_owned_
 
std::unordered_map< unsigned,
AggregatedResult
leaf_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 TableDescriptorType = typename RelAlgExecutorTraits::TableDescriptorType
 
using DeleteVictimOffsetList = std::vector< uint64_t >
 
using UpdateTargetOffsetList = std::vector< uint64_t >
 
using UpdateTargetTypeList = std::vector< TargetMetaInfo >
 
using UpdateTargetColumnNamesList = std::vector< std::string >
 
using FragmenterType = Fragmenter_Namespace::InsertOrderFragmenter
 
using TransactionLog = typename FragmenterType::ModifyTransactionTracker
 
using TransactionLogPtr = std::unique_ptr< TransactionLog >
 
using ColumnValidationFunction = std::function< bool(std::string const &)>
 

Detailed Description

Definition at line 54 of file RelAlgExecutor.h.

Member Typedef Documentation

Definition at line 56 of file RelAlgExecutor.h.

Constructor & Destructor Documentation

RelAlgExecutor::RelAlgExecutor ( Executor executor,
const Catalog_Namespace::Catalog cat,
std::shared_ptr< const query_state::QueryState query_state = nullptr 
)
inline

Definition at line 58 of file RelAlgExecutor.h.

61  : StorageIOFacility(executor, cat)
62  , executor_(executor)
63  , cat_(cat)
64  , query_state_(std::move(query_state))
65  , now_(0)
66  , queue_time_ms_(0) {}
StorageIOFacility(ExecutorType *executor, CatalogType const &catalog)
int64_t queue_time_ms_
const Catalog_Namespace::Catalog & cat_
std::shared_ptr< const query_state::QueryState > query_state_
Executor * executor_
RelAlgExecutor::RelAlgExecutor ( Executor executor,
const Catalog_Namespace::Catalog cat,
const std::string &  query_ra,
std::shared_ptr< const query_state::QueryState query_state = nullptr 
)
inline

Definition at line 68 of file RelAlgExecutor.h.

72  : StorageIOFacility(executor, cat)
73  , executor_(executor)
74  , cat_(cat)
75  , query_dag_(std::make_unique<RelAlgDagBuilder>(query_ra, cat_, nullptr))
76  , query_state_(std::move(query_state))
77  , now_(0)
78  , queue_time_ms_(0) {}
StorageIOFacility(ExecutorType *executor, CatalogType const &catalog)
int64_t queue_time_ms_
const Catalog_Namespace::Catalog & cat_
std::shared_ptr< const query_state::QueryState > query_state_
std::unique_ptr< RelAlgDagBuilder > query_dag_
Executor * executor_
RelAlgExecutor::RelAlgExecutor ( Executor executor,
const Catalog_Namespace::Catalog cat,
std::unique_ptr< RelAlgDagBuilder query_dag,
std::shared_ptr< const query_state::QueryState query_state = nullptr 
)
inline

Definition at line 80 of file RelAlgExecutor.h.

84  : StorageIOFacility(executor, cat)
85  , executor_(executor)
86  , cat_(cat)
87  , query_dag_(std::move(query_dag))
88  , query_state_(std::move(query_state))
89  , now_(0)
90  , queue_time_ms_(0) {}
StorageIOFacility(ExecutorType *executor, CatalogType const &catalog)
int64_t queue_time_ms_
const Catalog_Namespace::Catalog & cat_
std::shared_ptr< const query_state::QueryState > query_state_
std::unique_ptr< RelAlgDagBuilder > query_dag_
Executor * executor_

Member Function Documentation

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

Definition at line 130 of file RelAlgExecutor.h.

References CHECK(), and leaf_results_.

130  {
131  const auto it_ok = leaf_results_.emplace(id, result);
132  CHECK(it_ok.second);
133  }
std::unordered_map< unsigned, AggregatedResult > leaf_results_
CHECK(cgen_state)

+ Here is the call graph for this function:

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

Definition at line 336 of file RelAlgExecutor.h.

References CHECK(), CHECK_LT, and temporary_tables_.

Referenced by executeRelAlgStep(), and handleNop().

336  {
337  CHECK_LT(size_t(0), result->colCount());
338  CHECK_LT(table_id, 0);
339  const auto it_ok = temporary_tables_.emplace(table_id, result);
340  CHECK(it_ok.second);
341  }
TemporaryTables temporary_tables_
CHECK(cgen_state)
#define CHECK_LT(x, y)
Definition: Logger.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAlgExecutor::cleanupPostExecution ( )

Definition at line 394 of file RelAlgExecutor.cpp.

References CHECK(), and executor_.

Referenced by executeRelAlgQueryNoRetry(), and getOuterFragmentCount().

394  {
395  CHECK(executor_);
396  executor_->row_set_mem_owner_ = nullptr;
397  executor_->lit_str_dict_proxy_ = nullptr;
398 }
CHECK(cgen_state)
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AggregatedColRange RelAlgExecutor::computeColRangesCache ( )

Definition at line 374 of file RelAlgExecutor.cpp.

References cat_, executor_, get_physical_inputs(), and getRootRelAlgNode().

374  {
375  AggregatedColRange agg_col_range_cache;
376  const auto phys_inputs = get_physical_inputs(cat_, &getRootRelAlgNode());
377  return executor_->computeColRangesCache(phys_inputs);
378 }
const Catalog_Namespace::Catalog & cat_
const RelAlgNode & getRootRelAlgNode() const
std::unordered_set< PhysicalInput > get_physical_inputs(const RelAlgNode *ra)
Executor * executor_

+ Here is the call graph for this function:

StringDictionaryGenerations RelAlgExecutor::computeStringDictionaryGenerations ( )

Definition at line 380 of file RelAlgExecutor.cpp.

References cat_, executor_, get_physical_inputs(), and getRootRelAlgNode().

380  {
381  const auto phys_inputs = get_physical_inputs(cat_, &getRootRelAlgNode());
382  return executor_->computeStringDictionaryGenerations(phys_inputs);
383 }
const Catalog_Namespace::Catalog & cat_
const RelAlgNode & getRootRelAlgNode() const
std::unordered_set< PhysicalInput > get_physical_inputs(const RelAlgNode *ra)
Executor * executor_

+ Here is the call graph for this function:

TableGenerations RelAlgExecutor::computeTableGenerations ( )

Definition at line 385 of file RelAlgExecutor.cpp.

References executor_, get_physical_table_inputs(), and getRootRelAlgNode().

385  {
386  const auto phys_table_ids = get_physical_table_inputs(&getRootRelAlgNode());
387  return executor_->computeTableGenerations(phys_table_ids);
388 }
const RelAlgNode & getRootRelAlgNode() const
Executor * executor_
std::unordered_set< int > get_physical_table_inputs(const RelAlgNode *ra)

+ Here is the call graph for this function:

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 1694 of file RelAlgExecutor.cpp.

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

Referenced by executeWorkUnit().

1698  {
1699  auto query_infos = get_table_infos(ra_exe_unit.input_descs, executor_);
1700  CHECK_EQ(query_infos.size(), size_t(1));
1701  if (query_infos.front().info.fragments.size() != 1) {
1702  throw std::runtime_error(
1703  "Only single fragment tables supported for window functions for now");
1704  }
1705  if (eo.executor_type == ::ExecutorType::Extern) {
1706  return;
1707  }
1708  query_infos.push_back(query_infos.front());
1709  auto window_project_node_context = WindowProjectNodeContext::create(executor_);
1710  for (size_t target_index = 0; target_index < ra_exe_unit.target_exprs.size();
1711  ++target_index) {
1712  const auto& target_expr = ra_exe_unit.target_exprs[target_index];
1713  const auto window_func = dynamic_cast<const Analyzer::WindowFunction*>(target_expr);
1714  if (!window_func) {
1715  continue;
1716  }
1717  // Always use baseline layout hash tables for now, make the expression a tuple.
1718  const auto& partition_keys = window_func->getPartitionKeys();
1719  std::shared_ptr<Analyzer::Expr> partition_key_tuple;
1720  if (partition_keys.size() > 1) {
1721  partition_key_tuple = makeExpr<Analyzer::ExpressionTuple>(partition_keys);
1722  } else {
1723  if (partition_keys.empty()) {
1724  throw std::runtime_error(
1725  "Empty window function partitions are not supported yet");
1726  }
1727  CHECK_EQ(partition_keys.size(), size_t(1));
1728  partition_key_tuple = partition_keys.front();
1729  }
1730  // Creates a tautology equality with the partition expression on both sides.
1731  const auto partition_key_cond =
1732  makeExpr<Analyzer::BinOper>(kBOOLEAN,
1733  kBW_EQ,
1734  kONE,
1735  partition_key_tuple,
1736  transform_to_inner(partition_key_tuple.get()));
1737  auto context = createWindowFunctionContext(window_func,
1738  partition_key_cond,
1739  ra_exe_unit,
1740  query_infos,
1741  co,
1742  column_cache_map,
1743  executor_->getRowSetMemoryOwner());
1744  context->compute();
1745  window_project_node_context->addWindowFunctionContext(std::move(context),
1746  target_index);
1747  }
1748 }
std::vector< Analyzer::Expr * > target_exprs
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::vector< InputDescriptor > input_descs
static WindowProjectNodeContext * create(Executor *executor)
std::shared_ptr< Analyzer::Expr > transform_to_inner(const Analyzer::Expr *expr)
ExecutorType executor_type
Definition: sqldefs.h:69
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
Definition: sqldefs.h:31
const std::vector< std::shared_ptr< Analyzer::Expr > > & getPartitionKeys() const
Definition: Analyzer.h:1452
Executor * executor_
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, std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3529 of file RelAlgExecutor.cpp.

References cat_, CHECK_EQ, 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(), max_groups_buffer_entry_default_guess, now_, query_state_, RelAlgNode::setOutputMetainfo(), anonymous_namespace{RelAlgExecutor.cpp}::synthesize_inputs(), target_exprs_owned_, anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs(), and anonymous_namespace{RelAlgExecutor.cpp}::translate_targets().

Referenced by createWorkUnit(), and executeAggregate().

3532  {
3533  std::vector<InputDescriptor> input_descs;
3534  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
3535  std::vector<std::shared_ptr<RexInput>> used_inputs_owned;
3536  const auto input_to_nest_level = get_input_nest_levels(aggregate, {});
3537  std::tie(input_descs, input_col_descs, used_inputs_owned) =
3538  get_input_desc(aggregate, input_to_nest_level, {}, cat_);
3539  const auto join_type = get_join_type(aggregate);
3540 
3541  RelAlgTranslator translator(cat_,
3542  query_state_,
3543  executor_,
3544  input_to_nest_level,
3545  {join_type},
3546  now_,
3547  just_explain);
3548  CHECK_EQ(size_t(1), aggregate->inputCount());
3549  const auto source = aggregate->getInput(0);
3550  const auto& in_metainfo = source->getOutputMetainfo();
3551  const auto scalar_sources =
3552  synthesize_inputs(aggregate, size_t(0), in_metainfo, input_to_nest_level);
3553  const auto groupby_exprs = translate_groupby_exprs(aggregate, scalar_sources);
3554  const auto target_exprs = translate_targets(
3555  target_exprs_owned_, scalar_sources, groupby_exprs, aggregate, translator);
3556  const auto targets_meta = get_targets_meta(aggregate, target_exprs);
3557  aggregate->setOutputMetainfo(targets_meta);
3558  return {RelAlgExecutionUnit{input_descs,
3559  input_col_descs,
3560  {},
3561  {},
3562  {},
3563  groupby_exprs,
3564  target_exprs,
3565  nullptr,
3566  sort_info,
3567  0,
3568  false,
3569  std::nullopt,
3570  query_state_},
3571  aggregate,
3573  nullptr};
3574 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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)
static const size_t max_groups_buffer_entry_default_guess
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 RelCompound *compound, const RelAlgTranslator &translator, const ExecutorType executor_type)
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
std::list< std::shared_ptr< Analyzer::Expr > > translate_groupby_exprs(const RelCompound *compound, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources)
const Catalog_Namespace::Catalog & cat_
const RelAlgNode * getInput(const size_t idx) const
JoinType get_join_type(const RelAlgNode *ra)
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr * > &target_exprs)
std::shared_ptr< const query_state::QueryState > query_state_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) 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)
const size_t inputCount() const
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RelAlgExecutor::WorkUnit RelAlgExecutor::createCompoundWorkUnit ( const RelCompound compound,
const SortInfo sort_info,
const ExecutionOptions eo 
)
private

Definition at line 3255 of file RelAlgExecutor.cpp.

References cat_, CHECK_EQ, anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering(), executor_, ExecutionOptions::executor_type, 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(), ExecutionOptions::just_explain, LEFT, anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), max_groups_buffer_entry_default_guess, now_, shared::printContainer(), query_state_, anonymous_namespace{RelAlgExecutor.cpp}::rewrite_quals(), RelAlgNode::setOutputMetainfo(), RelAlgExecutionUnit::simple_quals, RelCompound::size(), target_exprs_owned_, anonymous_namespace{RelAlgExecutor.cpp}::translate_groupby_exprs(), anonymous_namespace{RelAlgExecutor.cpp}::translate_quals(), anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources(), anonymous_namespace{RelAlgExecutor.cpp}::translate_targets(), translateLeftDeepJoinFilter(), and VLOG.

Referenced by createWorkUnit(), executeCompound(), executeDelete(), executeUpdate(), and getOuterFragmentCount().

3258  {
3259  std::vector<InputDescriptor> input_descs;
3260  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
3261  auto input_to_nest_level = get_input_nest_levels(compound, {});
3262  std::tie(input_descs, input_col_descs, std::ignore) =
3263  get_input_desc(compound, input_to_nest_level, {}, cat_);
3264  VLOG(3) << "input_descs=" << shared::printContainer(input_descs);
3265  const auto query_infos = get_table_infos(input_descs, executor_);
3266  CHECK_EQ(size_t(1), compound->inputCount());
3267  const auto left_deep_join =
3268  dynamic_cast<const RelLeftDeepInnerJoin*>(compound->getInput(0));
3269  JoinQualsPerNestingLevel left_deep_join_quals;
3270  const auto join_types = left_deep_join ? left_deep_join_types(left_deep_join)
3271  : std::vector<JoinType>{get_join_type(compound)};
3272  std::vector<size_t> input_permutation;
3273  std::vector<size_t> left_deep_join_input_sizes;
3274  if (left_deep_join) {
3275  left_deep_join_input_sizes = get_left_deep_join_input_sizes(left_deep_join);
3276  left_deep_join_quals = translateLeftDeepJoinFilter(
3277  left_deep_join, input_descs, input_to_nest_level, eo.just_explain);
3279  std::find(join_types.begin(), join_types.end(), JoinType::LEFT) ==
3280  join_types.end()) {
3281  input_permutation = do_table_reordering(input_descs,
3282  input_col_descs,
3283  left_deep_join_quals,
3284  input_to_nest_level,
3285  compound,
3286  query_infos,
3287  executor_);
3288  input_to_nest_level = get_input_nest_levels(compound, input_permutation);
3289  std::tie(input_descs, input_col_descs, std::ignore) =
3290  get_input_desc(compound, input_to_nest_level, input_permutation, cat_);
3291  left_deep_join_quals = translateLeftDeepJoinFilter(
3292  left_deep_join, input_descs, input_to_nest_level, eo.just_explain);
3293  }
3294  }
3295  RelAlgTranslator translator(cat_,
3296  query_state_,
3297  executor_,
3298  input_to_nest_level,
3299  join_types,
3300  now_,
3301  eo.just_explain);
3302  const auto scalar_sources =
3303  translate_scalar_sources(compound, translator, eo.executor_type);
3304  const auto groupby_exprs = translate_groupby_exprs(compound, scalar_sources);
3305  const auto quals_cf = translate_quals(compound, translator);
3306  const auto target_exprs = translate_targets(target_exprs_owned_,
3307  scalar_sources,
3308  groupby_exprs,
3309  compound,
3310  translator,
3311  eo.executor_type);
3312  CHECK_EQ(compound->size(), target_exprs.size());
3313  const RelAlgExecutionUnit exe_unit = {input_descs,
3314  input_col_descs,
3315  quals_cf.simple_quals,
3316  rewrite_quals(quals_cf.quals),
3317  left_deep_join_quals,
3318  groupby_exprs,
3319  target_exprs,
3320  nullptr,
3321  sort_info,
3322  0,
3323  false,
3324  std::nullopt,
3325  query_state_};
3326  auto query_rewriter = std::make_unique<QueryRewriter>(query_infos, executor_);
3327  const auto rewritten_exe_unit = query_rewriter->rewrite(exe_unit);
3328  const auto targets_meta = get_targets_meta(compound, rewritten_exe_unit.target_exprs);
3329  compound->setOutputMetainfo(targets_meta);
3330  return {rewritten_exe_unit,
3331  compound,
3333  std::move(query_rewriter),
3334  input_permutation,
3335  left_deep_join_input_sizes};
3336 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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:107
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
static const size_t max_groups_buffer_entry_default_guess
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 RelCompound *compound, const RelAlgTranslator &translator, const ExecutorType executor_type)
std::vector< JoinCondition > JoinQualsPerNestingLevel
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
bool g_from_table_reordering
Definition: Execute.cpp:81
ExecutorType executor_type
std::list< std::shared_ptr< Analyzer::Expr > > translate_groupby_exprs(const RelCompound *compound, const std::vector< std::shared_ptr< Analyzer::Expr >> &scalar_sources)
const Catalog_Namespace::Catalog & cat_
const RelAlgNode * getInput(const size_t idx) const
JoinType get_join_type(const RelAlgNode *ra)
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr * > &target_exprs)
std::shared_ptr< const query_state::QueryState > query_state_
std::vector< std::shared_ptr< Analyzer::Expr > > translate_scalar_sources(const RA *ra_node, const RelAlgTranslator &translator, const ::ExecutorType executor_type)
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
QualsConjunctiveForm translate_quals(const RelCompound *compound, const RelAlgTranslator &translator)
PrintContainer< CONTAINER > printContainer(CONTAINER &container)
Definition: misc.h:63
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)
const size_t inputCount() const
Executor * executor_
#define VLOG(n)
Definition: Logger.h:291
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< 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:

+ Here is the caller graph for this function:

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

Definition at line 3880 of file RelAlgExecutor.cpp.

References cat_, CHECK_EQ, 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(), max_groups_buffer_entry_default_guess, now_, query_state_, rewrite_expr(), RelAlgNode::setOutputMetainfo(), and target_exprs_owned_.

Referenced by createWorkUnit(), and executeFilter().

3882  {
3883  CHECK_EQ(size_t(1), filter->inputCount());
3884  std::vector<InputDescriptor> input_descs;
3885  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
3886  std::vector<TargetMetaInfo> in_metainfo;
3887  std::vector<std::shared_ptr<RexInput>> used_inputs_owned;
3888  std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned;
3889 
3890  const auto input_to_nest_level = get_input_nest_levels(filter, {});
3891  std::tie(input_descs, input_col_descs, used_inputs_owned) =
3892  get_input_desc(filter, input_to_nest_level, {}, cat_);
3893  const auto join_type = get_join_type(filter);
3894  RelAlgTranslator translator(cat_,
3895  query_state_,
3896  executor_,
3897  input_to_nest_level,
3898  {join_type},
3899  now_,
3900  just_explain);
3901  std::tie(in_metainfo, target_exprs_owned) =
3902  get_inputs_meta(filter, translator, used_inputs_owned, input_to_nest_level);
3903  const auto filter_expr = translator.translateScalarRex(filter->getCondition());
3904  const auto qual = fold_expr(filter_expr.get());
3905  target_exprs_owned_.insert(
3906  target_exprs_owned_.end(), target_exprs_owned.begin(), target_exprs_owned.end());
3907  const auto target_exprs = get_exprs_not_owned(target_exprs_owned);
3908  filter->setOutputMetainfo(in_metainfo);
3909  const auto rewritten_qual = rewrite_expr(qual.get());
3910  return {{input_descs,
3911  input_col_descs,
3912  {},
3913  {rewritten_qual ? rewritten_qual : qual},
3914  {},
3915  {nullptr},
3916  target_exprs,
3917  nullptr,
3918  sort_info,
3919  0},
3920  filter,
3922  nullptr};
3923 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
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
const RexScalar * getCondition() const
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:192
Analyzer::ExpressionPtr rewrite_expr(const Analyzer::Expr *expr)
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
const Catalog_Namespace::Catalog & cat_
JoinType get_join_type(const RelAlgNode *ra)
std::shared_ptr< const query_state::QueryState > query_state_
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) 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)
const size_t inputCount() const
Executor * executor_
std::shared_ptr< Analyzer::Expr > fold_expr(const Analyzer::Expr *expr)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WorkUnit RelAlgExecutor::createJoinWorkUnit ( const RelJoin ,
const SortInfo ,
const bool  just_explain 
)
private
RelAlgExecutor::WorkUnit RelAlgExecutor::createProjectWorkUnit ( const RelProject project,
const SortInfo sort_info,
const ExecutionOptions eo 
)
private

Definition at line 3576 of file RelAlgExecutor.cpp.

References cat_, anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering(), executor_, ExecutionOptions::executor_type, 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(), ExecutionOptions::just_explain, anonymous_namespace{RelAlgExecutor.cpp}::left_deep_join_types(), max_groups_buffer_entry_default_guess, now_, query_state_, RelAlgNode::setOutputMetainfo(), target_exprs_owned_, anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources(), and translateLeftDeepJoinFilter().

Referenced by createWorkUnit(), executeDelete(), executeProject(), executeUpdate(), and getOuterFragmentCount().

3579  {
3580  std::vector<InputDescriptor> input_descs;
3581  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
3582  auto input_to_nest_level = get_input_nest_levels(project, {});
3583  std::tie(input_descs, input_col_descs, std::ignore) =
3584  get_input_desc(project, input_to_nest_level, {}, cat_);
3585  const auto query_infos = get_table_infos(input_descs, executor_);
3586 
3587  const auto left_deep_join =
3588  dynamic_cast<const RelLeftDeepInnerJoin*>(project->getInput(0));
3589  JoinQualsPerNestingLevel left_deep_join_quals;
3590  const auto join_types = left_deep_join ? left_deep_join_types(left_deep_join)
3591  : std::vector<JoinType>{get_join_type(project)};
3592  std::vector<size_t> input_permutation;
3593  std::vector<size_t> left_deep_join_input_sizes;
3594  if (left_deep_join) {
3595  left_deep_join_input_sizes = get_left_deep_join_input_sizes(left_deep_join);
3596  const auto query_infos = get_table_infos(input_descs, executor_);
3597  left_deep_join_quals = translateLeftDeepJoinFilter(
3598  left_deep_join, input_descs, input_to_nest_level, eo.just_explain);
3600  input_permutation = do_table_reordering(input_descs,
3601  input_col_descs,
3602  left_deep_join_quals,
3603  input_to_nest_level,
3604  project,
3605  query_infos,
3606  executor_);
3607  input_to_nest_level = get_input_nest_levels(project, input_permutation);
3608  std::tie(input_descs, input_col_descs, std::ignore) =
3609  get_input_desc(project, input_to_nest_level, input_permutation, cat_);
3610  left_deep_join_quals = translateLeftDeepJoinFilter(
3611  left_deep_join, input_descs, input_to_nest_level, eo.just_explain);
3612  }
3613  }
3614 
3615  RelAlgTranslator translator(cat_,
3616  query_state_,
3617  executor_,
3618  input_to_nest_level,
3619  join_types,
3620  now_,
3621  eo.just_explain);
3622  const auto target_exprs_owned =
3623  translate_scalar_sources(project, translator, eo.executor_type);
3624  target_exprs_owned_.insert(
3625  target_exprs_owned_.end(), target_exprs_owned.begin(), target_exprs_owned.end());
3626  const auto target_exprs = get_exprs_not_owned(target_exprs_owned);
3627 
3628  const RelAlgExecutionUnit exe_unit = {input_descs,
3629  input_col_descs,
3630  {},
3631  {},
3632  left_deep_join_quals,
3633  {nullptr},
3634  target_exprs,
3635  nullptr,
3636  sort_info,
3637  0,
3638  false,
3639  std::nullopt,
3640  query_state_};
3641  auto query_rewriter = std::make_unique<QueryRewriter>(query_infos, executor_);
3642  const auto rewritten_exe_unit = query_rewriter->rewrite(exe_unit);
3643  const auto targets_meta = get_targets_meta(project, rewritten_exe_unit.target_exprs);
3644  project->setOutputMetainfo(targets_meta);
3645  return {rewritten_exe_unit,
3646  project,
3648  std::move(query_rewriter),
3649  input_permutation,
3650  left_deep_join_input_sizes};
3651 }
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:107
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)
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:192
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
bool g_from_table_reordering
Definition: Execute.cpp:81
ExecutorType executor_type
const Catalog_Namespace::Catalog & cat_
const RelAlgNode * getInput(const size_t idx) const
JoinType get_join_type(const RelAlgNode *ra)
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr * > &target_exprs)
std::shared_ptr< const query_state::QueryState > query_state_
std::vector< std::shared_ptr< Analyzer::Expr > > translate_scalar_sources(const RA *ra_node, const RelAlgTranslator &translator, const ::ExecutorType executor_type)
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) 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:

+ Here is the caller graph for this function:

RelAlgExecutor::WorkUnit RelAlgExecutor::createSortInputWorkUnit ( const RelSort sort,
const ExecutionOptions eo 
)
private

Definition at line 2456 of file RelAlgExecutor.cpp.

References CHECK_GT, RelSort::collationCount(), SpeculativeTopNBlacklist::contains(), createWorkUnit(), Default, anonymous_namespace{RelAlgExecutor.cpp}::first_oe_is_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_order_entries(), anonymous_namespace{RelAlgExecutor.cpp}::get_scan_limit(), get_target_info(), RelAlgNode::getInput(), RelSort::getLimit(), RelSort::getOffset(), RelAlgExecutionUnit::input_descs, max_groups_buffer_entry_default_guess, RelAlgNode::setOutputMetainfo(), speculative_topn_blacklist_, SpeculativeTopN, and StreamingTopN.

Referenced by executeRelAlgQuerySingleStep(), and executeSort().

2458  {
2459  const auto source = sort->getInput(0);
2460  const size_t limit = sort->getLimit();
2461  const size_t offset = sort->getOffset();
2462  const size_t scan_limit = sort->collationCount() ? 0 : get_scan_limit(source, limit);
2463  const size_t scan_total_limit =
2464  scan_limit ? get_scan_limit(source, scan_limit + offset) : 0;
2465  size_t max_groups_buffer_entry_guess{
2466  scan_total_limit ? scan_total_limit : max_groups_buffer_entry_default_guess};
2468  const auto order_entries = get_order_entries(sort);
2469  SortInfo sort_info{order_entries, sort_algorithm, limit, offset};
2470  auto source_work_unit = createWorkUnit(source, sort_info, eo);
2471  const auto& source_exe_unit = source_work_unit.exe_unit;
2472 
2473  // we do not allow sorting geometry or array types
2474  for (auto order_entry : order_entries) {
2475  CHECK_GT(order_entry.tle_no, 0); // tle_no is a 1-base index
2476  const auto& te = source_exe_unit.target_exprs[order_entry.tle_no - 1];
2477  const auto& ti = get_target_info(te, false);
2478  if (ti.sql_type.is_geometry() || ti.sql_type.is_array()) {
2479  throw std::runtime_error(
2480  "Columns with geometry or array types cannot be used in an ORDER BY clause.");
2481  }
2482  }
2483 
2484  if (source_exe_unit.groupby_exprs.size() == 1) {
2485  if (!source_exe_unit.groupby_exprs.front()) {
2486  sort_algorithm = SortAlgorithm::StreamingTopN;
2487  } else {
2488  if (speculative_topn_blacklist_.contains(source_exe_unit.groupby_exprs.front(),
2489  first_oe_is_desc(order_entries))) {
2490  sort_algorithm = SortAlgorithm::Default;
2491  }
2492  }
2493  }
2494 
2495  sort->setOutputMetainfo(source->getOutputMetainfo());
2496  // NB: the `body` field of the returned `WorkUnit` needs to be the `source` node,
2497  // not the `sort`. The aggregator needs the pre-sorted result from leaves.
2498  return {RelAlgExecutionUnit{source_exe_unit.input_descs,
2499  std::move(source_exe_unit.input_col_descs),
2500  source_exe_unit.simple_quals,
2501  source_exe_unit.quals,
2502  source_exe_unit.join_quals,
2503  source_exe_unit.groupby_exprs,
2504  source_exe_unit.target_exprs,
2505  nullptr,
2506  {sort_info.order_entries, sort_algorithm, limit, offset},
2507  scan_total_limit,
2508  source_exe_unit.use_bump_allocator,
2509  source_exe_unit.union_all,
2510  source_exe_unit.query_state},
2511  source,
2512  max_groups_buffer_entry_guess,
2513  std::move(source_work_unit.query_rewriter),
2514  source_work_unit.input_permutation,
2515  source_work_unit.left_deep_join_input_sizes};
2516 }
size_t getOffset() const
bool contains(const std::shared_ptr< Analyzer::Expr > expr, const bool desc) const
size_t get_scan_limit(const RelAlgNode *ra, const size_t limit)
TargetInfo get_target_info(const PointerType target_expr, const bool bigint_count)
Definition: TargetInfo.h:78
static SpeculativeTopNBlacklist speculative_topn_blacklist_
static const size_t max_groups_buffer_entry_default_guess
std::vector< InputDescriptor > input_descs
#define CHECK_GT(x, y)
Definition: Logger.h:209
WorkUnit createWorkUnit(const RelAlgNode *, const SortInfo &, const ExecutionOptions &eo)
SortAlgorithm
const RelAlgNode * getInput(const size_t idx) const
size_t collationCount() const
size_t getLimit() const
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
std::list< Analyzer::OrderEntry > get_order_entries(const RelSort *sort)
bool first_oe_is_desc(const std::list< Analyzer::OrderEntry > &order_entries)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RelAlgExecutor::TableFunctionWorkUnit RelAlgExecutor::createTableFunctionWorkUnit ( const RelTableFunction table_func,
const bool  just_explain 
)
private

Definition at line 3765 of file RelAlgExecutor.cpp.

References cat_, CHECK_EQ, CHECK_GT, executor_, table_functions::TableFunctionsFactory::get(), get_exprs_not_owned(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), get_table_infos(), anonymous_namespace{RelAlgExecutor.cpp}::get_targets_meta(), RelTableFunction::getColInputsSize(), RelTableFunction::getFunctionName(), table_functions::TableFunction::getOutputRowParameter(), RelTableFunction::getTableFuncInputAt(), RelAlgNode::inputCount(), Native, now_, query_state_, RelAlgNode::setOutputMetainfo(), TableFunctionExecutionUnit::target_exprs, target_exprs_owned_, to_string(), and anonymous_namespace{RelAlgExecutor.cpp}::translate_scalar_sources().

Referenced by executeTableFunction().

3767  {
3768  std::vector<InputDescriptor> input_descs;
3769  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
3770  auto input_to_nest_level = get_input_nest_levels(table_func, {});
3771  std::tie(input_descs, input_col_descs, std::ignore) =
3772  get_input_desc(table_func, input_to_nest_level, {}, cat_);
3773  const auto query_infos = get_table_infos(input_descs, executor_);
3774  CHECK_EQ(size_t(1), table_func->inputCount());
3775 
3776  RelAlgTranslator translator(
3777  cat_, query_state_, executor_, input_to_nest_level, {}, now_, just_explain);
3778  const auto input_exprs_owned =
3779  translate_scalar_sources(table_func, translator, ::ExecutorType::Native);
3780  target_exprs_owned_.insert(
3781  target_exprs_owned_.end(), input_exprs_owned.begin(), input_exprs_owned.end());
3782  const auto input_exprs = get_exprs_not_owned(input_exprs_owned);
3783 
3784  const auto& table_function_impl =
3786 
3787  std::optional<size_t> output_row_multiplier;
3788  if (table_function_impl.hasUserSpecifiedOutputMultiplier()) {
3789  const auto parameter_index = table_function_impl.getOutputRowParameter();
3790  CHECK_GT(parameter_index, size_t(0));
3791  const auto parameter_expr = table_func->getTableFuncInputAt(parameter_index - 1);
3792  const auto parameter_expr_literal = dynamic_cast<const RexLiteral*>(parameter_expr);
3793  if (!parameter_expr_literal) {
3794  throw std::runtime_error(
3795  "Provided output buffer multiplier parameter is not a literal. Only literal "
3796  "values are supported with output buffer multiplier configured table "
3797  "functions.");
3798  }
3799  int64_t literal_val = parameter_expr_literal->getVal<int64_t>();
3800  if (literal_val < 0) {
3801  throw std::runtime_error("Provided output row multiplier " +
3802  std::to_string(literal_val) +
3803  " is not valid for table functions.");
3804  }
3805  output_row_multiplier = static_cast<size_t>(literal_val);
3806  }
3807 
3808  std::vector<Analyzer::ColumnVar*> input_col_exprs;
3809  for (auto input_expr : input_exprs) {
3810  if (auto col_var = dynamic_cast<Analyzer::ColumnVar*>(input_expr)) {
3811  size_t i = input_col_exprs.size();
3812  input_expr->set_type_info(table_function_impl.getInputSQLType(i));
3813  input_col_exprs.push_back(col_var);
3814  }
3815  }
3816  CHECK_EQ(input_col_exprs.size(), table_func->getColInputsSize());
3817 
3818  std::vector<Analyzer::Expr*> table_func_outputs;
3819  for (size_t i = 0; i < table_function_impl.getOutputsSize(); i++) {
3820  const auto ti = table_function_impl.getOutputSQLType(i);
3821  target_exprs_owned_.push_back(std::make_shared<Analyzer::ColumnVar>(ti, 0, i, -1));
3822  table_func_outputs.push_back(target_exprs_owned_.back().get());
3823  }
3824 
3825  const TableFunctionExecutionUnit exe_unit = {
3826  input_descs,
3827  input_col_descs,
3828  input_exprs, // table function inputs
3829  input_col_exprs, // table function column inputs (duplicates w/ above)
3830  table_func_outputs, // table function projected exprs
3831  output_row_multiplier, // output buffer multiplier
3832  table_func->getFunctionName()};
3833  const auto targets_meta = get_targets_meta(table_func, exe_unit.target_exprs);
3834  table_func->setOutputMetainfo(targets_meta);
3835  return {exe_unit, table_func};
3836 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
static const TableFunction & get(const std::string &name)
std::vector< Analyzer::Expr * > get_exprs_not_owned(const std::vector< std::shared_ptr< Analyzer::Expr >> &exprs)
Definition: Execute.h:192
#define CHECK_GT(x, y)
Definition: Logger.h:209
std::string to_string(char const *&&v)
size_t getColInputsSize() const
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
const Catalog_Namespace::Catalog & cat_
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr * > &target_exprs)
std::shared_ptr< const query_state::QueryState > query_state_
std::vector< std::shared_ptr< Analyzer::Expr > > translate_scalar_sources(const RA *ra_node, const RelAlgTranslator &translator, const ::ExecutorType executor_type)
const RexScalar * getTableFuncInputAt(const size_t idx) const
std::string getFunctionName() const
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
std::vector< Analyzer::Expr * > target_exprs
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)
const size_t inputCount() const
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RelAlgExecutor::WorkUnit RelAlgExecutor::createUnionWorkUnit ( const RelLogicalUnion logical_union,
const SortInfo sort_info,
const ExecutionOptions eo 
)
private

Definition at line 3671 of file RelAlgExecutor.cpp.

References cat_, CHECK(), executor_, get_exprs_not_owned(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_desc(), anonymous_namespace{RelAlgExecutor.cpp}::get_input_nest_levels(), get_table_infos(), anonymous_namespace{RelAlgExecutor.cpp}::get_targets_meta(), RelAlgNode::getInput(), RelAlgNode::getOutputMetainfo(), RelLogicalUnion::isAll(), ExecutionOptions::just_explain, max_groups_buffer_entry_default_guess, now_, shared::printContainer(), query_state_, RelAlgNode::setOutputMetainfo(), anonymous_namespace{RelAlgExecutor.cpp}::target_exprs_for_union(), target_exprs_owned_, RelAlgNode::toString(), and VLOG.

Referenced by executeUnion().

3674  {
3675  std::vector<InputDescriptor> input_descs;
3676  std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
3677  // Map ra input ptr to index (0, 1).
3678  auto input_to_nest_level = get_input_nest_levels(logical_union, {});
3679  std::tie(input_descs, input_col_descs, std::ignore) =
3680  get_input_desc(logical_union, input_to_nest_level, {}, cat_);
3681  const auto query_infos = get_table_infos(input_descs, executor_);
3682  auto const max_num_tuples =
3683  std::accumulate(query_infos.cbegin(),
3684  query_infos.cend(),
3685  size_t(0),
3686  [](auto max, auto const& query_info) {
3687  return std::max(max, query_info.info.getNumTuples());
3688  });
3689 
3690  VLOG(3) << "input_to_nest_level.size()=" << input_to_nest_level.size() << " Pairs are:";
3691  for (auto& pair : input_to_nest_level) {
3692  VLOG(3) << " (" << pair.first->toString() << ", " << pair.second << ')';
3693  }
3694 
3695  RelAlgTranslator translator(
3696  cat_, query_state_, executor_, input_to_nest_level, {}, now_, eo.just_explain);
3697 
3698  auto const input_exprs_owned = target_exprs_for_union(logical_union->getInput(0));
3699  CHECK(!input_exprs_owned.empty())
3700  << "No metainfo found for input node " << logical_union->getInput(0)->toString();
3701  VLOG(3) << "input_exprs_owned.size()=" << input_exprs_owned.size();
3702  for (auto& input_expr : input_exprs_owned) {
3703  VLOG(3) << " " << input_expr->toString();
3704  }
3705  target_exprs_owned_.insert(
3706  target_exprs_owned_.end(), input_exprs_owned.begin(), input_exprs_owned.end());
3707  const auto target_exprs = get_exprs_not_owned(input_exprs_owned);
3708 
3709  VLOG(3) << "input_descs=" << shared::printContainer(input_descs)
3710  << " input_col_descs=" << shared::printContainer(input_col_descs)
3711  << " target_exprs.size()=" << target_exprs.size()
3712  << " max_num_tuples=" << max_num_tuples;
3713 
3714  const RelAlgExecutionUnit exe_unit = {input_descs,
3715  input_col_descs,
3716  {}, // quals_cf.simple_quals,
3717  {}, // rewrite_quals(quals_cf.quals),
3718  {},
3719  {nullptr},
3720  target_exprs,
3721  nullptr,
3722  sort_info,
3723  max_num_tuples,
3724  false,
3725  logical_union->isAll(),
3726  query_state_};
3727  auto query_rewriter = std::make_unique<QueryRewriter>(query_infos, executor_);
3728  const auto rewritten_exe_unit = query_rewriter->rewrite(exe_unit);
3729 
3730  RelAlgNode const* input0 = logical_union->getInput(0);
3731  if (auto const* node = dynamic_cast<const RelCompound*>(input0)) {
3732  logical_union->setOutputMetainfo(
3733  get_targets_meta(node, rewritten_exe_unit.target_exprs));
3734  } else if (auto const* node = dynamic_cast<const RelProject*>(input0)) {
3735  logical_union->setOutputMetainfo(
3736  get_targets_meta(node, rewritten_exe_unit.target_exprs));
3737  } else if (auto const* node = dynamic_cast<const RelLogicalUnion*>(input0)) {
3738  logical_union->setOutputMetainfo(
3739  get_targets_meta(node, rewritten_exe_unit.target_exprs));
3740  } else if (auto const* node = dynamic_cast<const RelAggregate*>(input0)) {
3741  logical_union->setOutputMetainfo(
3742  get_targets_meta(node, rewritten_exe_unit.target_exprs));
3743  } else if (auto const* node = dynamic_cast<const RelScan*>(input0)) {
3744  logical_union->setOutputMetainfo(
3745  get_targets_meta(node, rewritten_exe_unit.target_exprs));
3746  } else if (auto const* node = dynamic_cast<const RelFilter*>(input0)) {
3747  logical_union->setOutputMetainfo(
3748  get_targets_meta(node, rewritten_exe_unit.target_exprs));
3749  } else if (dynamic_cast<const RelSort*>(input0)) {
3750  throw QueryNotSupported("LIMIT and OFFSET are not currently supported with UNION.");
3751  } else {
3752  throw QueryNotSupported("Unsupported input type: " + input0->toString());
3753  }
3754  VLOG(3) << "logical_union->getOutputMetainfo()="
3755  << shared::printContainer(logical_union->getOutputMetainfo())
3756  << " rewritten_exe_unit.input_col_descs.front()->getScanDesc().getTableId()="
3757  << rewritten_exe_unit.input_col_descs.front()->getScanDesc().getTableId();
3758 
3759  return {rewritten_exe_unit,
3760  logical_union,
3762  std::move(query_rewriter)};
3763 }
bool isAll() const
std::unordered_map< const RelAlgNode *, int > get_input_nest_levels(const RelAlgNode *ra_node, const std::vector< size_t > &input_permutation)
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:192
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
CHECK(cgen_state)
const Catalog_Namespace::Catalog & cat_
const RelAlgNode * getInput(const size_t idx) const
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_for_union(RelAlgNode const *input_node)
std::vector< TargetMetaInfo > get_targets_meta(const RA *ra_node, const std::vector< Analyzer::Expr * > &target_exprs)
std::shared_ptr< const query_state::QueryState > query_state_
virtual std::string toString() const =0
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
PrintContainer< CONTAINER > printContainer(CONTAINER &container)
Definition: misc.h:63
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)
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
Executor * executor_
#define VLOG(n)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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,
std::shared_ptr< RowSetMemoryOwner row_set_mem_owner 
)
private

Definition at line 1750 of file RelAlgExecutor.cpp.

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

Referenced by computeWindow().

1757  {
1758  const auto memory_level = co.device_type == ExecutorDeviceType::GPU
1761  const auto join_table_or_err =
1762  executor_->buildHashTableForQualifier(partition_key_cond,
1763  query_infos,
1764  memory_level,
1766  column_cache_map);
1767  if (!join_table_or_err.fail_reason.empty()) {
1768  throw std::runtime_error(join_table_or_err.fail_reason);
1769  }
1770  CHECK(join_table_or_err.hash_table->getHashType() ==
1772  const auto& order_keys = window_func->getOrderKeys();
1773  std::vector<std::shared_ptr<Chunk_NS::Chunk>> chunks_owner;
1774  const size_t elem_count = query_infos.front().info.fragments.front().getNumTuples();
1775  auto context = std::make_unique<WindowFunctionContext>(window_func,
1776  join_table_or_err.hash_table,
1777  elem_count,
1778  co.device_type,
1779  row_set_mem_owner);
1780  for (const auto& order_key : order_keys) {
1781  const auto order_col =
1782  std::dynamic_pointer_cast<const Analyzer::ColumnVar>(order_key);
1783  if (!order_col) {
1784  throw std::runtime_error("Only order by columns supported for now");
1785  }
1786  const int8_t* column;
1787  size_t join_col_elem_count;
1788  std::tie(column, join_col_elem_count) =
1790  *order_col,
1791  query_infos.front().info.fragments.front(),
1792  memory_level,
1793  0,
1794  nullptr,
1795  chunks_owner,
1796  column_cache_map);
1797  CHECK_EQ(join_col_elem_count, elem_count);
1798  context->addOrderColumn(column, order_col.get(), chunks_owner);
1799  }
1800  return context;
1801 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
const std::vector< std::shared_ptr< Analyzer::Expr > > & getOrderKeys() const
Definition: Analyzer.h:1456
CHECK(cgen_state)
ExecutorDeviceType device_type
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, DeviceAllocator *device_allocator, std::vector< std::shared_ptr< Chunk_NS::Chunk >> &chunks_owner, ColumnCacheMap &column_cache)
Gets one chunk&#39;s pointer and element count on either CPU or GPU.
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

RelAlgExecutor::WorkUnit RelAlgExecutor::createWorkUnit ( const RelAlgNode node,
const SortInfo sort_info,
const ExecutionOptions eo 
)
private

Definition at line 3083 of file RelAlgExecutor.cpp.

References createAggregateWorkUnit(), createCompoundWorkUnit(), createFilterWorkUnit(), createProjectWorkUnit(), logger::FATAL, ExecutionOptions::just_explain, LOG, and RelAlgNode::toString().

Referenced by createSortInputWorkUnit().

3085  {
3086  const auto compound = dynamic_cast<const RelCompound*>(node);
3087  if (compound) {
3088  return createCompoundWorkUnit(compound, sort_info, eo);
3089  }
3090  const auto project = dynamic_cast<const RelProject*>(node);
3091  if (project) {
3092  return createProjectWorkUnit(project, sort_info, eo);
3093  }
3094  const auto aggregate = dynamic_cast<const RelAggregate*>(node);
3095  if (aggregate) {
3096  return createAggregateWorkUnit(aggregate, sort_info, eo.just_explain);
3097  }
3098  const auto filter = dynamic_cast<const RelFilter*>(node);
3099  if (filter) {
3100  return createFilterWorkUnit(filter, sort_info, eo.just_explain);
3101  }
3102  LOG(FATAL) << "Unhandled node type: " << node->toString();
3103  return {};
3104 }
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const ExecutionOptions &eo)
WorkUnit createAggregateWorkUnit(const RelAggregate *, const SortInfo &, const bool just_explain)
#define LOG(tag)
Definition: Logger.h:188
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const ExecutionOptions &eo)
virtual std::string toString() const =0
WorkUnit createFilterWorkUnit(const RelFilter *, const SortInfo &, const bool just_explain)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAlgExecutor::eraseFromTemporaryTables ( const int  table_id)
inlineprivate

Definition at line 343 of file RelAlgExecutor.h.

References temporary_tables_.

343 { temporary_tables_.erase(table_id); }
TemporaryTables temporary_tables_
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 1565 of file RelAlgExecutor.cpp.

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

Referenced by executeRelAlgStep().

1569  {
1570  auto timer = DEBUG_TIMER(__func__);
1571  const auto work_unit = createAggregateWorkUnit(
1572  aggregate, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1573  return executeWorkUnit(work_unit,
1574  aggregate->getOutputMetainfo(),
1575  true,
1576  co,
1577  eo,
1578  render_info,
1579  queue_time_ms);
1580 }
WorkUnit createAggregateWorkUnit(const RelAggregate *, const SortInfo &, 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)
#define DEBUG_TIMER(name)
Definition: Logger.h:313
const std::vector< TargetMetaInfo > & getOutputMetainfo() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1547 of file RelAlgExecutor.cpp.

References createCompoundWorkUnit(), DEBUG_TIMER, Default, executeWorkUnit(), RelAlgNode::getOutputMetainfo(), and RelCompound::isAggregate().

Referenced by executeRelAlgStep().

1551  {
1552  auto timer = DEBUG_TIMER(__func__);
1553  const auto work_unit =
1554  createCompoundWorkUnit(compound, {{}, SortAlgorithm::Default, 0, 0}, eo);
1555  CompilationOptions co_compound = co;
1556  return executeWorkUnit(work_unit,
1557  compound->getOutputMetainfo(),
1558  compound->isAggregate(),
1559  co_compound,
1560  eo,
1561  render_info,
1562  queue_time_ms);
1563 }
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const ExecutionOptions &eo)
bool isAggregate() 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 DEBUG_TIMER(name)
Definition: Logger.h:313
const std::vector< TargetMetaInfo > & getOutputMetainfo() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAlgExecutor::executeDelete ( const RelAlgNode node,
const CompilationOptions co,
const ExecutionOptions eo_in,
const int64_t  queue_time_ms 
)
private

Definition at line 1462 of file RelAlgExecutor.cpp.

References cat_, CHECK(), CHECK_EQ, createCompoundWorkUnit(), createProjectWorkUnit(), DEBUG_TIMER, Default, executor_, CompilationOptions::filter_on_deleted_column, get_table_infos(), get_temporary_table(), Catalog_Namespace::Catalog::getDeletedColumn(), CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), CompilationOptions::makeCpuOnly(), ExecutionOptions::output_columnar_hint, table_is_temporary(), temporary_tables_, and StorageIOFacility< RelAlgExecutorTraits >::yieldDeleteCallback().

Referenced by executeRelAlgStep().

1465  {
1466  CHECK(node);
1467  auto timer = DEBUG_TIMER(__func__);
1468 
1470 
1471  auto execute_delete_for_node = [this, &co, &eo_in](const auto node,
1472  auto& work_unit,
1473  const bool is_aggregate) {
1474  auto* table_descriptor = node->getModifiedTableDescriptor();
1475  CHECK(table_descriptor);
1476  if (!table_descriptor->hasDeletedCol) {
1477  throw std::runtime_error(
1478  "DELETE only supported on tables with the vacuum attribute set to 'delayed'");
1479  }
1480 
1481  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
1482 
1483  auto execute_delete_ra_exe_unit =
1484  [this, &table_infos, &table_descriptor, &eo_in, &co](const auto& exe_unit,
1485  const bool is_aggregate) {
1486  DeleteTransactionParameters delete_params(table_is_temporary(table_descriptor));
1487  auto delete_callback = yieldDeleteCallback(delete_params);
1489 
1490  auto eo = eo_in;
1491  if (delete_params.tableIsTemporary()) {
1492  eo.output_columnar_hint = true;
1493  co_delete.filter_on_deleted_column =
1494  false; // project the entire delete column for columnar update
1495  } else {
1496  CHECK_EQ(exe_unit.target_exprs.size(), size_t(1));
1497  }
1498 
1499  executor_->executeUpdate(exe_unit,
1500  table_infos,
1501  co_delete,
1502  eo,
1503  cat_,
1504  executor_->row_set_mem_owner_,
1505  delete_callback,
1506  is_aggregate);
1507  delete_params.finalizeTransaction();
1508  };
1509 
1510  if (table_is_temporary(table_descriptor)) {
1511  auto query_rewrite = std::make_unique<QueryRewriter>(table_infos, executor_);
1512  auto cd = cat_.getDeletedColumn(table_descriptor);
1513  CHECK(cd);
1514  auto delete_column_expr = makeExpr<Analyzer::ColumnVar>(
1515  cd->columnType, table_descriptor->tableId, cd->columnId, 0);
1516  const auto rewritten_exe_unit =
1517  query_rewrite->rewriteColumnarDelete(work_unit.exe_unit, delete_column_expr);
1518  execute_delete_ra_exe_unit(rewritten_exe_unit, is_aggregate);
1519  } else {
1520  execute_delete_ra_exe_unit(work_unit.exe_unit, is_aggregate);
1521  }
1522  };
1523 
1524  if (auto compound = dynamic_cast<const RelCompound*>(node)) {
1525  const auto work_unit =
1526  createCompoundWorkUnit(compound, {{}, SortAlgorithm::Default, 0, 0}, eo_in);
1527  execute_delete_for_node(compound, work_unit, compound->isAggregate());
1528  } else if (auto project = dynamic_cast<const RelProject*>(node)) {
1529  auto work_unit =
1530  createProjectWorkUnit(project, {{}, SortAlgorithm::Default, 0, 0}, eo_in);
1531  if (project->isSimple()) {
1532  CHECK_EQ(size_t(1), project->inputCount());
1533  const auto input_ra = project->getInput(0);
1534  if (dynamic_cast<const RelSort*>(input_ra)) {
1535  const auto& input_table =
1536  get_temporary_table(&temporary_tables_, -input_ra->getId());
1537  CHECK(input_table);
1538  work_unit.exe_unit.scan_limit = input_table->rowCount();
1539  }
1540  }
1541  execute_delete_for_node(project, work_unit, false);
1542  } else {
1543  throw std::runtime_error("Unsupported parent node for delete: " + node->toString());
1544  }
1545 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const ExecutionOptions &eo)
const ColumnDescriptor * getDeletedColumn(const TableDescriptor *td) const
Definition: Catalog.cpp:2742
TemporaryTables temporary_tables_
static void invalidateCaches()
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const ExecutionOptions &eo)
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:157
static CompilationOptions makeCpuOnly(const CompilationOptions &in)
CHECK(cgen_state)
UpdateCallback yieldDeleteCallback(DeleteTransactionParameters &delete_parameters)
const Catalog_Namespace::Catalog & cat_
bool table_is_temporary(const TableDescriptor *const td)
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
#define DEBUG_TIMER(name)
Definition: Logger.h:313
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 1803 of file RelAlgExecutor.cpp.

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

Referenced by executeRelAlgStep().

1807  {
1808  auto timer = DEBUG_TIMER(__func__);
1809  const auto work_unit =
1810  createFilterWorkUnit(filter, {{}, SortAlgorithm::Default, 0, 0}, eo.just_explain);
1811  return executeWorkUnit(
1812  work_unit, filter->getOutputMetainfo(), false, co, eo, render_info, queue_time_ms);
1813 }
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 DEBUG_TIMER(name)
Definition: Logger.h:313
const std::vector< TargetMetaInfo > & getOutputMetainfo() const
WorkUnit createFilterWorkUnit(const RelFilter *, const SortInfo &, const bool just_explain)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1868 of file RelAlgExecutor.cpp.

References CHECK(), CHECK_EQ, CHECK_GE, CPU, DEBUG_TIMER, EMPTY_KEY_64, executor_, RelLogicalValues::getNumRows(), RelLogicalValues::getRowsSize(), RelLogicalValues::getTupleType(), RelLogicalValues::getValueAt(), RelLogicalValues::hasRows(), inline_int_null_val(), ExecutionOptions::just_explain, kBIGINT, kCOUNT, kNULLT, Projection, query_mem_desc, RelAlgNode::setOutputMetainfo(), RelLogicalValues::size(), and RelAlgTranslator::translateLiteral().

Referenced by executeRelAlgStep().

1870  {
1871  auto timer = DEBUG_TIMER(__func__);
1872  if (eo.just_explain) {
1873  throw std::runtime_error("EXPLAIN not supported for LogicalValues");
1874  }
1875 
1877  logical_values->getNumRows(),
1879  /*is_table_function=*/false);
1880 
1881  auto tuple_type = logical_values->getTupleType();
1882  for (size_t i = 0; i < tuple_type.size(); ++i) {
1883  auto& target_meta_info = tuple_type[i];
1884  if (target_meta_info.get_type_info().is_varlen()) {
1885  throw std::runtime_error("Variable length types not supported in VALUES yet.");
1886  }
1887  if (target_meta_info.get_type_info().get_type() == kNULLT) {
1888  // replace w/ bigint
1889  tuple_type[i] =
1890  TargetMetaInfo(target_meta_info.get_resname(), SQLTypeInfo(kBIGINT, false));
1891  }
1892  query_mem_desc.addColSlotInfo(
1893  {std::make_tuple(tuple_type[i].get_type_info().get_size(), 8)});
1894  }
1895  logical_values->setOutputMetainfo(tuple_type);
1896 
1897  std::vector<TargetInfo> target_infos;
1898  for (const auto& tuple_type_component : tuple_type) {
1899  target_infos.emplace_back(TargetInfo{false,
1900  kCOUNT,
1901  tuple_type_component.get_type_info(),
1902  SQLTypeInfo(kNULLT, false),
1903  false,
1904  false});
1905  }
1906  auto rs = std::make_shared<ResultSet>(target_infos,
1909  executor_->getRowSetMemoryOwner(),
1910  executor_);
1911 
1912  if (logical_values->hasRows()) {
1913  CHECK_EQ(logical_values->getRowsSize(), logical_values->size());
1914 
1915  auto storage = rs->allocateStorage();
1916  auto buff = storage->getUnderlyingBuffer();
1917 
1918  for (size_t i = 0; i < logical_values->getNumRows(); i++) {
1919  std::vector<std::shared_ptr<Analyzer::Expr>> row_literals;
1920  int8_t* ptr = buff + i * query_mem_desc.getRowSize();
1921 
1922  for (size_t j = 0; j < logical_values->getRowsSize(); j++) {
1923  auto rex_literal =
1924  dynamic_cast<const RexLiteral*>(logical_values->getValueAt(i, j));
1925  CHECK(rex_literal);
1926  const auto expr = RelAlgTranslator::translateLiteral(rex_literal);
1927  const auto constant = std::dynamic_pointer_cast<Analyzer::Constant>(expr);
1928  CHECK(constant);
1929 
1930  if (constant->get_is_null()) {
1931  CHECK(!target_infos[j].sql_type.is_varlen());
1932  *reinterpret_cast<int64_t*>(ptr) =
1933  inline_int_null_val(target_infos[j].sql_type);
1934  } else {
1935  const auto ti = constant->get_type_info();
1936  const auto datum = constant->get_constval();
1937 
1938  // Initialize the entire 8-byte slot
1939  *reinterpret_cast<int64_t*>(ptr) = EMPTY_KEY_64;
1940 
1941  const auto sz = ti.get_size();
1942  CHECK_GE(sz, int(0));
1943  std::memcpy(ptr, &datum, sz);
1944  }
1945  ptr += 8;
1946  }
1947  }
1948  }
1949  return {rs, tuple_type};
1950 }
bool hasRows() const
#define CHECK_EQ(x, y)
Definition: Logger.h:205
#define EMPTY_KEY_64
size_t size() const override
size_t getNumRows() const
const std::vector< TargetMetaInfo > getTupleType() const
#define CHECK_GE(x, y)
Definition: Logger.h:210
size_t getRowsSize() const
static std::shared_ptr< Analyzer::Expr > translateLiteral(const RexLiteral *)
CHECK(cgen_state)
Definition: sqldefs.h:76
const RexScalar * getValueAt(const size_t row_idx, const size_t col_idx) const
#define DEBUG_TIMER(name)
Definition: Logger.h:313
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 2000 of file RelAlgExecutor.cpp.

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

Referenced by executeRelAlgStep().

2001  {
2002  auto timer = DEBUG_TIMER(__func__);
2003  if (eo.just_explain) {
2004  throw std::runtime_error("EXPLAIN not supported for ModifyTable");
2005  }
2006 
2007  auto rs = std::make_shared<ResultSet>(TargetInfoList{},
2010  executor_->getRowSetMemoryOwner(),
2011  executor_);
2012 
2013  std::vector<TargetMetaInfo> empty_targets;
2014  return {rs, empty_targets};
2015 }
std::vector< TargetInfo > TargetInfoList
#define DEBUG_TIMER(name)
Definition: Logger.h:313
Executor * executor_

+ Here is the caller graph for this function:

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 1595 of file RelAlgExecutor.cpp.

References CHECK(), CHECK_EQ, CPU, createProjectWorkUnit(), DEBUG_TIMER, Default, executeWorkUnit(), get_temporary_table(), RelAlgNode::getInput(), RelAlgNode::getOutputMetainfo(), RelAlgNode::inputCount(), RelProject::isSimple(), and temporary_tables_.

Referenced by executeRelAlgStep().

1600  {
1601  auto timer = DEBUG_TIMER(__func__);
1602  auto work_unit = createProjectWorkUnit(project, {{}, SortAlgorithm::Default, 0, 0}, eo);
1603  CompilationOptions co_project = co;
1604  if (project->isSimple()) {
1605  CHECK_EQ(size_t(1), project->inputCount());
1606  const auto input_ra = project->getInput(0);
1607  if (dynamic_cast<const RelSort*>(input_ra)) {
1608  co_project.device_type = ExecutorDeviceType::CPU;
1609  const auto& input_table =
1610  get_temporary_table(&temporary_tables_, -input_ra->getId());
1611  CHECK(input_table);
1612  work_unit.exe_unit.scan_limit =
1613  std::min(input_table->getLimit(), input_table->rowCount());
1614  }
1615  }
1616  return executeWorkUnit(work_unit,
1617  project->getOutputMetainfo(),
1618  false,
1619  co_project,
1620  eo,
1621  render_info,
1622  queue_time_ms,
1623  previous_count);
1624 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const ExecutionOptions &eo)
TemporaryTables temporary_tables_
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:157
CHECK(cgen_state)
const RelAlgNode * getInput(const size_t idx) const
bool isSimple() 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 DEBUG_TIMER(name)
Definition: Logger.h:313
const size_t inputCount() const
const std::vector< TargetMetaInfo > & getOutputMetainfo() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExecutionResult RelAlgExecutor::executeRelAlgQuery ( const CompilationOptions co,
const ExecutionOptions eo,
const bool  just_explain_plan,
RenderInfo render_info 
)

Definition at line 152 of file RelAlgExecutor.cpp.

References CHECK(), DEBUG_TIMER, executeRelAlgQueryNoRetry(), g_allow_cpu_retry, logger::INFO, INJECT_TIMER, LOG, CompilationOptions::makeCpuOnly(), query_dag_, and RenderInfo::setForceNonInSituData().

155  {
156  CHECK(query_dag_);
157  auto timer = DEBUG_TIMER(__func__);
159 
160  try {
161  return executeRelAlgQueryNoRetry(co, eo, just_explain_plan, render_info);
162  } catch (const QueryMustRunOnCpu&) {
163  if (!g_allow_cpu_retry) {
164  throw;
165  }
166  }
167  LOG(INFO) << "Query unable to run in GPU mode, retrying on CPU";
168  auto co_cpu = CompilationOptions::makeCpuOnly(co);
169 
170  if (render_info) {
171  render_info->setForceNonInSituData();
172  }
173  return executeRelAlgQueryNoRetry(co_cpu, eo, just_explain_plan, render_info);
174 }
void setForceNonInSituData()
Definition: RenderInfo.cpp:45
#define LOG(tag)
Definition: Logger.h:188
static CompilationOptions makeCpuOnly(const CompilationOptions &in)
CHECK(cgen_state)
#define INJECT_TIMER(DESC)
Definition: measure.h:91
ExecutionResult executeRelAlgQueryNoRetry(const CompilationOptions &co, const ExecutionOptions &eo, const bool just_explain_plan, RenderInfo *render_info)
ExecutionResult executeRelAlgQuery(const CompilationOptions &co, const ExecutionOptions &eo, const bool just_explain_plan, RenderInfo *render_info)
#define DEBUG_TIMER(name)
Definition: Logger.h:313
std::unique_ptr< RelAlgDagBuilder > query_dag_
bool g_allow_cpu_retry
Definition: Execute.cpp:78

+ Here is the call graph for this function:

ExecutionResult RelAlgExecutor::executeRelAlgQueryNoRetry ( const CompilationOptions co,
const ExecutionOptions eo,
const bool  just_explain_plan,
RenderInfo render_info 
)
private

Definition at line 185 of file RelAlgExecutor.cpp.

References ExecutionOptions::allow_runtime_query_interrupt, cat_, CHECK(), cleanupPostExecution(), DEBUG_TIMER, RenderInfo::disallow_in_situ_only_if_final_ED_is_aggregate, executeRelAlgQueryWithFilterPushDown(), executeRelAlgSeq(), executor_, ExecutionOptions::find_push_down_candidates, g_enable_dynamic_watchdog, g_enable_runtime_query_interrupt, g_runtime_query_interrupt_frequency, get_physical_inputs(), get_physical_table_inputs(), getSubqueries(), INJECT_TIMER, join(), query_dag_, query_state_, run_benchmark_import::result, RenderInfo::setInSituDataIfUnset(), timer_start(), timer_stop(), to_string(), Executor::UNITARY_EXECUTOR_ID, and VLOG.

Referenced by executeRelAlgQuery().

188  {
190  auto timer = DEBUG_TIMER(__func__);
191  auto timer_setup = DEBUG_TIMER("Query pre-execution steps");
192 
193  query_dag_->resetQueryExecutionState();
194  const auto& ra = query_dag_->getRootNode();
195 
196  // capture the lock acquistion time
197  auto clock_begin = timer_start();
199  executor_->resetInterrupt();
200  }
201 
202  std::string query_session = "";
204  // a request of query execution without session id can happen, i.e., test query
205  // if so, we turn back to the original way: a runtime query interrupt
206  // without per-session management (as similar to dynamic watchdog)
207  mapd_shared_lock<mapd_shared_mutex> session_read_lock(
208  executor_->executor_session_mutex_);
209  if (query_state_ != nullptr && query_state_->getConstSessionInfo() != nullptr) {
210  query_session = query_state_->getConstSessionInfo()->get_session_id();
211  } else if (executor_->getCurrentQuerySession(session_read_lock) != query_session) {
212  query_session = executor_->getCurrentQuerySession(session_read_lock);
213  }
214  session_read_lock.unlock();
215  if (query_session != "") {
216  // if session is valid, then we allow per-session runtime query interrupt
217  mapd_unique_lock<mapd_shared_mutex> session_write_lock(
218  executor_->executor_session_mutex_);
219  executor_->addToQuerySessionList(query_session, session_write_lock);
220  session_write_lock.unlock();
221  // hybrid spinlock. if it fails to acquire a lock, then
222  // it sleeps {g_runtime_query_interrupt_frequency} millisecond.
223  while (executor_->execute_spin_lock_.test_and_set(std::memory_order_acquire)) {
224  // failed to get the spinlock: check whether query is interrupted
225  mapd_shared_lock<mapd_shared_mutex> session_read_lock(
226  executor_->executor_session_mutex_);
227  bool isQueryInterrupted =
228  executor_->checkIsQuerySessionInterrupted(query_session, session_read_lock);
229  session_read_lock.unlock();
230  if (isQueryInterrupted) {
231  mapd_unique_lock<mapd_shared_mutex> session_write_lock(
232  executor_->executor_session_mutex_);
233  executor_->removeFromQuerySessionList(query_session, session_write_lock);
234  session_write_lock.unlock();
235  throw std::runtime_error(
236  "Query execution has been interrupted (pending query)");
237  }
238  // here it fails to acquire the lock
239  std::this_thread::sleep_for(
240  std::chrono::milliseconds(g_runtime_query_interrupt_frequency));
241  };
242  }
243  // currently, atomic_flag does not provide a way to get its current status,
244  // i.e., spinlock.is_locked(), so we additionally lock the execute_mutex_
245  // right after acquiring spinlock to let other part of the code can know
246  // whether there exists a running query on the executor
247  }
248  auto aquire_execute_mutex = [](Executor* executor) -> ExecutorMutexHolder {
249  ExecutorMutexHolder ret;
250  if (executor->executor_id_ == Executor::UNITARY_EXECUTOR_ID) {
251  // Only one unitary executor can run at a time
252  ret.unique_lock = mapd_unique_lock<mapd_shared_mutex>(executor->execute_mutex_);
253  } else {
254  ret.shared_lock = mapd_shared_lock<mapd_shared_mutex>(executor->execute_mutex_);
255  }
256  return ret;
257  };
258  auto lock = aquire_execute_mutex(executor_);
259  ScopeGuard clearRuntimeInterruptStatus = [this] {
260  // reset the runtime query interrupt status
262  mapd_shared_lock<mapd_shared_mutex> session_read_lock(
263  executor_->executor_session_mutex_);
264  std::string curSession = executor_->getCurrentQuerySession(session_read_lock);
265  session_read_lock.unlock();
266  mapd_unique_lock<mapd_shared_mutex> session_write_lock(
267  executor_->executor_session_mutex_);
268  executor_->removeFromQuerySessionList(curSession, session_write_lock);
269  executor_->invalidateQuerySession(session_write_lock);
270  executor_->execute_spin_lock_.clear(std::memory_order_release);
271  session_write_lock.unlock();
272  executor_->resetInterrupt();
273  VLOG(1) << "RESET runtime query interrupt status of Executor " << this;
274  }
275  };
276 
278  // check whether this query session is already interrupted
279  // this case occurs when there is very short gap between being interrupted and
280  // taking the execute lock
281  // if so we interrupt the query session and remove it from the running session list
282  mapd_shared_lock<mapd_shared_mutex> session_read_lock(
283  executor_->executor_session_mutex_);
284  bool isAlreadyInterrupted =
285  executor_->checkIsQuerySessionInterrupted(query_session, session_read_lock);
286  session_read_lock.unlock();
287  if (isAlreadyInterrupted) {
288  mapd_unique_lock<mapd_shared_mutex> session_write_lock(
289  executor_->executor_session_mutex_);
290  executor_->removeFromQuerySessionList(query_session, session_write_lock);
291  session_write_lock.unlock();
292  throw std::runtime_error("Query execution has been interrupted");
293  }
294 
295  // make sure to set the running session ID
296  mapd_unique_lock<mapd_shared_mutex> session_write_lock(
297  executor_->executor_session_mutex_);
298  executor_->invalidateQuerySession(session_write_lock);
299  executor_->setCurrentQuerySession(query_session, session_write_lock);
300  session_write_lock.unlock();
301  }
302 
303  int64_t queue_time_ms = timer_stop(clock_begin);
304  ScopeGuard row_set_holder = [this] { cleanupPostExecution(); };
305  const auto phys_inputs = get_physical_inputs(cat_, &ra);
306  const auto phys_table_ids = get_physical_table_inputs(&ra);
307  executor_->setCatalog(&cat_);
308  executor_->setupCaching(phys_inputs, phys_table_ids);
309 
310  ScopeGuard restore_metainfo_cache = [this] { executor_->clearMetaInfoCache(); };
311  auto ed_seq = RaExecutionSequence(&ra);
312 
313  if (just_explain_plan) {
314  std::stringstream ss;
315  std::vector<const RelAlgNode*> nodes;
316  for (size_t i = 0; i < ed_seq.size(); i++) {
317  nodes.emplace_back(ed_seq.getDescriptor(i)->getBody());
318  }
319  size_t ctr = nodes.size();
320  size_t tab_ctr = 0;
321  for (auto& body : boost::adaptors::reverse(nodes)) {
322  const auto index = ctr--;
323  const auto tabs = std::string(tab_ctr++, '\t');
324  CHECK(body);
325  ss << tabs << std::to_string(index) << " : " << body->toString() << "\n";
326  if (auto sort = dynamic_cast<const RelSort*>(body)) {
327  ss << tabs << " : " << sort->getInput(0)->toString() << "\n";
328  }
329  if (dynamic_cast<const RelProject*>(body) ||
330  dynamic_cast<const RelCompound*>(body)) {
331  if (auto join = dynamic_cast<const RelLeftDeepInnerJoin*>(body->getInput(0))) {
332  ss << tabs << " : " << join->toString() << "\n";
333  }
334  }
335  }
336  auto rs = std::make_shared<ResultSet>(ss.str());
337  return {rs, {}};
338  }
339 
340  if (render_info) {
341  // set render to be non-insitu in certain situations.
343  ed_seq.size() > 1) {
344  // old logic
345  // disallow if more than one ED
346  render_info->setInSituDataIfUnset(false);
347  }
348  }
349 
350  if (eo.find_push_down_candidates) {
351  // this extra logic is mainly due to current limitations on multi-step queries
352  // and/or subqueries.
354  ed_seq, co, eo, render_info, queue_time_ms);
355  }
356  timer_setup.stop();
357 
358  // Dispatch the subqueries first
359  for (auto subquery : getSubqueries()) {
360  const auto subquery_ra = subquery->getRelAlg();
361  CHECK(subquery_ra);
362  if (subquery_ra->hasContextData()) {
363  continue;
364  }
365  // Execute the subquery and cache the result.
366  RelAlgExecutor ra_executor(executor_, cat_, query_state_);
367  RaExecutionSequence subquery_seq(subquery_ra);
368  auto result = ra_executor.executeRelAlgSeq(subquery_seq, co, eo, nullptr, 0);
369  subquery->setExecutionResult(std::make_shared<ExecutionResult>(result));
370  }
371  return executeRelAlgSeq(ed_seq, co, eo, render_info, queue_time_ms);
372 }
ExecutionResult executeRelAlgSeq(const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
ExecutionResult executeRelAlgQueryWithFilterPushDown(const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
bool setInSituDataIfUnset(const bool is_in_situ_data)
Definition: RenderInfo.cpp:98
std::string join(T const &container, std::string const &delim)
TypeR::rep timer_stop(Type clock_begin)
Definition: measure.h:46
bool g_enable_dynamic_watchdog
Definition: Execute.cpp:75
const std::vector< std::shared_ptr< RexSubQuery > > & getSubqueries() const noexcept
std::string to_string(char const *&&v)
bool disallow_in_situ_only_if_final_ED_is_aggregate
Definition: RenderInfo.h:41
const bool find_push_down_candidates
CHECK(cgen_state)
#define INJECT_TIMER(DESC)
Definition: measure.h:91
A container for relational algebra descriptors defining the execution order for a relational algebra ...
const Catalog_Namespace::Catalog & cat_
ExecutionResult executeRelAlgQueryNoRetry(const CompilationOptions &co, const ExecutionOptions &eo, const bool just_explain_plan, RenderInfo *render_info)
unsigned g_runtime_query_interrupt_frequency
Definition: Execute.cpp:110
std::shared_ptr< const query_state::QueryState > query_state_
#define DEBUG_TIMER(name)
Definition: Logger.h:313
std::unique_ptr< RelAlgDagBuilder > query_dag_
void cleanupPostExecution()
std::unordered_set< PhysicalInput > get_physical_inputs(const RelAlgNode *ra)
const bool allow_runtime_query_interrupt
Executor * executor_
bool g_enable_runtime_query_interrupt
Definition: Execute.cpp:108
std::unordered_set< int > get_physical_table_inputs(const RelAlgNode *ra)
#define VLOG(n)
Definition: Logger.h:291
Type timer_start()
Definition: measure.h:40
static const ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:303

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FirstStepExecutionResult RelAlgExecutor::executeRelAlgQuerySingleStep ( const RaExecutionSequence seq,
const size_t  step_idx,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info 
)

Definition at line 412 of file RelAlgExecutor.cpp.

References CHECK(), CHECK_EQ, anonymous_namespace{RelAlgExecutor.cpp}::check_sort_node_source_constraint(), createSortInputWorkUnit(), executeRelAlgSubSeq(), executor_, RaExecutionSequence::getDescriptor(), INJECT_TIMER, anonymous_namespace{RelAlgExecutor.cpp}::node_is_aggregate(), queue_time_ms_, Reduce, GroupByAndAggregate::shard_count_for_top_groups(), and Union.

417  {
418  INJECT_TIMER(executeRelAlgQueryStep);
419  auto exe_desc_ptr = seq.getDescriptor(step_idx);
420  CHECK(exe_desc_ptr);
421  const auto sort = dynamic_cast<const RelSort*>(exe_desc_ptr->getBody());
422 
423  size_t shard_count{0};
424  auto merge_type = [&shard_count](const RelAlgNode* body) -> MergeType {
425  return node_is_aggregate(body) && !shard_count ? MergeType::Reduce : MergeType::Union;
426  };
427 
428  if (sort) {
430  const auto source_work_unit = createSortInputWorkUnit(sort, eo);
432  source_work_unit.exe_unit, *executor_->getCatalog());
433  if (!shard_count) {
434  // No point in sorting on the leaf, only execute the input to the sort node.
435  CHECK_EQ(size_t(1), sort->inputCount());
436  const auto source = sort->getInput(0);
437  if (sort->collationCount() || node_is_aggregate(source)) {
438  auto temp_seq = RaExecutionSequence(std::make_unique<RaExecutionDesc>(source));
439  CHECK_EQ(temp_seq.size(), size_t(1));
440  // Use subseq to avoid clearing existing temporary tables
441  return {executeRelAlgSubSeq(temp_seq, std::make_pair(0, 1), co, eo, nullptr, 0),
442  merge_type(source),
443  source->getId(),
444  false};
445  }
446  }
447  }
448  return {executeRelAlgSubSeq(seq,
449  std::make_pair(step_idx, step_idx + 1),
450  co,
451  eo,
452  render_info,
454  merge_type(exe_desc_ptr->getBody()),
455  exe_desc_ptr->getBody()->getId(),
456  false};
457 }
int64_t queue_time_ms_
#define CHECK_EQ(x, y)
Definition: Logger.h:205
RaExecutionDesc * getDescriptor(size_t idx) const
void check_sort_node_source_constraint(const RelSort *sort)
CHECK(cgen_state)
#define INJECT_TIMER(DESC)
Definition: measure.h:91
MergeType
A container for relational algebra descriptors defining the execution order for a relational algebra ...
ExecutionResult executeRelAlgSubSeq(const RaExecutionSequence &seq, const std::pair< size_t, size_t > interval, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
bool node_is_aggregate(const RelAlgNode *ra)
Executor * executor_
WorkUnit createSortInputWorkUnit(const RelSort *, const ExecutionOptions &eo)
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:

ExecutionResult RelAlgExecutor::executeRelAlgQueryWithFilterPushDown ( const RaExecutionSequence seq,
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::allow_runtime_query_interrupt, cat_, CHECK(), ExecutionOptions::dynamic_watchdog_time_limit, executeRelAlgSeq(), executor_, ExecutionOptions::find_push_down_candidates, getSubqueries(), 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, RaExecutionSequence::size(), ExecutionOptions::with_dynamic_watchdog, and ExecutionOptions::with_watchdog.

Referenced by executeRelAlgQueryNoRetry().

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  const auto& subqueries = getSubqueries();
164  if (seq.size() > 1 || !subqueries.empty()) {
165  if (eo.just_calcite_explain) {
166  return ExecutionResult(std::vector<PushedDownFilterInfo>{},
168  }
169  const ExecutionOptions eo_modified{eo.output_columnar_hint,
170  eo.allow_multifrag,
171  eo.just_explain,
172  eo.allow_loop_joins,
173  eo.with_watchdog,
174  eo.jit_debug,
175  eo.just_validate,
178  /*find_push_down_candidates=*/false,
179  /*just_calcite_explain=*/false,
182 
183  // Dispatch the subqueries first
184  for (auto subquery : subqueries) {
185  // Execute the subquery and cache the result.
186  RelAlgExecutor ra_executor(executor_, cat_);
187  const auto subquery_ra = subquery->getRelAlg();
188  CHECK(subquery_ra);
189  RaExecutionSequence subquery_seq(subquery_ra);
190  auto result = ra_executor.executeRelAlgSeq(subquery_seq, co, eo, nullptr, 0);
191  subquery->setExecutionResult(std::make_shared<ExecutionResult>(result));
192  }
193  return executeRelAlgSeq(seq, co, eo_modified, render_info, queue_time_ms);
194  }
195  // else
196 
197  // Dispatch the subqueries first
198  for (auto subquery : subqueries) {
199  // Execute the subquery and cache the result.
200  RelAlgExecutor ra_executor(executor_, cat_);
201  const auto subquery_ra = subquery->getRelAlg();
202  CHECK(subquery_ra);
203  RaExecutionSequence subquery_seq(subquery_ra);
204  auto result = ra_executor.executeRelAlgSeq(subquery_seq, co, eo, nullptr, 0);
205  subquery->setExecutionResult(std::make_shared<ExecutionResult>(result));
206  }
207  return executeRelAlgSeq(seq, co, eo, render_info, queue_time_ms);
208 }
ExecutionResult executeRelAlgSeq(const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
const std::vector< std::shared_ptr< RexSubQuery > > & getSubqueries() const noexcept
const bool allow_multifrag
const bool find_push_down_candidates
CHECK(cgen_state)
const bool just_validate
const bool with_dynamic_watchdog
const double gpu_input_mem_limit_percent
A container for relational algebra descriptors defining the execution order for a relational algebra ...
const Catalog_Namespace::Catalog & cat_
const bool just_calcite_explain
const bool allow_loop_joins
const bool allow_runtime_query_interrupt
const unsigned dynamic_watchdog_time_limit
Executor * executor_
const bool with_watchdog

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExecutionResult RelAlgExecutor::executeRelAlgSeq ( const RaExecutionSequence seq,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms,
const bool  with_existing_temp_tables = false 
)

Definition at line 476 of file RelAlgExecutor.cpp.

References cat_, CHECK(), DEBUG_TIMER, RaExecutionSequence::empty(), executeRelAlgStep(), executor_, ExecutionOptions::executor_type, g_enable_interop, RaExecutionDesc::getBody(), RaExecutionSequence::getDescriptor(), logger::INFO, INJECT_TIMER, ExecutionOptions::just_explain, LOG, now_, RaExecutionSequence::size(), target_exprs_owned_, temporary_tables_, and VLOG.

Referenced by executeRelAlgQueryNoRetry(), and executeRelAlgQueryWithFilterPushDown().

481  {
483  auto timer = DEBUG_TIMER(__func__);
484  if (!with_existing_temp_tables) {
485  decltype(temporary_tables_)().swap(temporary_tables_);
486  }
487  decltype(target_exprs_owned_)().swap(target_exprs_owned_);
488  executor_->catalog_ = &cat_;
489  executor_->temporary_tables_ = &temporary_tables_;
490 
491  time(&now_);
492  CHECK(!seq.empty());
493  const auto exec_desc_count = eo.just_explain ? size_t(1) : seq.size();
494 
495  for (size_t i = 0; i < exec_desc_count; i++) {
496  VLOG(1) << "Executing query step " << i;
497  // only render on the last step
498  try {
499  executeRelAlgStep(seq,
500  i,
501  co,
502  eo,
503  (i == exec_desc_count - 1) ? render_info : nullptr,
504  queue_time_ms);
505  } catch (const NativeExecutionError&) {
506  if (!g_enable_interop) {
507  throw;
508  }
509  auto eo_extern = eo;
510  eo_extern.executor_type = ::ExecutorType::Extern;
511  auto exec_desc_ptr = seq.getDescriptor(i);
512  const auto body = exec_desc_ptr->getBody();
513  const auto compound = dynamic_cast<const RelCompound*>(body);
514  if (compound && (compound->getGroupByCount() || compound->isAggregate())) {
515  LOG(INFO) << "Also failed to run the query using interoperability";
516  throw;
517  }
518  executeRelAlgStep(seq,
519  i,
520  co,
521  eo_extern,
522  (i == exec_desc_count - 1) ? render_info : nullptr,
523  queue_time_ms);
524  }
525  }
526 
527  return seq.getDescriptor(exec_desc_count - 1)->getResult();
528 }
RaExecutionDesc * getDescriptor(size_t idx) const
ExecutionResult executeRelAlgSeq(const RaExecutionSequence &seq, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms, const bool with_existing_temp_tables=false)
#define LOG(tag)
Definition: Logger.h:188
TemporaryTables temporary_tables_
bool g_enable_interop
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
CHECK(cgen_state)
ExecutorType executor_type
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
void executeRelAlgStep(const RaExecutionSequence &seq, const size_t step_idx, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
#define DEBUG_TIMER(name)
Definition: Logger.h:313
const RelAlgNode * getBody() const
Executor * executor_
#define VLOG(n)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAlgExecutor::executeRelAlgStep ( const RaExecutionSequence seq,
const size_t  step_idx,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 555 of file RelAlgExecutor.cpp.

References addTemporaryTable(), ExecutionOptions::allow_loop_joins, ExecutionOptions::allow_multifrag, ExecutionOptions::allow_runtime_query_interrupt, CHECK(), DEBUG_TIMER, ExecutionOptions::dynamic_watchdog_time_limit, executeAggregate(), executeCompound(), executeDelete(), executeFilter(), executeLogicalValues(), executeModify(), executeProject(), executeSort(), executeTableFunction(), executeUnion(), executeUpdate(), executor_, ExecutionOptions::executor_type, logger::FATAL, ExecutionOptions::find_push_down_candidates, g_cluster, g_enable_union, g_skip_intermediate_count, RaExecutionSequence::getDescriptor(), RelAlgNode::getId(), ExecutionOptions::gpu_input_mem_limit_percent, handleNop(), INJECT_TIMER, ExecutionOptions::jit_debug, ExecutionOptions::just_calcite_explain, ExecutionOptions::just_explain, ExecutionOptions::just_validate, LOG, ExecutionOptions::outer_fragment_indices, ExecutionOptions::output_columnar_hint, WindowProjectNodeContext::reset(), ExecutionOptions::runtime_query_interrupt_frequency, VLOG, ExecutionOptions::with_dynamic_watchdog, and ExecutionOptions::with_watchdog.

Referenced by executeRelAlgSeq(), and executeRelAlgSubSeq().

560  {
562  auto timer = DEBUG_TIMER(__func__);
564  auto exec_desc_ptr = seq.getDescriptor(step_idx);
565  CHECK(exec_desc_ptr);
566  auto& exec_desc = *exec_desc_ptr;
567  const auto body = exec_desc.getBody();
568  if (body->isNop()) {
569  handleNop(exec_desc);
570  return;
571  }
572  const ExecutionOptions eo_work_unit{
574  eo.allow_multifrag,
575  eo.just_explain,
576  eo.allow_loop_joins,
577  eo.with_watchdog && (step_idx == 0 || dynamic_cast<const RelProject*>(body)),
578  eo.jit_debug,
579  eo.just_validate,
587  eo.executor_type,
588  step_idx == 0 ? eo.outer_fragment_indices : std::vector<size_t>()};
589 
590  const auto compound = dynamic_cast<const RelCompound*>(body);
591  if (compound) {
592  if (compound->isDeleteViaSelect()) {
593  executeDelete(compound, co, eo_work_unit, queue_time_ms);
594  } else if (compound->isUpdateViaSelect()) {
595  executeUpdate(compound, co, eo_work_unit, queue_time_ms);
596  } else {
597  exec_desc.setResult(
598  executeCompound(compound, co, eo_work_unit, render_info, queue_time_ms));
599  VLOG(3) << "Returned from executeCompound(), addTemporaryTable("
600  << static_cast<int>(-compound->getId()) << ", ...)"
601  << " exec_desc.getResult().getDataPtr()->rowCount()="
602  << exec_desc.getResult().getDataPtr()->rowCount();
603  if (exec_desc.getResult().isFilterPushDownEnabled()) {
604  return;
605  }
606  addTemporaryTable(-compound->getId(), exec_desc.getResult().getDataPtr());
607  }
608  return;
609  }
610  const auto project = dynamic_cast<const RelProject*>(body);
611  if (project) {
612  if (project->isDeleteViaSelect()) {
613  executeDelete(project, co, eo_work_unit, queue_time_ms);
614  } else if (project->isUpdateViaSelect()) {
615  executeUpdate(project, co, eo_work_unit, queue_time_ms);
616  } else {
617  ssize_t prev_count = -1;
618  // Disabling the intermediate count optimization in distributed, as the previous
619  // execution descriptor will likely not hold the aggregated result.
620  if (g_skip_intermediate_count && step_idx > 0 && !g_cluster) {
621  auto prev_exec_desc = seq.getDescriptor(step_idx - 1);
622  CHECK(prev_exec_desc);
623  RelAlgNode const* prev_body = prev_exec_desc->getBody();
624  // This optimization needs to be restricted in its application for UNION, which
625  // can have 2 input nodes in which neither should restrict the count of the other.
626  // However some non-UNION queries are measurably slower with this restriction, so
627  // it is only applied when g_enable_union is true.
628  bool const parent_check =
629  !g_enable_union || project->getInput(0)->getId() == prev_body->getId();
630  // If the previous node produced a reliable count, skip the pre-flight count
631  if (parent_check && (dynamic_cast<const RelCompound*>(prev_body) ||
632  dynamic_cast<const RelLogicalValues*>(prev_body))) {
633  const auto& prev_exe_result = prev_exec_desc->getResult();
634  const auto prev_result = prev_exe_result.getRows();
635  if (prev_result) {
636  prev_count = static_cast<ssize_t>(prev_result->rowCount());
637  }
638  VLOG(3) << "prev_exec_desc->getBody()->toString()="
639  << prev_exec_desc->getBody()->toString()
640  << " prev_count=" << prev_count;
641  }
642  }
643  exec_desc.setResult(executeProject(
644  project, co, eo_work_unit, render_info, queue_time_ms, prev_count));
645  VLOG(3) << "Returned from executeProject(), addTemporaryTable("
646  << static_cast<int>(-project->getId()) << ", ...)"
647  << " exec_desc.getResult().getDataPtr()->rowCount()="
648  << exec_desc.getResult().getDataPtr()->rowCount();
649  if (exec_desc.getResult().isFilterPushDownEnabled()) {
650  return;
651  }
652  addTemporaryTable(-project->getId(), exec_desc.getResult().getDataPtr());
653  }
654  return;
655  }
656  const auto aggregate = dynamic_cast<const RelAggregate*>(body);
657  if (aggregate) {
658  exec_desc.setResult(
659  executeAggregate(aggregate, co, eo_work_unit, render_info, queue_time_ms));
660  addTemporaryTable(-aggregate->getId(), exec_desc.getResult().getDataPtr());
661  return;
662  }
663  const auto filter = dynamic_cast<const RelFilter*>(body);
664  if (filter) {
665  exec_desc.setResult(
666  executeFilter(filter, co, eo_work_unit, render_info, queue_time_ms));
667  addTemporaryTable(-filter->getId(), exec_desc.getResult().getDataPtr());
668  return;
669  }
670  const auto sort = dynamic_cast<const RelSort*>(body);
671  if (sort) {
672  exec_desc.setResult(executeSort(sort, co, eo_work_unit, render_info, queue_time_ms));
673  if (exec_desc.getResult().isFilterPushDownEnabled()) {
674  return;
675  }
676  addTemporaryTable(-sort->getId(), exec_desc.getResult().getDataPtr());
677  return;
678  }
679  const auto logical_values = dynamic_cast<const RelLogicalValues*>(body);
680  if (logical_values) {
681  exec_desc.setResult(executeLogicalValues(logical_values, eo_work_unit));
682  addTemporaryTable(-logical_values->getId(), exec_desc.getResult().getDataPtr());
683  return;
684  }
685  const auto modify = dynamic_cast<const RelModify*>(body);
686  if (modify) {
687  exec_desc.setResult(executeModify(modify, eo_work_unit));
688  return;
689  }
690  const auto logical_union = dynamic_cast<const RelLogicalUnion*>(body);
691  if (logical_union) {
692  exec_desc.setResult(
693  executeUnion(logical_union, seq, co, eo_work_unit, render_info, queue_time_ms));
694  addTemporaryTable(-logical_union->getId(), exec_desc.getResult().getDataPtr());
695  return;
696  }
697  const auto table_func = dynamic_cast<const RelTableFunction*>(body);
698  if (table_func) {
699  exec_desc.setResult(
700  executeTableFunction(table_func, co, eo_work_unit, queue_time_ms));
701  addTemporaryTable(-table_func->getId(), exec_desc.getResult().getDataPtr());
702  return;
703  }
704  LOG(FATAL) << "Unhandled body type: " << body->toString();
705 }
ExecutionResult executeAggregate(const RelAggregate *aggregate, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
RaExecutionDesc * getDescriptor(size_t idx) const
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
#define LOG(tag)
Definition: Logger.h:188
const unsigned runtime_query_interrupt_frequency
bool g_enable_union
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
CHECK(cgen_state)
const bool just_validate
unsigned getId() const
ExecutorType executor_type
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const bool with_dynamic_watchdog
static void reset(Executor *executor)
const double gpu_input_mem_limit_percent
void executeUpdate(const RelAlgNode *node, const CompilationOptions &co, const ExecutionOptions &eo, const int64_t queue_time_ms)
void executeRelAlgStep(const RaExecutionSequence &seq, const size_t step_idx, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
ExecutionResult executeTableFunction(const RelTableFunction *, const CompilationOptions &, const ExecutionOptions &, const int64_t queue_time_ms)
const std::vector< size_t > outer_fragment_indices
const bool just_calcite_explain
ExecutionResult executeUnion(const RelLogicalUnion *, const RaExecutionSequence &, 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)
const bool allow_loop_joins
#define DEBUG_TIMER(name)
Definition: Logger.h:313
ExecutionResult executeCompound(const RelCompound *, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
bool g_cluster
const bool allow_runtime_query_interrupt
const unsigned dynamic_watchdog_time_limit
void executeDelete(const RelAlgNode *node, const CompilationOptions &co, const ExecutionOptions &eo_in, const int64_t queue_time_ms)
Executor * executor_
#define VLOG(n)
Definition: Logger.h:291
const bool with_watchdog

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExecutionResult RelAlgExecutor::executeRelAlgSubSeq ( const RaExecutionSequence seq,
const std::pair< size_t, size_t >  interval,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)

Definition at line 530 of file RelAlgExecutor.cpp.

References cat_, executeRelAlgStep(), executor_, RaExecutionSequence::getDescriptor(), INJECT_TIMER, now_, and temporary_tables_.

Referenced by executeRelAlgQuerySingleStep().

536  {
538  executor_->catalog_ = &cat_;
539  executor_->temporary_tables_ = &temporary_tables_;
540 
541  time(&now_);
542  for (size_t i = interval.first; i < interval.second; i++) {
543  // only render on the last step
544  executeRelAlgStep(seq,
545  i,
546  co,
547  eo,
548  (i == interval.second - 1) ? render_info : nullptr,
549  queue_time_ms);
550  }
551 
552  return seq.getDescriptor(interval.second - 1)->getResult();
553 }
RaExecutionDesc * getDescriptor(size_t idx) const
TemporaryTables temporary_tables_
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
ExecutionResult executeRelAlgSubSeq(const RaExecutionSequence &seq, const std::pair< size_t, size_t > interval, const CompilationOptions &co, const ExecutionOptions &eo, RenderInfo *render_info, const int64_t queue_time_ms)
void executeRelAlgStep(const RaExecutionSequence &seq, const size_t step_idx, const CompilationOptions &, const ExecutionOptions &, RenderInfo *, const int64_t queue_time_ms)
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExecutionResult RelAlgExecutor::executeSimpleInsert ( const Analyzer::Query insert_query)

Definition at line 2017 of file RelAlgExecutor.cpp.

References appendDatum(), DataBlockPtr::arraysPtr, cat_, CHECK(), CHECK_EQ, checked_malloc(), Fragmenter_Namespace::InsertData::columnIds, CPU, Fragmenter_Namespace::InsertData::data, Fragmenter_Namespace::InsertData::databaseId, Catalog_Namespace::DBMetadata::dbId, executor_, get_column_descriptor(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_elem_type(), Analyzer::Query::get_result_col_list(), Analyzer::Query::get_result_table_id(), SQLTypeInfo::get_size(), Analyzer::Query::get_targetlist(), SQLTypeInfo::get_type(), Catalog_Namespace::Catalog::getCurrentDB(), Catalog_Namespace::Catalog::getMetadataForDict(), Catalog_Namespace::Catalog::getMetadataForTable(), Catalog_Namespace::Catalog::getPhysicalTablesDescriptors(), inline_fixed_encoding_null_val(), anonymous_namespace{RelAlgExecutor.cpp}::insert_one_dict_str(), anonymous_namespace{TypedDataAccessors.h}::is_null(), SQLTypeInfo::is_string(), kARRAY, kBIGINT, kBOOLEAN, kCAST, kCHAR, kDATE, kDECIMAL, kDOUBLE, kENCODING_DICT, kENCODING_NONE, kFLOAT, kINT, kLINESTRING, kMULTIPOLYGON, kNUMERIC, kPOINT, kPOLYGON, kSMALLINT, kTEXT, kTIME, kTIMESTAMP, kTINYINT, kVARCHAR, DataBlockPtr::numbersPtr, Fragmenter_Namespace::InsertData::numRows, anonymous_namespace{TypedDataAccessors.h}::put_null(), anonymous_namespace{TypedDataAccessors.h}::put_null_array(), SHARD_FOR_KEY, DataBlockPtr::stringsPtr, Fragmenter_Namespace::InsertData::tableId, and to_string().

Referenced by Parser::InsertValuesStmt::execute().

2017  {
2018  // Note: We currently obtain an executor for this method, but we do not need it.
2019  // Therefore, we skip the executor state setup in the regular execution path. In the
2020  // future, we will likely want to use the executor to evaluate expressions in the insert
2021  // statement.
2022 
2023  const auto& targets = query.get_targetlist();
2024  const int table_id = query.get_result_table_id();
2025  const auto& col_id_list = query.get_result_col_list();
2026 
2027  std::vector<const ColumnDescriptor*> col_descriptors;
2028  std::vector<int> col_ids;
2029  std::unordered_map<int, std::unique_ptr<uint8_t[]>> col_buffers;
2030  std::unordered_map<int, std::vector<std::string>> str_col_buffers;
2031  std::unordered_map<int, std::vector<ArrayDatum>> arr_col_buffers;
2032 
2033  const auto table_descriptor = cat_.getMetadataForTable(table_id);
2034  CHECK(table_descriptor);
2035  const auto shard_tables = cat_.getPhysicalTablesDescriptors(table_descriptor);
2036  const TableDescriptor* shard{nullptr};
2037 
2038  for (const int col_id : col_id_list) {
2039  const auto cd = get_column_descriptor(col_id, table_id, cat_);
2040  const auto col_enc = cd->columnType.get_compression();
2041  if (cd->columnType.is_string()) {
2042  switch (col_enc) {
2043  case kENCODING_NONE: {
2044  auto it_ok =
2045  str_col_buffers.insert(std::make_pair(col_id, std::vector<std::string>{}));
2046  CHECK(it_ok.second);
2047  break;
2048  }
2049  case kENCODING_DICT: {
2050  const auto dd = cat_.getMetadataForDict(cd->columnType.get_comp_param());
2051  CHECK(dd);
2052  const auto it_ok = col_buffers.emplace(
2053  col_id, std::make_unique<uint8_t[]>(cd->columnType.get_size()));
2054  CHECK(it_ok.second);
2055  break;
2056  }
2057  default:
2058  CHECK(false);
2059  }
2060  } else if (cd->columnType.is_geometry()) {
2061  auto it_ok =
2062  str_col_buffers.insert(std::make_pair(col_id, std::vector<std::string>{}));
2063  CHECK(it_ok.second);
2064  } else if (cd->columnType.is_array()) {
2065  auto it_ok =
2066  arr_col_buffers.insert(std::make_pair(col_id, std::vector<ArrayDatum>{}));
2067  CHECK(it_ok.second);
2068  } else {
2069  const auto it_ok = col_buffers.emplace(
2070  col_id,
2071  std::unique_ptr<uint8_t[]>(
2072  new uint8_t[cd->columnType.get_logical_size()]())); // changed to zero-init
2073  // the buffer
2074  CHECK(it_ok.second);
2075  }
2076  col_descriptors.push_back(cd);
2077  col_ids.push_back(col_id);
2078  }
2079  size_t col_idx = 0;
2081  insert_data.databaseId = cat_.getCurrentDB().dbId;
2082  insert_data.tableId = table_id;
2083  int64_t int_col_val{0};
2084  for (auto target_entry : targets) {
2085  auto col_cv = dynamic_cast<const Analyzer::Constant*>(target_entry->get_expr());
2086  if (!col_cv) {
2087  auto col_cast = dynamic_cast<const Analyzer::UOper*>(target_entry->get_expr());
2088  CHECK(col_cast);
2089  CHECK_EQ(kCAST, col_cast->get_optype());
2090  col_cv = dynamic_cast<const Analyzer::Constant*>(col_cast->get_operand());
2091  }
2092  CHECK(col_cv);
2093  const auto cd = col_descriptors[col_idx];
2094  auto col_datum = col_cv->get_constval();
2095  auto col_type = cd->columnType.get_type();
2096  uint8_t* col_data_bytes{nullptr};
2097  if (!cd->columnType.is_array() && !cd->columnType.is_geometry() &&
2098  (!cd->columnType.is_string() ||
2099  cd->columnType.get_compression() == kENCODING_DICT)) {
2100  const auto col_data_bytes_it = col_buffers.find(col_ids[col_idx]);
2101  CHECK(col_data_bytes_it != col_buffers.end());
2102  col_data_bytes = col_data_bytes_it->second.get();
2103  }
2104  switch (col_type) {
2105  case kBOOLEAN: {
2106  auto col_data = col_data_bytes;
2107  *col_data = col_cv->get_is_null() ? inline_fixed_encoding_null_val(cd->columnType)
2108  : (col_datum.boolval ? 1 : 0);
2109  break;
2110  }
2111  case kTINYINT: {
2112  auto col_data = reinterpret_cast<int8_t*>(col_data_bytes);
2113  *col_data = col_cv->get_is_null() ? inline_fixed_encoding_null_val(cd->columnType)
2114  : col_datum.tinyintval;
2115  int_col_val = col_datum.tinyintval;
2116  break;
2117  }
2118  case kSMALLINT: {
2119  auto col_data = reinterpret_cast<int16_t*>(col_data_bytes);
2120  *col_data = col_cv->get_is_null() ? inline_fixed_encoding_null_val(cd->columnType)
2121  : col_datum.smallintval;
2122  int_col_val = col_datum.smallintval;
2123  break;
2124  }
2125  case kINT: {
2126  auto col_data = reinterpret_cast<int32_t*>(col_data_bytes);
2127  *col_data = col_cv->get_is_null() ? inline_fixed_encoding_null_val(cd->columnType)
2128  : col_datum.intval;
2129  int_col_val = col_datum.intval;
2130  break;
2131  }
2132  case kBIGINT:
2133  case kDECIMAL:
2134  case kNUMERIC: {
2135  auto col_data = reinterpret_cast<int64_t*>(col_data_bytes);
2136  *col_data = col_cv->get_is_null() ? inline_fixed_encoding_null_val(cd->columnType)
2137  : col_datum.bigintval;
2138  int_col_val = col_datum.bigintval;
2139  break;
2140  }
2141  case kFLOAT: {
2142  auto col_data = reinterpret_cast<float*>(col_data_bytes);
2143  *col_data = col_datum.floatval;
2144  break;
2145  }
2146  case kDOUBLE: {
2147  auto col_data = reinterpret_cast<double*>(col_data_bytes);
2148  *col_data = col_datum.doubleval;
2149  break;
2150  }
2151  case kTEXT:
2152  case kVARCHAR:
2153  case kCHAR: {
2154  switch (cd->columnType.get_compression()) {
2155  case kENCODING_NONE:
2156  str_col_buffers[col_ids[col_idx]].push_back(
2157  col_datum.stringval ? *col_datum.stringval : "");
2158  break;
2159  case kENCODING_DICT: {
2160  switch (cd->columnType.get_size()) {
2161  case 1:
2162  int_col_val = insert_one_dict_str(
2163  reinterpret_cast<uint8_t*>(col_data_bytes), cd, col_cv, cat_);
2164  break;
2165  case 2:
2166  int_col_val = insert_one_dict_str(
2167  reinterpret_cast<uint16_t*>(col_data_bytes), cd, col_cv, cat_);
2168  break;
2169  case 4:
2170  int_col_val = insert_one_dict_str(
2171  reinterpret_cast<int32_t*>(col_data_bytes), cd, col_cv, cat_);
2172  break;
2173  default:
2174  CHECK(false);
2175  }
2176  break;
2177  }
2178  default:
2179  CHECK(false);
2180  }
2181  break;
2182  }
2183  case kTIME:
2184  case kTIMESTAMP:
2185  case kDATE: {
2186  auto col_data = reinterpret_cast<int64_t*>(col_data_bytes);
2187  *col_data = col_cv->get_is_null() ? inline_fixed_encoding_null_val(cd->columnType)
2188  : col_datum.bigintval;
2189  break;
2190  }
2191  case kARRAY: {
2192  const auto is_null = col_cv->get_is_null();
2193  const auto size = cd->columnType.get_size();
2194  const SQLTypeInfo elem_ti = cd->columnType.get_elem_type();
2195  // POINT coords: [un]compressed coords always need to be encoded, even if NULL
2196  const auto is_point_coords = (cd->isGeoPhyCol && elem_ti.get_type() == kTINYINT);
2197  if (is_null && !is_point_coords) {
2198  if (size > 0) {
2199  // NULL fixlen array: NULL_ARRAY sentinel followed by NULL sentinels
2200  if (elem_ti.is_string() && elem_ti.get_compression() == kENCODING_DICT) {
2201  throw std::runtime_error("Column " + cd->columnName +
2202  " doesn't accept NULL values");
2203  }
2204  int8_t* buf = (int8_t*)checked_malloc(size);
2205  put_null_array(static_cast<void*>(buf), elem_ti, "");
2206  for (int8_t* p = buf + elem_ti.get_size(); (p - buf) < size;
2207  p += elem_ti.get_size()) {
2208  put_null(static_cast<void*>(p), elem_ti, "");
2209  }
2210  arr_col_buffers[col_ids[col_idx]].emplace_back(size, buf, is_null);
2211  } else {
2212  arr_col_buffers[col_ids[col_idx]].emplace_back(0, nullptr, is_null);
2213  }
2214  break;
2215  }
2216  const auto l = col_cv->get_value_list();
2217  size_t len = l.size() * elem_ti.get_size();
2218  if (size > 0 && static_cast<size_t>(size) != len) {
2219  throw std::runtime_error("Array column " + cd->columnName + " expects " +
2220  std::to_string(size / elem_ti.get_size()) +
2221  " values, " + "received " + std::to_string(l.size()));
2222  }
2223  if (elem_ti.is_string()) {
2224  CHECK(kENCODING_DICT == elem_ti.get_compression());
2225  CHECK(4 == elem_ti.get_size());
2226 
2227  int8_t* buf = (int8_t*)checked_malloc(len);
2228  int32_t* p = reinterpret_cast<int32_t*>(buf);
2229 
2230  int elemIndex = 0;
2231  for (auto& e : l) {
2232  auto c = std::dynamic_pointer_cast<Analyzer::Constant>(e);
2233  CHECK(c);
2234 
2235  int_col_val = insert_one_dict_str(
2236  &p[elemIndex], cd->columnName, elem_ti, c.get(), cat_);
2237 
2238  elemIndex++;
2239  }
2240  arr_col_buffers[col_ids[col_idx]].push_back(ArrayDatum(len, buf, is_null));
2241 
2242  } else {
2243  int8_t* buf = (int8_t*)checked_malloc(len);
2244  int8_t* p = buf;
2245  for (auto& e : l) {
2246  auto c = std::dynamic_pointer_cast<Analyzer::Constant>(e);
2247  CHECK(c);
2248  p = appendDatum(p, c->get_constval(), elem_ti);
2249  }
2250  arr_col_buffers[col_ids[col_idx]].push_back(ArrayDatum(len, buf, is_null));
2251  }
2252  break;
2253  }
2254  case kPOINT:
2255  case kLINESTRING:
2256  case kPOLYGON:
2257  case kMULTIPOLYGON:
2258  str_col_buffers[col_ids[col_idx]].push_back(
2259  col_datum.stringval ? *col_datum.stringval : "");
2260  break;
2261  default:
2262  CHECK(false);
2263  }
2264  ++col_idx;
2265  if (col_idx == static_cast<size_t>(table_descriptor->shardedColumnId)) {
2266  const auto shard_count = shard_tables.size();
2267  const size_t shard_idx = SHARD_FOR_KEY(int_col_val, shard_count);
2268  shard = shard_tables[shard_idx];
2269  }
2270  }
2271  for (const auto& kv : col_buffers) {
2272  insert_data.columnIds.push_back(kv.first);
2273  DataBlockPtr p;
2274  p.numbersPtr = reinterpret_cast<int8_t*>(kv.second.get());
2275  insert_data.data.push_back(p);
2276  }
2277  for (auto& kv : str_col_buffers) {
2278  insert_data.columnIds.push_back(kv.first);
2279  DataBlockPtr p;
2280  p.stringsPtr = &kv.second;
2281  insert_data.data.push_back(p);
2282  }
2283  for (auto& kv : arr_col_buffers) {
2284  insert_data.columnIds.push_back(kv.first);
2285  DataBlockPtr p;
2286  p.arraysPtr = &kv.second;
2287  insert_data.data.push_back(p);
2288  }
2289  insert_data.numRows = 1;
2290  if (shard) {
2291  shard->fragmenter->insertData(insert_data);
2292  } else {
2293  table_descriptor->fragmenter->insertData(insert_data);
2294  }
2295 
2296  auto rs = std::make_shared<ResultSet>(TargetInfoList{},
2299  executor_->getRowSetMemoryOwner(),
2300  executor_);
2301  std::vector<TargetMetaInfo> empty_targets;
2302  return {rs, empty_targets};
2303 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
HOST DEVICE int get_size() const
Definition: sqltypes.h:268
Definition: sqltypes.h:50
std::vector< std::string > * stringsPtr
Definition: sqltypes.h:149
std::vector< ArrayDatum > * arraysPtr
Definition: sqltypes.h:150
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logicalTableDesc) const
Definition: Catalog.cpp:3494
int64_t insert_one_dict_str(T *col_data, const std::string &columnName, const SQLTypeInfo &columnType, const Analyzer::Constant *col_cv, const Catalog_Namespace::Catalog &catalog)
Definition: sqldefs.h:49
std::vector< TargetInfo > TargetInfoList
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:258
std::string to_string(char const *&&v)
int tableId
identifies the database into which the data is being inserted
Definition: Fragmenter.h:61
std::conditional_t< is_cuda_compiler(), DeviceArrayDatum, HostArrayDatum > ArrayDatum
Definition: sqltypes.h:130
size_t numRows
a vector of column ids for the row(s) being inserted
Definition: Fragmenter.h:63
CHECK(cgen_state)
const DBMetadata & getCurrentDB() const
Definition: Catalog.h:194
void * checked_malloc(const size_t size)
Definition: checked_alloc.h:44
void put_null_array(void *ndptr, const SQLTypeInfo &ntype, const std::string col_name)
const Catalog_Namespace::Catalog & cat_
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1449
void put_null(void *ndptr, const SQLTypeInfo &ntype, const std::string col_name)
Definition: sqltypes.h:53
Definition: sqltypes.h:54
int8_t * appendDatum(int8_t *buf, Datum d, const SQLTypeInfo &ti)
Definition: sqltypes.h:869
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:266
bool is_null(const T &v, const SQLTypeInfo &t)
std::vector< DataBlockPtr > data
the number of rows being inserted
Definition: Fragmenter.h:64
Definition: sqltypes.h:42
int64_t inline_fixed_encoding_null_val(const SQL_TYPE_INFO &ti)
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:59
Definition: sqltypes.h:46
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
bool is_string() const
Definition: sqltypes.h:415
specifies the content in-memory of a row in the table metadata table
int8_t * numbersPtr
Definition: sqltypes.h:148
SQLTypeInfo get_elem_type() const
Definition: sqltypes.h:622
std::vector< int > columnIds
identifies the table into which the data is being inserted
Definition: Fragmenter.h:62
Executor * executor_
#define SHARD_FOR_KEY(key, num_shards)
Definition: shard_key.h:20
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:120

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 2335 of file RelAlgExecutor.cpp.

References SpeculativeTopNBlacklist::add(), GroupByAndAggregate::addTransientStringLiterals(), CHECK(), CHECK_EQ, anonymous_namespace{RelAlgExecutor.cpp}::check_sort_node_source_constraint(), RelSort::collationCount(), createSortInputWorkUnit(), DEBUG_TIMER, executeWorkUnit(), 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(), ExecutionResult::getRows(), RelSort::isEmptyResult(), leaf_results_, anonymous_namespace{RelAlgExecutor.cpp}::node_is_aggregate(), ExecutionOptions::output_columnar_hint, run_benchmark_import::result, RelAlgNode::setOutputMetainfo(), speculative_topn_blacklist_, and use_speculative_top_n().

Referenced by executeRelAlgStep().

2339  {
2340  auto timer = DEBUG_TIMER(__func__);
2342  const auto source = sort->getInput(0);
2343  const bool is_aggregate = node_is_aggregate(source);
2344  auto it = leaf_results_.find(sort->getId());
2345  if (it != leaf_results_.end()) {
2346  // Add any transient string literals to the sdp on the agg
2347  const auto source_work_unit = createSortInputWorkUnit(sort, eo);
2349  source_work_unit.exe_unit, executor_, executor_->row_set_mem_owner_);
2350  // Handle push-down for LIMIT for multi-node
2351  auto& aggregated_result = it->second;
2352  auto& result_rows = aggregated_result.rs;
2353  const size_t limit = sort->getLimit();
2354  const size_t offset = sort->getOffset();
2355  const auto order_entries = get_order_entries(sort);
2356  if (limit || offset) {
2357  if (!order_entries.empty()) {
2358  result_rows->sort(order_entries, limit + offset);
2359  }
2360  result_rows->dropFirstN(offset);
2361  if (limit) {
2362  result_rows->keepFirstN(limit);
2363  }
2364  }
2365  ExecutionResult result(result_rows, aggregated_result.targets_meta);
2366  sort->setOutputMetainfo(aggregated_result.targets_meta);
2367  return result;
2368  }
2369 
2370  std::list<std::shared_ptr<Analyzer::Expr>> groupby_exprs;
2371  bool is_desc{false};
2372 
2373  auto execute_sort_query = [this,
2374  sort,
2375  &source,
2376  &is_aggregate,
2377  &eo,
2378  &co,
2379  render_info,
2380  queue_time_ms,
2381  &groupby_exprs,
2382  &is_desc]() -> ExecutionResult {
2383  const auto source_work_unit = createSortInputWorkUnit(sort, eo);
2384  is_desc = first_oe_is_desc(source_work_unit.exe_unit.sort_info.order_entries);
2385  ExecutionOptions eo_copy = {
2387  eo.allow_multifrag,
2388  eo.just_explain,
2389  eo.allow_loop_joins,
2390  eo.with_watchdog,
2391  eo.jit_debug,
2392  eo.just_validate || sort->isEmptyResult(),
2393  eo.with_dynamic_watchdog,
2394  eo.dynamic_watchdog_time_limit,
2395  eo.find_push_down_candidates,
2396  eo.just_calcite_explain,
2397  eo.gpu_input_mem_limit_percent,
2398  eo.allow_runtime_query_interrupt,
2399  eo.runtime_query_interrupt_frequency,
2400  eo.executor_type,
2401  };
2402 
2403  groupby_exprs = source_work_unit.exe_unit.groupby_exprs;
2404  auto source_result = executeWorkUnit(source_work_unit,
2405  source->getOutputMetainfo(),
2406  is_aggregate,
2407  co,
2408  eo_copy,
2409  render_info,
2410  queue_time_ms);
2411  if (render_info && render_info->isPotentialInSituRender()) {
2412  return source_result;
2413  }
2414  if (source_result.isFilterPushDownEnabled()) {
2415  return source_result;
2416  }
2417  auto rows_to_sort = source_result.getRows();
2418  if (eo.just_explain) {
2419  return {rows_to_sort, {}};
2420  }
2421  const size_t limit = sort->getLimit();
2422  const size_t offset = sort->getOffset();
2423  if (sort->collationCount() != 0 && !rows_to_sort->definitelyHasNoRows() &&
2424  !use_speculative_top_n(source_work_unit.exe_unit,
2425  rows_to_sort->getQueryMemDesc())) {
2426  rows_to_sort->sort(source_work_unit.exe_unit.sort_info.order_entries,
2427  limit + offset);
2428  }
2429  if (limit || offset) {
2430  if (g_cluster && sort->collationCount() == 0) {
2431  if (offset >= rows_to_sort->rowCount()) {
2432  rows_to_sort->dropFirstN(offset);
2433  } else {
2434  rows_to_sort->keepFirstN(limit + offset);
2435  }
2436  } else {
2437  rows_to_sort->dropFirstN(offset);
2438  if (limit) {
2439  rows_to_sort->keepFirstN(limit);
2440  }
2441  }
2442  }
2443  return {rows_to_sort, source_result.getTargetsMeta()};
2444  };
2445 
2446  try {
2447  return execute_sort_query();
2448  } catch (const SpeculativeTopNFailed& e) {
2449  CHECK_EQ(size_t(1), groupby_exprs.size());
2450  CHECK(groupby_exprs.front());
2451  speculative_topn_blacklist_.add(groupby_exprs.front(), is_desc);
2452  return execute_sort_query();
2453  }
2454 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
size_t getOffset() const
static SpeculativeTopNBlacklist speculative_topn_blacklist_
bool use_speculative_top_n(const RelAlgExecutionUnit &ra_exe_unit, const QueryMemoryDescriptor &query_mem_desc)
void check_sort_node_source_constraint(const RelSort *sort)
std::unordered_map< unsigned, AggregatedResult > leaf_results_
CHECK(cgen_state)
unsigned getId() const
const std::shared_ptr< ResultSet > & getRows() const
const RelAlgNode * getInput(const size_t idx) const
bool node_is_aggregate(const RelAlgNode *ra)
bool isEmptyResult() const
size_t collationCount() const
size_t getLimit() 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 DEBUG_TIMER(name)
Definition: Logger.h:313
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
std::list< Analyzer::OrderEntry > get_order_entries(const RelSort *sort)
bool g_cluster
void add(const std::shared_ptr< Analyzer::Expr > expr, const bool desc)
Executor * executor_
WorkUnit createSortInputWorkUnit(const RelSort *, const ExecutionOptions &eo)
bool first_oe_is_desc(const std::list< Analyzer::OrderEntry > &order_entries)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExecutionResult RelAlgExecutor::executeTableFunction ( const RelTableFunction table_func,
const CompilationOptions co_in,
const ExecutionOptions eo,
const int64_t  queue_time_ms 
)
private

Definition at line 1626 of file RelAlgExecutor.cpp.

References cat_, CHECK(), createTableFunctionWorkUnit(), DEBUG_TIMER, CompilationOptions::device_type, Executor::ERR_OUT_OF_GPU_MEM, executor_, g_cluster, g_enable_table_functions, get_table_infos(), QueryExecutionError::getErrorCode(), handlePersistentError(), INJECT_TIMER, ExecutionOptions::just_explain, and run_benchmark_import::result.

Referenced by executeRelAlgStep().

1629  {
1631  auto timer = DEBUG_TIMER(__func__);
1632 
1633  auto co = co_in;
1634 
1635  if (g_cluster) {
1636  throw std::runtime_error("Table functions not supported in distributed mode yet");
1637  }
1638  if (!g_enable_table_functions) {
1639  throw std::runtime_error("Table function support is disabled");
1640  }
1641 
1642  auto table_func_work_unit = createTableFunctionWorkUnit(table_func, eo.just_explain);
1643  const auto body = table_func_work_unit.body;
1644  CHECK(body);
1645 
1646  const auto table_infos =
1647  get_table_infos(table_func_work_unit.exe_unit.input_descs, executor_);
1648 
1649  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
1650  co.device_type,
1652  nullptr,
1653  executor_),
1654  {}};
1655 
1656  try {
1657  result = {executor_->executeTableFunction(
1658  table_func_work_unit.exe_unit, table_infos, co, eo, cat_),
1659  body->getOutputMetainfo()};
1660  } catch (const QueryExecutionError& e) {
1663  throw std::runtime_error("Table function ran out of memory during execution");
1664  }
1665  result.setQueueTime(queue_time_ms);
1666  return result;
1667 }
int32_t getErrorCode() const
Definition: ErrorHandling.h:55
TableFunctionWorkUnit createTableFunctionWorkUnit(const RelTableFunction *table_func, const bool just_explain)
CHECK(cgen_state)
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
static const int32_t ERR_OUT_OF_GPU_MEM
Definition: Execute.h:936
ExecutionResult executeTableFunction(const RelTableFunction *, const CompilationOptions &, const ExecutionOptions &, const int64_t queue_time_ms)
static void handlePersistentError(const int32_t error_code)
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
#define DEBUG_TIMER(name)
Definition: Logger.h:313
bool g_cluster
Executor * executor_
bool g_enable_table_functions
Definition: Execute.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ExecutionResult RelAlgExecutor::executeUnion ( const RelLogicalUnion logical_union,
const RaExecutionSequence seq,
const CompilationOptions co,
const ExecutionOptions eo,
RenderInfo render_info,
const int64_t  queue_time_ms 
)
private

Definition at line 1832 of file RelAlgExecutor.cpp.

References RelLogicalUnion::checkForMatchingMetaInfoTypes(), createUnionWorkUnit(), DEBUG_TIMER, Default, executeWorkUnit(), RelAlgNode::getInput(), RelAlgNode::getOutputMetainfo(), RelAlgNode::hasInput(), RelLogicalUnion::isAll(), isGeometry(), CompilationOptions::makeCpuOnly(), query_dag_, and RelAlgNode::setOutputMetainfo().

Referenced by executeRelAlgStep().

1837  {
1838  auto timer = DEBUG_TIMER(__func__);
1839  if (!logical_union->isAll()) {
1840  throw std::runtime_error("UNION without ALL is not supported yet.");
1841  }
1842  // Will throw a std::runtime_error if types don't match.
1843  logical_union->checkForMatchingMetaInfoTypes();
1844  logical_union->setOutputMetainfo(logical_union->getInput(0)->getOutputMetainfo());
1845  if (boost::algorithm::any_of(logical_union->getOutputMetainfo(), isGeometry)) {
1846  throw std::runtime_error("UNION does not support subqueries with geo-columns.");
1847  }
1848  // Only Projections and Aggregates from a UNION are supported for now.
1849  query_dag_->eachNode([logical_union](RelAlgNode const* node) {
1850  if (node->hasInput(logical_union) &&
1851  !shared::dynamic_castable_to_any<RelProject, RelLogicalUnion, RelAggregate>(
1852  node)) {
1853  throw std::runtime_error("UNION ALL not yet supported in this context.");
1854  }
1855  });
1856 
1857  auto work_unit =
1858  createUnionWorkUnit(logical_union, {{}, SortAlgorithm::Default, 0, 0}, eo);
1859  return executeWorkUnit(work_unit,
1860  logical_union->getOutputMetainfo(),
1861  false,
1863  eo,
1864  render_info,
1865  queue_time_ms);
1866 }
bool isAll() const
void checkForMatchingMetaInfoTypes() const
static CompilationOptions makeCpuOnly(const CompilationOptions &in)
bool isGeometry(TargetMetaInfo const &target_meta_info)
const RelAlgNode * getInput(const size_t idx) const
WorkUnit createUnionWorkUnit(const RelLogicalUnion *, const SortInfo &, const ExecutionOptions &eo)
bool hasInput(const RelAlgNode *needle) 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 DEBUG_TIMER(name)
Definition: Logger.h:313
void setOutputMetainfo(const std::vector< TargetMetaInfo > &targets_metainfo) const
std::unique_ptr< RelAlgDagBuilder > query_dag_
const std::vector< TargetMetaInfo > & getOutputMetainfo() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAlgExecutor::executeUpdate ( const RelAlgNode node,
const CompilationOptions co,
const ExecutionOptions eo,
const int64_t  queue_time_ms 
)
private

Definition at line 1359 of file RelAlgExecutor.cpp.

References CompilationOptions::allow_lazy_fetch, cat_, CHECK(), CHECK_EQ, createCompoundWorkUnit(), createProjectWorkUnit(), DEBUG_TIMER, Default, executor_, CompilationOptions::filter_on_deleted_column, get_table_infos(), get_temporary_table(), Catalog_Namespace::Catalog::getMetadataForColumn(), CompilationOptions::hoist_literals, CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), CompilationOptions::makeCpuOnly(), ExecutionOptions::output_columnar_hint, temporary_tables_, and StorageIOFacility< RelAlgExecutorTraits >::yieldUpdateCallback().

Referenced by executeRelAlgStep().

1362  {
1363  CHECK(node);
1364  auto timer = DEBUG_TIMER(__func__);
1365 
1367 
1368  auto co = co_in;
1369  co.hoist_literals = false; // disable literal hoisting as it interferes with dict
1370  // encoded string updates
1371 
1372  auto execute_update_for_node =
1373  [this, &co, &eo_in](const auto node, auto& work_unit, const bool is_aggregate) {
1374  UpdateTransactionParameters update_params(node->getModifiedTableDescriptor(),
1375  node->getTargetColumns(),
1376  node->getOutputMetainfo(),
1377  node->isVarlenUpdateRequired());
1378 
1379  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
1380 
1381  auto execute_update_ra_exe_unit =
1382  [this, &co, &eo_in, &table_infos, &update_params](
1383  const RelAlgExecutionUnit& ra_exe_unit, const bool is_aggregate) {
1385 
1386  auto eo = eo_in;
1387  if (update_params.tableIsTemporary()) {
1388  eo.output_columnar_hint = true;
1389  co_project.allow_lazy_fetch = false;
1390  co_project.filter_on_deleted_column =
1391  false; // project the entire delete column for columnar update
1392  }
1393 
1394  auto update_callback = yieldUpdateCallback(update_params);
1395  executor_->executeUpdate(ra_exe_unit,
1396  table_infos,
1397  co_project,
1398  eo,
1399  cat_,
1400  executor_->row_set_mem_owner_,
1401  update_callback,
1402  is_aggregate);
1403  update_params.finalizeTransaction();
1404  };
1405 
1406  if (update_params.tableIsTemporary()) {
1407  // hold owned target exprs during execution if rewriting
1408  auto query_rewrite = std::make_unique<QueryRewriter>(table_infos, executor_);
1409  // rewrite temp table updates to generate the full column by moving the where
1410  // clause into a case if such a rewrite is not possible, bail on the update
1411  // operation build an expr for the update target
1412  const auto td = update_params.getTableDescriptor();
1413  CHECK(td);
1414  const auto update_column_names = update_params.getUpdateColumnNames();
1415  if (update_column_names.size() > 1) {
1416  throw std::runtime_error(
1417  "Multi-column update is not yet supported for temporary tables.");
1418  }
1419 
1420  auto cd = cat_.getMetadataForColumn(td->tableId, update_column_names.front());
1421  CHECK(cd);
1422  auto projected_column_to_update =
1423  makeExpr<Analyzer::ColumnVar>(cd->columnType, td->tableId, cd->columnId, 0);
1424  const auto rewritten_exe_unit = query_rewrite->rewriteColumnarUpdate(
1425  work_unit.exe_unit, projected_column_to_update);
1426  if (rewritten_exe_unit.target_exprs.front()->get_type_info().is_varlen()) {
1427  throw std::runtime_error(
1428  "Variable length updates not yet supported on temporary tables.");
1429  }
1430  execute_update_ra_exe_unit(rewritten_exe_unit, is_aggregate);
1431  } else {
1432  execute_update_ra_exe_unit(work_unit.exe_unit, is_aggregate);
1433  }
1434  };
1435 
1436  if (auto compound = dynamic_cast<const RelCompound*>(node)) {
1437  auto work_unit =
1438  createCompoundWorkUnit(compound, {{}, SortAlgorithm::Default, 0, 0}, eo_in);
1439 
1440  execute_update_for_node(compound, work_unit, compound->isAggregate());
1441  } else if (auto project = dynamic_cast<const RelProject*>(node)) {
1442  auto work_unit =
1443  createProjectWorkUnit(project, {{}, SortAlgorithm::Default, 0, 0}, eo_in);
1444 
1445  if (project->isSimple()) {
1446  CHECK_EQ(size_t(1), project->inputCount());
1447  const auto input_ra = project->getInput(0);
1448  if (dynamic_cast<const RelSort*>(input_ra)) {
1449  const auto& input_table =
1450  get_temporary_table(&temporary_tables_, -input_ra->getId());
1451  CHECK(input_table);
1452  work_unit.exe_unit.scan_limit = input_table->rowCount();
1453  }
1454  }
1455 
1456  execute_update_for_node(project, work_unit, false);
1457  } else {
1458  throw std::runtime_error("Unsupported parent node for update: " + node->toString());
1459  }
1460 }
#define CHECK_EQ(x, y)
Definition: Logger.h:205
UpdateCallback yieldUpdateCallback(UpdateTransactionParameters &update_parameters)
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const ExecutionOptions &eo)
TemporaryTables temporary_tables_
static void invalidateCaches()
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const ExecutionOptions &eo)
const ResultSetPtr & get_temporary_table(const TemporaryTables *temporary_tables, const int table_id)
Definition: Execute.h:157
static CompilationOptions makeCpuOnly(const CompilationOptions &in)
CHECK(cgen_state)
const Catalog_Namespace::Catalog & cat_
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
#define DEBUG_TIMER(name)
Definition: Logger.h:313
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 2654 of file RelAlgExecutor.cpp.

References GroupByAndAggregate::addTransientStringLiterals(), CompilationOptions::allow_lazy_fetch, RelAlgExecutor::WorkUnit::body, anonymous_namespace{RelAlgExecutor.cpp}::build_render_targets(), anonymous_namespace{RelAlgExecutor.cpp}::can_use_bump_allocator(), cat_, CHECK(), CHECK_EQ, CHECK_GT, anonymous_namespace{RelAlgExecutor.cpp}::compute_output_buffer_size(), computeWindow(), CPU, DEBUG_TIMER, anonymous_namespace{RelAlgExecutor.cpp}::decide_approx_count_distinct_implementation(), CompilationOptions::device_type, RelAlgExecutor::WorkUnit::exe_unit, anonymous_namespace{RelAlgExecutor.cpp}::exe_unit_has_quals(), executor_, ExecutionOptions::executor_type, Extern, ExecutionOptions::find_push_down_candidates, g_big_group_threshold, g_enable_window_functions, get_table_infos(), QueryExecutionError::getErrorCode(), getFilteredCountAll(), getNDVEstimation(), anonymous_namespace{RelAlgExecutor.cpp}::groups_approx_upper_bound(), handleOutOfMemoryRetry(), handlePersistentError(), INJECT_TIMER, anonymous_namespace{RelAlgExecutor.cpp}::is_agg(), anonymous_namespace{RelAlgExecutor.cpp}::is_window_execution_unit(), RenderInfo::isPotentialInSituRender(), isRowidLookup(), ExecutionOptions::just_calcite_explain, ExecutionOptions::just_explain, ExecutionOptions::just_validate, leaf_results_, RelAlgExecutor::WorkUnit::max_groups_buffer_entry_guess, ra_exec_unit_desc_for_caching(), run_benchmark_import::result, selectFiltersToBePushedDown(), RelAlgExecutionUnit::target_exprs, target_exprs_owned_, VLOG, and QueryExecutionError::wasMultifragKernelLaunch().

Referenced by executeAggregate(), executeCompound(), executeFilter(), executeProject(), executeSort(), and executeUnion().

2662  {
2664  auto timer = DEBUG_TIMER(__func__);
2665 
2666  auto co = co_in;
2667  ColumnCacheMap column_cache;
2668  if (is_window_execution_unit(work_unit.exe_unit)) {
2670  throw std::runtime_error("Window functions support is disabled");
2671  }
2672  co.device_type = ExecutorDeviceType::CPU;
2673  co.allow_lazy_fetch = false;
2674  computeWindow(work_unit.exe_unit, co, eo, column_cache, queue_time_ms);
2675  }
2676  if (!eo.just_explain && eo.find_push_down_candidates) {
2677  // find potential candidates:
2678  auto selected_filters = selectFiltersToBePushedDown(work_unit, co, eo);
2679  if (!selected_filters.empty() || eo.just_calcite_explain) {
2680  return ExecutionResult(selected_filters, eo.find_push_down_candidates);
2681  }
2682  }
2683  if (render_info && render_info->isPotentialInSituRender()) {
2684  co.allow_lazy_fetch = false;
2685  }
2686  const auto body = work_unit.body;
2687  CHECK(body);
2688  auto it = leaf_results_.find(body->getId());
2689  VLOG(3) << "body->getId()=" << body->getId() << " body->toString()=" << body->toString()
2690  << " it==leaf_results_.end()=" << (it == leaf_results_.end());
2691  if (it != leaf_results_.end()) {
2693  work_unit.exe_unit, executor_, executor_->row_set_mem_owner_);
2694  auto& aggregated_result = it->second;
2695  auto& result_rows = aggregated_result.rs;
2696  ExecutionResult result(result_rows, aggregated_result.targets_meta);
2697  body->setOutputMetainfo(aggregated_result.targets_meta);
2698  if (render_info) {
2699  build_render_targets(*render_info, work_unit.exe_unit.target_exprs, targets_meta);
2700  }
2701  return result;
2702  }
2703  const auto table_infos = get_table_infos(work_unit.exe_unit, executor_);
2704 
2706  work_unit.exe_unit, table_infos, executor_, co.device_type, target_exprs_owned_);
2707  auto max_groups_buffer_entry_guess = work_unit.max_groups_buffer_entry_guess;
2708  if (is_window_execution_unit(ra_exe_unit)) {
2709  CHECK_EQ(table_infos.size(), size_t(1));
2710  CHECK_EQ(table_infos.front().info.fragments.size(), size_t(1));
2711  max_groups_buffer_entry_guess =
2712  table_infos.front().info.fragments.front().getNumTuples();
2713  ra_exe_unit.scan_limit = max_groups_buffer_entry_guess;
2714  } else if (compute_output_buffer_size(ra_exe_unit) && !isRowidLookup(work_unit)) {
2715  if (previous_count > 0 && !exe_unit_has_quals(ra_exe_unit)) {
2716  ra_exe_unit.scan_limit = static_cast<size_t>(previous_count);
2717  } else {
2718  // TODO(adb): enable bump allocator path for render queries
2719  if (can_use_bump_allocator(ra_exe_unit, co, eo) && !render_info) {
2720  ra_exe_unit.scan_limit = 0;
2721  ra_exe_unit.use_bump_allocator = true;
2722  } else if (eo.executor_type == ::ExecutorType::Extern) {
2723  ra_exe_unit.scan_limit = 0;
2724  } else if (!eo.just_explain) {
2725  const auto filter_count_all = getFilteredCountAll(work_unit, true, co, eo);
2726  if (filter_count_all >= 0) {
2727  ra_exe_unit.scan_limit = std::max(filter_count_all, ssize_t(1));
2728  }
2729  }
2730  }
2731  }
2732 
2733  ExecutionResult result{std::make_shared<ResultSet>(std::vector<TargetInfo>{},
2734  co.device_type,
2736  nullptr,
2737  executor_),
2738  {}};
2739 
2740  auto execute_and_handle_errors =
2741  [&](const auto max_groups_buffer_entry_guess_in,
2742  const bool has_cardinality_estimation) -> ExecutionResult {
2743  // Note that the groups buffer entry guess may be modified during query execution.
2744  // Create a local copy so we can track those changes if we need to attempt a retry
2745  // due to OOM
2746  auto local_groups_buffer_entry_guess = max_groups_buffer_entry_guess_in;
2747  try {
2748  return {executor_->executeWorkUnit(local_groups_buffer_entry_guess,
2749  is_agg,
2750  table_infos,
2751  ra_exe_unit,
2752  co,
2753  eo,
2754  cat_,
2755  executor_->row_set_mem_owner_,
2756  render_info,
2757  has_cardinality_estimation,
2758  column_cache),
2759  targets_meta};
2760  } catch (const QueryExecutionError& e) {
2762  return handleOutOfMemoryRetry(
2763  {ra_exe_unit, work_unit.body, local_groups_buffer_entry_guess},
2764  targets_meta,
2765  is_agg,
2766  co,
2767  eo,
2768  render_info,
2770  queue_time_ms);
2771  }
2772  };
2773  auto cache_key = ra_exec_unit_desc_for_caching(ra_exe_unit);
2774  try {
2775  auto cached_cardinality = executor_->getCachedCardinality(cache_key);
2776  auto card = cached_cardinality.second;
2777  if (cached_cardinality.first && card >= 0) {
2778  result = execute_and_handle_errors(card, true);
2779  } else {
2780  result = execute_and_handle_errors(
2781  max_groups_buffer_entry_guess,
2783  }
2784  VLOG(3) << "result.getRows()->entryCount()=" << result.getRows()->entryCount();
2785  } catch (const CardinalityEstimationRequired&) {
2786  // check the cardinality cache
2787  auto cached_cardinality = executor_->getCachedCardinality(cache_key);
2788  auto card = cached_cardinality.second;
2789  if (cached_cardinality.first && card >= 0) {
2790  result = execute_and_handle_errors(card, true);
2791  } else {
2792  const auto estimated_groups_buffer_entry_guess =
2793  2 * std::min(groups_approx_upper_bound(table_infos),
2794  getNDVEstimation(work_unit, is_agg, co, eo));
2795  CHECK_GT(estimated_groups_buffer_entry_guess, size_t(0));
2796  result = execute_and_handle_errors(estimated_groups_buffer_entry_guess, true);
2797  if (!(eo.just_validate || eo.just_explain)) {
2798  executor_->addToCardinalityCache(cache_key, estimated_groups_buffer_entry_guess);
2799  }
2800  }
2801  }
2802 
2803  result.setQueueTime(queue_time_ms);
2804  if (render_info) {
2805  build_render_targets(*render_info, work_unit.exe_unit.target_exprs, targets_meta);
2806  if (render_info->isPotentialInSituRender()) {
2807  // return an empty result (with the same queue time, and zero render time)
2808  return {std::make_shared<ResultSet>(
2809  queue_time_ms,
2810  0,
2811  executor_->row_set_mem_owner_
2812  ? executor_->row_set_mem_owner_->cloneStrDictDataOnly()
2813  : nullptr),
2814  {}};
2815  }
2816  }
2817  return result;
2818 }
bool is_agg(const Analyzer::Expr *expr)
#define CHECK_EQ(x, y)
Definition: Logger.h:205
int32_t getErrorCode() const
Definition: ErrorHandling.h:55
bool can_use_bump_allocator(const RelAlgExecutionUnit &ra_exe_unit, const CompilationOptions &co, const ExecutionOptions &eo)
std::string ra_exec_unit_desc_for_caching(const RelAlgExecutionUnit &ra_exe_unit)
Definition: Execute.cpp:1190
std::vector< PushedDownFilterInfo > selectFiltersToBePushedDown(const RelAlgExecutor::WorkUnit &work_unit, const CompilationOptions &co, const ExecutionOptions &eo)
std::unordered_map< unsigned, AggregatedResult > leaf_results_
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:209
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_
const bool find_push_down_candidates
CHECK(cgen_state)
const bool just_validate
ExecutorType executor_type
#define INJECT_TIMER(DESC)
Definition: measure.h:91
const Catalog_Namespace::Catalog & cat_
size_t g_big_group_threshold
Definition: Execute.cpp:97
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)
void build_render_targets(RenderInfo &render_info, const std::vector< Analyzer::Expr * > &work_unit_target_exprs, const std::vector< TargetMetaInfo > &targets_meta)
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
bool g_enable_window_functions
Definition: Execute.cpp:98
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)
bool wasMultifragKernelLaunch() const
Definition: ErrorHandling.h:57
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)
bool isPotentialInSituRender() const
Definition: RenderInfo.cpp:64
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
#define DEBUG_TIMER(name)
Definition: Logger.h:313
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_
#define VLOG(n)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 3046 of file RelAlgExecutor.cpp.

References Executor::ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED, Executor::ERR_DIV_BY_ZERO, Executor::ERR_GEOS, 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_SINGLE_VALUE_FOUND_MULTIPLE_VALUES, 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(), and handlePersistentError().

3046  {
3047  if (error_code < 0) {
3048  return "Ran out of slots in the query output buffer";
3049  }
3050  switch (error_code) {
3052  return "Division by zero";
3054  return "Query couldn't keep the entire working set of columns in GPU memory";
3056  return "Self joins not supported yet";
3058  return "Not enough host memory to execute the query";
3060  return "Overflow or underflow";
3062  return "Query execution has exceeded the time limit";
3064  return "Query execution has been interrupted";
3066  return "Columnar conversion not supported for variable length types";
3068  return "Too many literals in the query";
3070  return "NONE ENCODED String types are not supported as input result set.";
3072  return "Not enough OpenGL memory to render the query results";
3074  return "Streaming-Top-N not supported in Render Query";
3076  return "Multiple distinct values encountered";
3077  case Executor::ERR_GEOS:
3078  return "Geos call failure";
3079  }
3080  return "Other error: code " + std::to_string(error_code);
3081 }
static const int32_t ERR_INTERRUPTED
Definition: Execute.h:943
static const int32_t ERR_GEOS
Definition: Execute.h:949
static const int32_t ERR_TOO_MANY_LITERALS
Definition: Execute.h:945
std::string to_string(char const *&&v)
static const int32_t ERR_STRING_CONST_IN_RESULTSET
Definition: Execute.h:946
static const int32_t ERR_STREAMING_TOP_N_NOT_SUPPORTED_IN_RENDER_QUERY
Definition: Execute.h:947
static const int32_t ERR_COLUMNAR_CONVERSION_NOT_SUPPORTED
Definition: Execute.h:944
static const int32_t ERR_DIV_BY_ZERO
Definition: Execute.h:935
static const int32_t ERR_OUT_OF_RENDER_MEM
Definition: Execute.h:939
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:941
static const int32_t ERR_OUT_OF_TIME
Definition: Execute.h:942
static const int32_t ERR_UNSUPPORTED_SELF_JOIN
Definition: Execute.h:938
static const int32_t ERR_SINGLE_VALUE_FOUND_MULTIPLE_VALUES
Definition: Execute.h:948
static const int32_t ERR_OUT_OF_GPU_MEM
Definition: Execute.h:936
static const int32_t ERR_OUT_OF_CPU_MEM
Definition: Execute.h:940

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Executor * RelAlgExecutor::getExecutor ( ) const

Definition at line 390 of file RelAlgExecutor.cpp.

References executor_.

390  {
391  return executor_;
392 }
Executor * executor_
ssize_t RelAlgExecutor::getFilteredCountAll ( const WorkUnit work_unit,
const bool  is_agg,
const CompilationOptions co,
const ExecutionOptions eo 
)
private

Definition at line 2820 of file RelAlgExecutor.cpp.

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

Referenced by executeWorkUnit().

2823  {
2824  const auto count =
2825  makeExpr<Analyzer::AggExpr>(SQLTypeInfo(g_bigint_count ? kBIGINT : kINT, false),
2826  kCOUNT,
2827  nullptr,
2828  false,
2829  nullptr);
2830  const auto count_all_exe_unit =
2831  create_count_all_execution_unit(work_unit.exe_unit, count);
2832  size_t one{1};
2833  ResultSetPtr count_all_result;
2834  try {
2835  ColumnCacheMap column_cache;
2836  count_all_result =
2837  executor_->executeWorkUnit(one,
2838  is_agg,
2839  get_table_infos(work_unit.exe_unit, executor_),
2840  count_all_exe_unit,
2841  co,
2842  eo,
2843  cat_,
2844  executor_->row_set_mem_owner_,
2845  nullptr,
2846  false,
2847  column_cache);
2848  } catch (const std::exception& e) {
2849  LOG(WARNING) << "Failed to run pre-flight filtered count with error " << e.what();
2850  return -1;
2851  }
2852  const auto count_row = count_all_result->getNextRow(false, false);
2853  CHECK_EQ(size_t(1), count_row.size());
2854  const auto& count_tv = count_row.front();
2855  const auto count_scalar_tv = boost::get<ScalarTargetValue>(&count_tv);
2856  CHECK(count_scalar_tv);
2857  const auto count_ptr = boost::get<int64_t>(count_scalar_tv);
2858  CHECK(count_ptr);
2859  CHECK_GE(*count_ptr, 0);
2860  auto count_upper_bound = static_cast<size_t>(*count_ptr);
2861  return std::max(count_upper_bound, size_t(1));
2862 }
bool is_agg(const Analyzer::Expr *expr)
#define CHECK_EQ(x, y)
Definition: Logger.h:205
#define LOG(tag)
Definition: Logger.h:188
#define CHECK_GE(x, y)
Definition: Logger.h:210
std::shared_ptr< ResultSet > ResultSetPtr
RelAlgExecutionUnit create_count_all_execution_unit(const RelAlgExecutionUnit &ra_exe_unit, std::shared_ptr< Analyzer::Expr > replacement_target)
CHECK(cgen_state)
const Catalog_Namespace::Catalog & cat_
bool g_bigint_count
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
Definition: sqldefs.h:76
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
Definition: sqltypes.h:46
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 cat_, CHECK(), CHECK_EQ, Default, executor_, g_bigint_count, get_table_infos(), kBIGINT, kCOUNT, and kINT.

Referenced by selectFiltersToBePushedDown().

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:205
std::shared_ptr< ResultSet > ResultSetPtr
CHECK(cgen_state)
const Catalog_Namespace::Catalog & cat_
bool g_bigint_count
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
Definition: sqldefs.h:76
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
Definition: sqltypes.h:46
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Referenced by executeWorkUnit().

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 }
bool is_agg(const Analyzer::Expr *expr)
int32_t getErrorCode() const
Definition: ErrorHandling.h:55
static const int32_t ERR_INTERRUPTED
Definition: Execute.h:943
#define UNREACHABLE()
Definition: Logger.h:241
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:942
std::unordered_map< int, std::unordered_map< int, std::shared_ptr< const ColumnarResults >>> ColumnCacheMap
std::vector< InputTableInfo > get_table_infos(const std::vector< InputDescriptor > &input_descs, Executor *executor)
static std::string getErrorMessageFromCode(const int32_t error_code)
Executor * executor_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t RelAlgExecutor::getOuterFragmentCount ( const CompilationOptions co,
const ExecutionOptions eo 
)

Definition at line 73 of file RelAlgExecutor.cpp.

References cat_, CHECK(), cleanupPostExecution(), createCompoundWorkUnit(), createProjectWorkUnit(), Default, executor_, ExecutionOptions::find_push_down_candidates, get_frag_count_of_table(), get_physical_inputs(), get_physical_table_inputs(), getSubqueries(), ExecutionOptions::just_explain, query_dag_, WindowProjectNodeContext::reset(), target_exprs_owned_, and temporary_tables_.

74  {
76  return 0;
77  }
78 
79  if (eo.just_explain) {
80  return 0;
81  }
82 
84 
85  query_dag_->resetQueryExecutionState();
86  const auto& ra = query_dag_->getRootNode();
87 
88  mapd_shared_lock<mapd_shared_mutex> lock(executor_->execute_mutex_);
89  ScopeGuard row_set_holder = [this] { cleanupPostExecution(); };
90  const auto phys_inputs = get_physical_inputs(cat_, &ra);
91  const auto phys_table_ids = get_physical_table_inputs(&ra);
92  executor_->setCatalog(&cat_);
93  executor_->setupCaching(phys_inputs, phys_table_ids);
94 
95  ScopeGuard restore_metainfo_cache = [this] { executor_->clearMetaInfoCache(); };
96  auto ed_seq = RaExecutionSequence(&ra);
97 
98  if (!getSubqueries().empty()) {
99  return 0;
100  }
101 
102  CHECK(!ed_seq.empty());
103  if (ed_seq.size() > 1) {
104  return 0;
105  }
106 
107  decltype(temporary_tables_)().swap(temporary_tables_);
108  decltype(target_exprs_owned_)().swap(target_exprs_owned_);
109  executor_->catalog_ = &cat_;
110  executor_->temporary_tables_ = &temporary_tables_;
111 
113  auto exec_desc_ptr = ed_seq.getDescriptor(0);
114  CHECK(exec_desc_ptr);
115  auto& exec_desc = *exec_desc_ptr;
116  const auto body = exec_desc.getBody();
117  if (body->isNop()) {
118  return 0;
119  }
120 
121  const auto project = dynamic_cast<const RelProject*>(body);
122  if (project) {
123  auto work_unit =
124  createProjectWorkUnit(project, {{}, SortAlgorithm::Default, 0, 0}, eo);
125 
126  return get_frag_count_of_table(work_unit.exe_unit.input_descs[0].getTableId(),
127  executor_);
128  }
129 
130  const auto compound = dynamic_cast<const RelCompound*>(body);
131  if (compound) {
132  if (compound->isDeleteViaSelect()) {
133  return 0;
134  } else if (compound->isUpdateViaSelect()) {
135  return 0;
136  } else {
137  if (compound->isAggregate()) {
138  return 0;
139  }
140 
141  const auto work_unit =
142  createCompoundWorkUnit(compound, {{}, SortAlgorithm::Default, 0, 0}, eo);
143 
144  return get_frag_count_of_table(work_unit.exe_unit.input_descs[0].getTableId(),
145  executor_);
146  }
147  }
148 
149  return 0;
150 }
WorkUnit createProjectWorkUnit(const RelProject *, const SortInfo &, const ExecutionOptions &eo)
TemporaryTables temporary_tables_
const std::vector< std::shared_ptr< RexSubQuery > > & getSubqueries() const noexcept
WorkUnit createCompoundWorkUnit(const RelCompound *, const SortInfo &, const ExecutionOptions &eo)
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
const bool find_push_down_candidates
CHECK(cgen_state)
static void reset(Executor *executor)
A container for relational algebra descriptors defining the execution order for a relational algebra ...
const Catalog_Namespace::Catalog & cat_
std::unique_ptr< RelAlgDagBuilder > query_dag_
void cleanupPostExecution()
std::unordered_set< PhysicalInput > get_physical_inputs(const RelAlgNode *ra)
size_t get_frag_count_of_table(const int table_id, Executor *executor)
Executor * executor_
std::unordered_set< int > get_physical_table_inputs(const RelAlgNode *ra)

+ Here is the call graph for this function:

const QueryHint RelAlgExecutor::getParsedQueryHints ( ) const
inline

Definition at line 143 of file RelAlgExecutor.h.

References CHECK(), and query_dag_.

Referenced by DBHandler::execute_rel_alg(), DBHandler::execute_rel_alg_df(), Parser::LocalConnector::getOuterFragmentCount(), QueryRunner::QueryRunner::getParsedQueryHintofQuery(), QueryRunner::anonymous_namespace{QueryRunner.cpp}::run_select_query_with_filter_push_down(), and QueryRunner::QueryRunner::runSelectQuery().

143  {
144  CHECK(query_dag_);
145  return query_dag_->getQueryHints();
146  }
CHECK(cgen_state)
std::unique_ptr< RelAlgDagBuilder > query_dag_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const RelAlgNode& RelAlgExecutor::getRootRelAlgNode ( ) const
inline

Definition at line 135 of file RelAlgExecutor.h.

References CHECK(), and query_dag_.

Referenced by computeColRangesCache(), computeStringDictionaryGenerations(), and computeTableGenerations().

135  {
136  CHECK(query_dag_);
137  return query_dag_->getRootNode();
138  }
CHECK(cgen_state)
std::unique_ptr< RelAlgDagBuilder > query_dag_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 139 of file RelAlgExecutor.h.

References CHECK(), and query_dag_.

Referenced by executeRelAlgQueryNoRetry(), executeRelAlgQueryWithFilterPushDown(), and getOuterFragmentCount().

139  {
140  CHECK(query_dag_);
141  return query_dag_->getSubqueries();
142  };
CHECK(cgen_state)
std::unique_ptr< RelAlgDagBuilder > query_dag_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RelAlgExecutor::handleNop ( RaExecutionDesc ed)
private

Definition at line 707 of file RelAlgExecutor.cpp.

References addTemporaryTable(), CHECK(), CHECK_EQ, RaExecutionDesc::getBody(), and temporary_tables_.

Referenced by executeRelAlgStep().

707  {