OmniSciDB  2c44a3935d
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 ()
 
std::shared_ptr< Analyzer::Exprget_shared_ptr ()
 
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 68 of file Analyzer.h.

Constructor & Destructor Documentation

◆ Expr() [1/4]

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

Definition at line 70 of file Analyzer.h.

70 : type_info(t, notnull), contains_agg(false) {}
SQLTypeInfo type_info
Definition: Analyzer.h:177
bool contains_agg
Definition: Analyzer.h:178

◆ Expr() [2/4]

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

Definition at line 71 of file Analyzer.h.

72  : type_info(t, d, 0, notnull), contains_agg(false) {}
SQLTypeInfo type_info
Definition: Analyzer.h:177
bool contains_agg
Definition: Analyzer.h:178

◆ Expr() [3/4]

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

Definition at line 73 of file Analyzer.h.

74  : type_info(t, d, s, notnull), contains_agg(false) {}
SQLTypeInfo type_info
Definition: Analyzer.h:177
bool contains_agg
Definition: Analyzer.h:178

◆ Expr() [4/4]

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

Definition at line 75 of file Analyzer.h.

76  : type_info(ti), contains_agg(has_agg) {}
SQLTypeInfo type_info
Definition: Analyzer.h:177
bool contains_agg
Definition: Analyzer.h:178

◆ ~Expr()

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

Definition at line 77 of file Analyzer.h.

77 {}

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 685 of file Analyzer.cpp.

References Analyzer::Constant::Constant(), contains_agg, SQLTypeInfo::get_comp_param(), SQLTypeInfo::get_compression(), SQLTypeInfo::get_type_name(), SQLTypeInfo::is_castable(), SQLTypeInfo::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().

685  {
686  if (new_type_info == type_info) {
687  return shared_from_this();
688  }
689  if (new_type_info.is_string() && type_info.is_string() &&
690  new_type_info.get_compression() == kENCODING_DICT &&
692  (new_type_info.get_comp_param() == type_info.get_comp_param() ||
693  new_type_info.get_comp_param() == TRANSIENT_DICT(type_info.get_comp_param()))) {
694  return shared_from_this();
695  }
696  if (!type_info.is_castable(new_type_info)) {
697  throw std::runtime_error("Cannot CAST from " + type_info.get_type_name() + " to " +
698  new_type_info.get_type_name());
699  }
700  // @TODO(wei) temporary restriction until executor can support this.
701  if (typeid(*this) != typeid(Constant) && new_type_info.is_string() &&
702  new_type_info.get_compression() == kENCODING_DICT &&
703  new_type_info.get_comp_param() <= TRANSIENT_DICT_ID) {
705  throw std::runtime_error(
706  "Cannot group by string columns which are not dictionary encoded.");
707  }
708  throw std::runtime_error(
709  "Internal error: Cannot apply transient dictionary encoding to non-literal "
710  "expression "
711  "yet.");
712  }
713  return makeExpr<UOper>(new_type_info, contains_agg, kCAST, shared_from_this());
714 }
bool is_string() const
Definition: sqltypes.h:408
bool is_castable(const SQLTypeInfo &new_type_info) const
Definition: sqltypes.h:477
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:266
Definition: sqldefs.h:49
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:265
SQLTypeInfo type_info
Definition: Analyzer.h:177
#define TRANSIENT_DICT_ID
Definition: sqltypes.h:196
std::string get_type_name() const
Definition: sqltypes.h:360
bool contains_agg
Definition: Analyzer.h:178
#define TRANSIENT_DICT(ID)
Definition: sqltypes.h:197
+ 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 2723 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::LowerExpr::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().

2723  {
2724  // only add unique instances to the list
2725  for (auto e : expr_list) {
2726  if (*e == *this) {
2727  return;
2728  }
2729  }
2730  expr_list.push_back(this);
2731 }
+ 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()

◆ collect_rte_idx()

◆ decompress()

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

Definition at line 671 of file Analyzer.cpp.

References contains_agg, SQLTypeInfo::get_compression(), SQLTypeInfo::get_dimension(), SQLTypeInfo::get_notnull(), SQLTypeInfo::get_scale(), SQLTypeInfo::get_subtype(), SQLTypeInfo::get_type(), kCAST, kENCODING_NONE, and type_info.

