OmniSciDB  04ee39c94c
Analyzer::Expr Class Referenceabstract

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::Expr:
+ Collaboration diagram for Analyzer::Expr:

Public Member Functions

 Expr (SQLTypes t, bool notnull)
 
 Expr (SQLTypes t, int d, bool notnull)
 
 Expr (SQLTypes t, int d, int s, bool notnull)
 
 Expr (const SQLTypeInfo &ti, bool has_agg=false)
 
virtual ~Expr ()
 
const SQLTypeInfoget_type_info () const
 
void set_type_info (const SQLTypeInfo &ti)
 
bool get_contains_agg () const
 
void set_contains_agg (bool a)
 
virtual std::shared_ptr< Analyzer::Expradd_cast (const SQLTypeInfo &new_type_info)
 
virtual void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const
 
virtual std::shared_ptr< Analyzer::Exprdeep_copy () const =0
 
virtual std::shared_ptr< Analyzer::Exprnormalize_simple_predicate (int &rte_idx) const
 
virtual void group_predicates (std::list< const Expr *> &scan_predicates, std::list< const Expr *> &join_predicates, std::list< const Expr *> &const_predicates) const
 
virtual void collect_rte_idx (std::set< int > &rte_idx_set) const
 
virtual void collect_column_var (std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const
 
virtual std::shared_ptr< Analyzer::Exprrewrite_with_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
 
virtual std::shared_ptr< Analyzer::Exprrewrite_with_child_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
 
virtual std::shared_ptr< Analyzer::Exprrewrite_agg_to_var (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
 
virtual bool operator== (const Expr &rhs) const =0
 
virtual std::string toString () const =0
 
virtual void print () const
 
virtual void add_unique (std::list< const Expr *> &expr_list) const
 
virtual void find_expr (bool(*f)(const Expr *), std::list< const Expr *> &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Protected Attributes

SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 67 of file Analyzer.h.

Constructor & Destructor Documentation

◆ Expr() [1/4]

Analyzer::Expr::Expr ( SQLTypes  t,
bool  notnull 
)
inline

Definition at line 69 of file Analyzer.h.

69 : type_info(t, notnull), contains_agg(false) {}
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176

◆ Expr() [2/4]

Analyzer::Expr::Expr ( SQLTypes  t,
int  d,
bool  notnull 
)
inline

Definition at line 70 of file Analyzer.h.

71  : type_info(t, d, 0, notnull), contains_agg(false) {}
void d(const SQLTypes expected_type, const std::string &str)
Definition: ImportTest.cpp:268
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176

◆ Expr() [3/4]

Analyzer::Expr::Expr ( SQLTypes  t,
int  d,
int  s,
bool  notnull 
)
inline

Definition at line 72 of file Analyzer.h.

73  : type_info(t, d, s, notnull), contains_agg(false) {}
void d(const SQLTypes expected_type, const std::string &str)
Definition: ImportTest.cpp:268
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176

◆ Expr() [4/4]

Analyzer::Expr::Expr ( const SQLTypeInfo ti,
bool  has_agg = false 
)
inline

Definition at line 74 of file Analyzer.h.

75  : type_info(ti), contains_agg(has_agg) {}
SQLTypeInfo type_info
Definition: Analyzer.h:175
bool contains_agg
Definition: Analyzer.h:176

◆ ~Expr()

virtual Analyzer::Expr::~Expr ( )
inlinevirtual

Definition at line 76 of file Analyzer.h.

76 {}

Member Function Documentation

◆ add_cast()

std::shared_ptr< Analyzer::Expr > Analyzer::Expr::add_cast ( const SQLTypeInfo new_type_info)
virtual

Reimplemented in Analyzer::CaseExpr, Analyzer::Subquery, Analyzer::UOper, and Analyzer::Constant.

Definition at line 663 of file Analyzer.cpp.

References Analyzer::Constant::Constant(), contains_agg, SQLTypeInfoCore< TYPE_FACET_PACK >::get_comp_param(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type_name(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_castable(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_string(), kCAST, kENCODING_DICT, TRANSIENT_DICT, TRANSIENT_DICT_ID, and type_info.

Referenced by Analyzer::Constant::add_cast(), Analyzer::UOper::add_cast(), and Parser::QuerySpec::analyze_group_by().

663  {
664  if (new_type_info == type_info) {
665  return shared_from_this();
666  }
667  if (new_type_info.is_string() && type_info.is_string() &&
668  new_type_info.get_compression() == kENCODING_DICT &&
670  (new_type_info.get_comp_param() == type_info.get_comp_param() ||
671  new_type_info.get_comp_param() == TRANSIENT_DICT(type_info.get_comp_param()))) {
672  return shared_from_this();
673  }
674  if (!type_info.is_castable(new_type_info)) {
675  throw std::runtime_error("Cannot CAST from " + type_info.get_type_name() + " to " +
676  new_type_info.get_type_name());
677  }
678  // @TODO(wei) temporary restriction until executor can support this.
679  if (typeid(*this) != typeid(Constant) && new_type_info.is_string() &&
680  new_type_info.get_compression() == kENCODING_DICT &&
681  new_type_info.get_comp_param() <= TRANSIENT_DICT_ID) {
683  throw std::runtime_error(
684  "Cannot group by string columns which are not dictionary encoded.");
685  }
686  throw std::runtime_error(
687  "Internal error: Cannot apply transient dictionary encoding to non-literal "
688  "expression "
689  "yet.");
690  }
691  return makeExpr<UOper>(new_type_info, contains_agg, kCAST, shared_from_this());
692 }
Definition: sqldefs.h:49
bool is_castable(const SQLTypeInfoCore &new_type_info) const
Definition: sqltypes.h:510
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
SQLTypeInfo type_info
Definition: Analyzer.h:175
std::string get_type_name() const
Definition: sqltypes.h:426
#define TRANSIENT_DICT_ID
Definition: sqltypes.h:186
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:332
bool contains_agg
Definition: Analyzer.h:176
bool is_string() const
Definition: sqltypes.h:450
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:187
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_unique()

void Analyzer::Expr::add_unique ( std::list< const Expr *> &  expr_list) const
virtual

Definition at line 2585 of file Analyzer.cpp.

Referenced by Analyzer::UOper::find_expr(), Analyzer::BinOper::find_expr(), Analyzer::InValues::find_expr(), Analyzer::CharLengthExpr::find_expr(), Analyzer::KeyForStringExpr::find_expr(), Analyzer::CardinalityExpr::find_expr(), Analyzer::LikeExpr::find_expr(), Analyzer::RegexpExpr::find_expr(), Analyzer::LikelihoodExpr::find_expr(), Analyzer::AggExpr::find_expr(), Analyzer::CaseExpr::find_expr(), Analyzer::ExtractExpr::find_expr(), Analyzer::DateaddExpr::find_expr(), Analyzer::DatediffExpr::find_expr(), Analyzer::DatetruncExpr::find_expr(), and Analyzer::CaseExpr::get_domain().

2585  {
2586  // only add unique instances to the list
2587  for (auto e : expr_list) {
2588  if (*e == *this) {
2589  return;
2590  }
2591  }
2592  expr_list.push_back(this);
2593 }
+ Here is the caller graph for this function:

◆ check_group_by()

virtual void Analyzer::Expr::check_group_by ( const std::list< std::shared_ptr< Analyzer::Expr >> &  groupby) const
inlinevirtual

◆ collect_column_var()

virtual void Analyzer::Expr::collect_column_var ( std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &  colvar_set,
bool  include_agg 
) const
inlinevirtual

◆ collect_rte_idx()

◆ decompress()

std::shared_ptr< Analyzer::Expr > Analyzer::Expr::decompress ( )

Definition at line 649 of file Analyzer.cpp.

References contains_agg, SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_dimension(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_notnull(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_scale(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_subtype(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kCAST, kENCODING_NONE, and type_info.

649  {
651  return shared_from_this();
652  }
653  SQLTypeInfo new_type_info(type_info.get_type(),
658  0,
660  return makeExpr<UOper>(new_type_info, contains_agg, kCAST, shared_from_this());
661 }
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:325
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:330
HOST DEVICE int get_scale() const
Definition: sqltypes.h:328
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:323
Definition: sqldefs.h:49
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
SQLTypeInfo type_info
Definition: Analyzer.h:175
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:324
bool contains_agg
Definition: Analyzer.h:176
+ Here is the call graph for this function:

◆ deep_copy()

◆ find_expr()

virtual void Analyzer::Expr::find_expr ( bool(*)(const Expr *)  f,
std::list< const Expr *> &  expr_list 
) const
inlinevirtual

Reimplemented in Analyzer::DatetruncExpr, Analyzer::DatediffExpr, Analyzer::DateaddExpr, Analyzer::ExtractExpr, Analyzer::CaseExpr, Analyzer::AggExpr, Analyzer::LikelihoodExpr, Analyzer::RegexpExpr, Analyzer::LikeExpr, Analyzer::CardinalityExpr, Analyzer::KeyForStringExpr, Analyzer::CharLengthExpr, Analyzer::InValues, Analyzer::Subquery, Analyzer::BinOper, and Analyzer::UOper.

Definition at line 158 of file Analyzer.h.

References decompress().

Referenced by anonymous_namespace{LogicalIR.cpp}::contains_unsafe_division(), and Planner::Optimizer::optimize_aggs().

159  {
160  if (f(this)) {
161  add_unique(expr_list);
162  }
163  }
virtual void add_unique(std::list< const Expr *> &expr_list) const
Definition: Analyzer.cpp:2585
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_contains_agg()

◆ get_domain()

virtual void Analyzer::Expr::get_domain ( DomainSet domain_set) const
inlinevirtual

Reimplemented in Analyzer::CaseExpr.

Definition at line 172 of file Analyzer.h.

172 { domain_set.clear(); }

◆ get_type_info()

const SQLTypeInfo& Analyzer::Expr::get_type_info ( ) const
inline

Definition at line 77 of file Analyzer.h.

Referenced by anonymous_namespace{GroupByAndAggregate.cpp}::add_transient_string_literals_for_expression(), Parser::ArrayLiteral::analyze(), anonymous_namespace{ExtensionsIR.cpp}::call_requires_custom_type_handling(), CodeGenerator::checkExpressionRanges(), CodeGenerator::codegen(), GroupByAndAggregate::codegenAggArg(), CodeGenerator::codegenArith(), CodeGenerator::codegenArrayAt(), CodeGenerator::codegenArrayExpr(), CodeGenerator::codegenCast(), CodeGenerator::codegenCmp(), CodeGenerator::codegenCmpDecimalConst(), CodeGenerator::codegenColVar(), GroupByAndAggregate::codegenCountDistinct(), CodeGenerator::codegenDeciDiv(), CodeGenerator::codegenDictLike(), CodeGenerator::codegenDictRegexp(), CodeGenerator::codegenFixedLengthColVar(), CodeGenerator::codegenFixedLengthColVarInWindow(), CodeGenerator::codegenFpArith(), CodeGenerator::codegenFunctionOper(), CodeGenerator::codegenFunctionOperCastArgs(), CodeGenerator::codegenFunctionOperNullArg(), CodeGenerator::codegenFunctionOperWithCustomTypeHandling(), CodeGenerator::codegenIntArith(), CodeGenerator::codegenIntConst(), CodeGenerator::codegenLogical(), CodeGenerator::codegenLogicalShortCircuit(), CodeGenerator::codegenOuterJoinNullPlaceholder(), CodeGenerator::codegenQualifierCmp(), CodeGenerator::codegenUMinus(), ScalarCodeGenerator::compile(), CodeGenerator::createInValuesBitmap(), Analyzer::InIntegerSet::deep_copy(), CodeGenerator::endArgsNullcheck(), Parser::anonymous_namespace{ParserNode.cpp}::expr_is_null(), anonymous_namespace{ExtensionsIR.cpp}::ext_func_call_requires_nullcheck(), BaselineJoinHashTable::fetchColumn(), JoinHashTable::fetchFragments(), JoinHashTable::genHashTableKey(), anonymous_namespace{WindowFunctionIR.cpp}::get_adjusted_window_type_info(), anonymous_namespace{GroupByAndAggregate.cpp}::get_agg_count(), get_agg_type(), anonymous_namespace{ColumnIR.cpp}::get_col_bit_width(), anonymous_namespace{ColumnIR.cpp}::get_col_decoder(), anonymous_namespace{FromTableReordering.cpp}::get_join_qual_cost(), get_target_info(), ColumnFetcher::getAllColumnFragments(), getExpressionRange(), JoinHashTable::getHashJoinArgs(), getLeafColumnRange(), CgenState::getOrAddLiteral(), GroupByAndAggregate::gpuCanHandleOrderEntries(), Executor::groupByColumnCodegen(), CodeGenerator::hashJoinLhs(), GroupByAndAggregate::initCountDistinctDescriptors(), Analyzer::anonymous_namespace{Analyzer.cpp}::is_expr_nullable(), anonymous_namespace{CompareIR.cpp}::lower_bw_eq(), WindowFunctionContext::makeComparator(), anonymous_namespace{DateTimePlusRewrite.cpp}::match_const_integer(), anonymous_namespace{WindowExpressionRewrite.cpp}::matches_gt_bigint_zero(), normalize_column_pair(), Analyzer::Constant::operator==(), Analyzer::FunctionOper::operator==(), Analyzer::FunctionOperWithCustomTypeHandling::operator==(), QueryMemoryDescriptor::pick_target_compact_width(), anonymous_namespace{DateTimePlusRewrite.cpp}::remove_cast_to_date(), remove_cast_to_int(), Analyzer::ColumnVar::rewrite_agg_to_var(), Analyzer::Var::rewrite_agg_to_var(), Analyzer::AggExpr::rewrite_agg_to_var(), Analyzer::ColumnVar::rewrite_with_child_targetlist(), anonymous_namespace{LogicalIR.cpp}::should_defer_eval(), Analyzer::BinOper::simple_predicate_has_simple_cast(), Analyzer::ColumnVar::toString(), var_ref(), DeepCopyVisitor::visitAggExpr(), DeepCopyVisitor::visitArrayOper(), anonymous_namespace{ExpressionRewrite.cpp}::ArrayElementStringLiteralEncodingVisitor::visitArrayOper(), DeepCopyVisitor::visitBinOper(), anonymous_namespace{ExpressionRewrite.cpp}::RecursiveOrToInVisitor::visitBinOper(), anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitBinOper(), DeepCopyVisitor::visitCaseExpr(), anonymous_namespace{JoinFilterPushDown.cpp}::BindFilterToOutermostVisitor::visitColumnVar(), DeepCopyVisitor::visitDateaddExpr(), DeepCopyVisitor::visitDatediffExpr(), DeepCopyVisitor::visitDatetruncExpr(), DeepCopyVisitor::visitExtractExpr(), DeepCopyVisitor::visitFunctionOper(), DeepCopyVisitor::visitFunctionOperWithCustomTypeHandling(), DeepCopyVisitor::visitInIntegerSet(), DeepCopyVisitor::visitUOper(), anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitUOper(), DeepCopyVisitor::visitWindowFunction(), and anonymous_namespace{WindowExpressionRewrite.cpp}::window_sum_and_count_match().

77 { return type_info; }
SQLTypeInfo type_info
Definition: Analyzer.h:175

◆ group_predicates()

virtual void Analyzer::Expr::group_predicates ( std::list< const Expr *> &  scan_predicates,
std::list< const Expr *> &  join_predicates,
std::list< const Expr *> &  const_predicates 
) const
inlinevirtual

◆ normalize_simple_predicate()

virtual std::shared_ptr<Analyzer::Expr> Analyzer::Expr::normalize_simple_predicate ( int &  rte_idx) const
inlinevirtual

Reimplemented in Analyzer::BinOper.

Definition at line 93 of file Analyzer.h.

93  {
94  rte_idx = -1;
95  return nullptr;
96  }

◆ operator==()

◆ print()

virtual void Analyzer::Expr::print ( ) const
inlinevirtual

Definition at line 149 of file Analyzer.h.

149 { std::cout << toString(); }
virtual std::string toString() const =0

◆ rewrite_agg_to_var()

virtual std::shared_ptr<Analyzer::Expr> Analyzer::Expr::rewrite_agg_to_var ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlinevirtual

Reimplemented in Analyzer::DatetruncExpr, Analyzer::DatediffExpr, Analyzer::DateaddExpr, Analyzer::ExtractExpr, Analyzer::CaseExpr, Analyzer::AggExpr, Analyzer::LikelihoodExpr, Analyzer::RegexpExpr, Analyzer::LikeExpr, Analyzer::CardinalityExpr, Analyzer::KeyForStringExpr, Analyzer::CharLengthExpr, Analyzer::InValues, Analyzer::Subquery, Analyzer::BinOper, Analyzer::UOper, Analyzer::Var, and Analyzer::ColumnVar.

Definition at line 143 of file Analyzer.h.

References operator==().

144  {
145  return deep_copy();
146  }
virtual std::shared_ptr< Analyzer::Expr > deep_copy() const =0
+ Here is the call graph for this function:

◆ rewrite_with_child_targetlist()

virtual std::shared_ptr<Analyzer::Expr> Analyzer::Expr::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlinevirtual

◆ rewrite_with_targetlist()

virtual std::shared_ptr<Analyzer::Expr> Analyzer::Expr::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlinevirtual

◆ set_contains_agg()

void Analyzer::Expr::set_contains_agg ( bool  a)
inline

Definition at line 80 of file Analyzer.h.

80 { contains_agg = a; }
bool contains_agg
Definition: Analyzer.h:176

◆ set_type_info()

void Analyzer::Expr::set_type_info ( const SQLTypeInfo ti)
inline

Definition at line 78 of file Analyzer.h.

78 { type_info = ti; }
SQLTypeInfo type_info
Definition: Analyzer.h:175

◆ toString()

Member Data Documentation

◆ contains_agg

◆ type_info

SQLTypeInfo Analyzer::Expr::type_info
protected

Definition at line 175 of file Analyzer.h.

Referenced by add_cast(), Analyzer::Constant::add_cast(), Analyzer::UOper::add_cast(), Analyzer::CaseExpr::add_cast(), Analyzer::Constant::cast_from_string(), Analyzer::Constant::cast_number(), Analyzer::Constant::cast_string(), Analyzer::Constant::cast_to_string(), decompress(), Analyzer::ColumnVar::deep_copy(), Analyzer::Var::deep_copy(), Analyzer::Constant::deep_copy(), Analyzer::UOper::deep_copy(), Analyzer::BinOper::deep_copy(), Analyzer::AggExpr::deep_copy(), Analyzer::CaseExpr::deep_copy(), Analyzer::ExtractExpr::deep_copy(), Analyzer::DateaddExpr::deep_copy(), Analyzer::DatediffExpr::deep_copy(), Analyzer::DatetruncExpr::deep_copy(), Analyzer::FunctionOper::deep_copy(), Analyzer::FunctionOperWithCustomTypeHandling::deep_copy(), Analyzer::WindowFunction::deep_copy(), Analyzer::ArrayExpr::deep_copy(), Analyzer::Constant::do_cast(), Analyzer::ColumnVar::group_predicates(), Analyzer::BinOper::normalize_simple_predicate(), Analyzer::Constant::operator==(), Analyzer::FunctionOper::operator==(), Analyzer::FunctionOperWithCustomTypeHandling::operator==(), Analyzer::CaseExpr::rewrite_agg_to_var(), Analyzer::ExtractExpr::rewrite_agg_to_var(), Analyzer::DateaddExpr::rewrite_agg_to_var(), Analyzer::DatediffExpr::rewrite_agg_to_var(), Analyzer::DatetruncExpr::rewrite_agg_to_var(), Analyzer::AggExpr::rewrite_with_child_targetlist(), Analyzer::CaseExpr::rewrite_with_child_targetlist(), Analyzer::ExtractExpr::rewrite_with_child_targetlist(), Analyzer::DateaddExpr::rewrite_with_child_targetlist(), Analyzer::DatediffExpr::rewrite_with_child_targetlist(), Analyzer::DatetruncExpr::rewrite_with_child_targetlist(), Analyzer::CaseExpr::rewrite_with_targetlist(), Analyzer::ExtractExpr::rewrite_with_targetlist(), Analyzer::DateaddExpr::rewrite_with_targetlist(), Analyzer::DatediffExpr::rewrite_with_targetlist(), Analyzer::DatetruncExpr::rewrite_with_targetlist(), Analyzer::Constant::set_null_value(), Analyzer::Constant::toString(), Analyzer::UOper::toString(), and Analyzer::Constant::~Constant().


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