671  {
673  return shared_from_this();
674  }
675  SQLTypeInfo new_type_info(type_info.get_type(),
680  0,
682  return makeExpr<UOper>(new_type_info, contains_agg, kCAST, shared_from_this());
683 }
Definition: sqldefs.h:49
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:265
SQLTypeInfo type_info
Definition: Analyzer.h:177
HOST DEVICE int get_scale() const
Definition: sqltypes.h:262
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:264
HOST DEVICE SQLTypes get_subtype() const
Definition: sqltypes.h:258
HOST DEVICE int get_dimension() const
Definition: sqltypes.h:259
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:257
bool contains_agg
Definition: Analyzer.h:178
+ 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::LowerExpr, Analyzer::KeyForStringExpr, Analyzer::CharLengthExpr, Analyzer::InValues, Analyzer::Subquery, Analyzer::BinOper, and Analyzer::UOper.

Definition at line 160 of file Analyzer.h.

References decompress().

Referenced by anonymous_namespace{LogicalIR.cpp}::contains_unsafe_division().

161  {
162  if (f(this)) {
163  add_unique(expr_list);
164  }
165  }
virtual void add_unique(std::list< const Expr *> &expr_list) const
Definition: Analyzer.cpp:2723
+ 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 174 of file Analyzer.h.

174 { domain_set.clear(); }

◆ get_shared_ptr()

std::shared_ptr<Analyzer::Expr> Analyzer::Expr::get_shared_ptr ( )
inline

Definition at line 78 of file Analyzer.h.

78 { return shared_from_this(); }

◆ get_type_info()

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

Definition at line 79 of file Analyzer.h.

Referenced by anonymous_namespace{GroupByAndAggregate.cpp}::add_transient_string_literals_for_expression(), Parser::ArrayLiteral::analyze(), CodeGenerator::beginArgsNullcheck(), 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::codegenGeoBinOper(), CodeGenerator::codegenGeoUOper(), 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(), 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(), anonymous_namespace{RelAlgExecutor.cpp}::get_logical_type_for_expr(), get_target_info(), 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(), ColumnFetcher::makeJoinColumn(), 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(), ScalarExprToSql::visitConstant(), DeepCopyVisitor::visitDateaddExpr(), DeepCopyVisitor::visitDatediffExpr(), DeepCopyVisitor::visitDatetruncExpr(), DeepCopyVisitor::visitExtractExpr(), DeepCopyVisitor::visitFunctionOper(), DeepCopyVisitor::visitFunctionOperWithCustomTypeHandling(), DeepCopyVisitor::visitGeoBinOper(), DeepCopyVisitor::visitGeoUOper(), DeepCopyVisitor::visitInIntegerSet(), ScalarExprToSql::visitUOper(), DeepCopyVisitor::visitUOper(), anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitUOper(), DeepCopyVisitor::visitWindowFunction(), and anonymous_namespace{WindowExpressionRewrite.cpp}::window_sum_and_count_match().

79 { return type_info; }
SQLTypeInfo type_info
Definition: Analyzer.h:177

◆ 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 95 of file Analyzer.h.

95  {
96  rte_idx = -1;
97  return nullptr;
98  }

◆ operator==()

◆ print()

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

Definition at line 151 of file Analyzer.h.

151 { 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::LowerExpr, Analyzer::KeyForStringExpr, Analyzer::CharLengthExpr, Analyzer::InValues, Analyzer::Subquery, Analyzer::BinOper, Analyzer::UOper, Analyzer::Var, and Analyzer::ColumnVar.

Definition at line 145 of file Analyzer.h.

References operator==().

146  {
147  return deep_copy();
148  }
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 82 of file Analyzer.h.

82 { contains_agg = a; }
bool contains_agg
Definition: Analyzer.h:178

◆ set_type_info()

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

Definition at line 80 of file Analyzer.h.

80 { type_info = ti; }
SQLTypeInfo type_info
Definition: Analyzer.h:177

◆ toString()

Member Data Documentation

◆ contains_agg

◆ type_info

SQLTypeInfo Analyzer::Expr::type_info
protected

Definition at line 177 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::GeoUOper::deep_copy(), Analyzer::GeoBinOper::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: