OmniSciDB  c0231cc57d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analyzer::StringOper Class Reference

Expression class for string functions The "arg" constructor parameter must be an expression that resolves to a string datatype (e.g. TEXT). More...

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::StringOper:
+ Collaboration diagram for Analyzer::StringOper:

Public Types

enum  OperandTypeFamily { OperandTypeFamily::STRING_FAMILY, OperandTypeFamily::INT_FAMILY }
 
using LiteralArgMap = std::map< size_t, std::pair< SQLTypes, Datum >>
 

Public Member Functions

 StringOper (const SqlStringOpKind kind, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
 
 StringOper (const SqlStringOpKind kind, const std::vector< std::shared_ptr< Analyzer::Expr >> &args, const size_t min_args, const std::vector< OperandTypeFamily > &expected_type_families, const std::vector< std::string > &arg_names)
 
 StringOper (const SqlStringOpKind kind, const std::vector< std::shared_ptr< Analyzer::Expr >> &args, const std::vector< std::shared_ptr< Analyzer::Expr >> &chained_string_op_exprs)
 
 StringOper (const StringOper &other_string_oper)
 
 StringOper (const std::shared_ptr< StringOper > &other_string_oper)
 
SqlStringOpKind get_kind () const
 
size_t getArity () const
 
size_t getLiteralsArity () const
 
const ExprgetArg (const size_t i) const
 
std::shared_ptr< Analyzer::ExprgetOwnArg (const size_t i) const
 
std::vector< std::shared_ptr
< Analyzer::Expr > > 
getOwnArgs () const
 
std::vector< std::shared_ptr
< Analyzer::Expr > > 
getChainedStringOpExprs () const
 
void collect_rte_idx (std::set< int > &rte_idx_set) const override
 
void collect_column_var (std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
 
bool hasNoneEncodedTextArg () const
 
bool hasSingleDictEncodedColInput () const
 returns whether we have one and only one column involved in this StringOper and all its descendents, and that that column is a dictionary-encoded text type More...
 
std::vector< size_t > getLiteralArgIndexes () const
 
LiteralArgMap getLiteralArgs () const
 
std::shared_ptr< Analyzer::Exprrewrite_with_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_with_child_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_agg_to_var (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprdeep_copy () const override
 
void group_predicates (std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
 
bool operator== (const Expr &rhs) const override
 
std::string toString () const override
 
void find_expr (bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
 
virtual size_t getMinArgs () const
 
virtual std::vector
< OperandTypeFamily
getExpectedTypeFamilies () const
 
virtual std::vector< std::string > getArgNames () const
 
- Public Member Functions inherited from Analyzer::Expr
 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::Expr
add_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::Expr
normalize_simple_predicate (int &rte_idx) const
 
virtual size_t get_num_column_vars (const bool include_agg) const
 
virtual void print () const
 
virtual void add_unique (std::list< const Expr * > &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Private Member Functions

void check_operand_types (const size_t min_args, const std::vector< OperandTypeFamily > &expected_type_families, const std::vector< std::string > &arg_names, const bool dict_encoded_cols_only=true, const bool cols_first_arg_only=true) const
 

Static Private Member Functions

static SQLTypeInfo get_return_type (const std::vector< std::shared_ptr< Analyzer::Expr >> args)
 

Private Attributes

SqlStringOpKind kind_
 
std::vector< std::shared_ptr
< Analyzer::Expr > > 
args_
 
std::vector< std::shared_ptr
< Analyzer::Expr > > 
chained_string_op_exprs_
 

Additional Inherited Members

- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Expression class for string functions The "arg" constructor parameter must be an expression that resolves to a string datatype (e.g. TEXT).

Definition at line 1464 of file Analyzer.h.

Member Typedef Documentation

using Analyzer::StringOper::LiteralArgMap = std::map<size_t, std::pair<SQLTypes, Datum>>

Definition at line 1568 of file Analyzer.h.

Member Enumeration Documentation

Enumerator
STRING_FAMILY 
INT_FAMILY 

Definition at line 1468 of file Analyzer.h.

1468 { STRING_FAMILY, INT_FAMILY };

Constructor & Destructor Documentation

Analyzer::StringOper::StringOper ( const SqlStringOpKind  kind,
const std::vector< std::shared_ptr< Analyzer::Expr >> &  args 
)
inline

Definition at line 1470 of file Analyzer.h.

Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:73
static SQLTypeInfo get_return_type(const std::vector< std::shared_ptr< Analyzer::Expr >> args)
Definition: Analyzer.cpp:4023
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617
Analyzer::StringOper::StringOper ( const SqlStringOpKind  kind,
const std::vector< std::shared_ptr< Analyzer::Expr >> &  args,
const size_t  min_args,
const std::vector< OperandTypeFamily > &  expected_type_families,
const std::vector< std::string > &  arg_names 
)
inline

Definition at line 1474 of file Analyzer.h.

References check_operand_types().

1480  check_operand_types(min_args, expected_type_families, arg_names);
1481  }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:73
static SQLTypeInfo get_return_type(const std::vector< std::shared_ptr< Analyzer::Expr >> args)
Definition: Analyzer.cpp:4023
void check_operand_types(const size_t min_args, const std::vector< OperandTypeFamily > &expected_type_families, const std::vector< std::string > &arg_names, const bool dict_encoded_cols_only=true, const bool cols_first_arg_only=true) const
Definition: Analyzer.cpp:4045
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617

+ Here is the call graph for this function:

Analyzer::StringOper::StringOper ( const SqlStringOpKind  kind,
const std::vector< std::shared_ptr< Analyzer::Expr >> &  args,
const std::vector< std::shared_ptr< Analyzer::Expr >> &  chained_string_op_exprs 
)
inline

Definition at line 1483 of file Analyzer.h.

1487  , kind_(kind)
1488  , args_(args)
1489  , chained_string_op_exprs_(chained_string_op_exprs) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:73
static SQLTypeInfo get_return_type(const std::vector< std::shared_ptr< Analyzer::Expr >> args)
Definition: Analyzer.cpp:4023
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1619
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617
Analyzer::StringOper::StringOper ( const StringOper other_string_oper)
inline

Definition at line 1491 of file Analyzer.h.

References args_, chained_string_op_exprs_, and kind_.

1492  : Expr(other_string_oper.get_type_info()) {
1493  kind_ = other_string_oper.kind_;
1494  args_ = other_string_oper.args_;
1495  chained_string_op_exprs_ = other_string_oper.chained_string_op_exprs_;
1496  }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:73
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1619
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617
Analyzer::StringOper::StringOper ( const std::shared_ptr< StringOper > &  other_string_oper)
inline

Definition at line 1498 of file Analyzer.h.

References args_, chained_string_op_exprs_, and kind_.

1499  : Expr(other_string_oper->get_type_info()) {
1500  kind_ = other_string_oper->kind_;
1501  args_ = other_string_oper->args_;
1502  chained_string_op_exprs_ = other_string_oper->chained_string_op_exprs_;
1503  }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:73
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1619
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617

Member Function Documentation

void Analyzer::StringOper::check_operand_types ( const size_t  min_args,
const std::vector< OperandTypeFamily > &  expected_type_families,
const std::vector< std::string > &  arg_names,
const bool  dict_encoded_cols_only = true,
const bool  cols_first_arg_only = true 
) const
private

Definition at line 4045 of file Analyzer.cpp.

References args_, CHECK_EQ, g_enable_string_functions, get_kind(), INT_FAMILY, IS_INTEGER, remove_cast(), STRING_FAMILY, and toString().

Referenced by StringOper().

4050  {
4051  std::ostringstream oss;
4053  oss << "Function " << ::toString(get_kind()) << " not supported.";
4054  throw std::runtime_error(oss.str());
4055  }
4056  const size_t num_args = args_.size();
4057  CHECK_EQ(expected_type_families.size(), arg_names.size());
4058  if (num_args < min_args || num_args > expected_type_families.size()) {
4059  oss << "Error instantiating " << ::toString(get_kind()) << " operator. ";
4060  oss << "Expected " << expected_type_families.size() << " arguments, but received "
4061  << num_args << ".";
4062  }
4063  for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) {
4064  const auto& expected_type_family = expected_type_families[arg_idx];
4065  // We need to remove any casts that Calcite may add to try the right operand type,
4066  // even if we don't support them. Need to check how this works with casts we do
4067  // support.
4068  auto arg_ti = args_[arg_idx]->get_type_info();
4069  const auto decasted_arg = remove_cast(args_[arg_idx]);
4070  const bool is_arg_constant =
4071  dynamic_cast<const Analyzer::Constant*>(decasted_arg.get()) != nullptr;
4072  const bool is_arg_column_var =
4073  dynamic_cast<const Analyzer::ColumnVar*>(decasted_arg.get()) != nullptr;
4074  const bool is_arg_string_oper =
4075  dynamic_cast<const Analyzer::StringOper*>(decasted_arg.get()) != nullptr;
4076  if (!(is_arg_constant || is_arg_column_var || is_arg_string_oper)) {
4077  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4078  << "Currently only constant, column, or other string operator arguments "
4079  << "are allowed as inputs.";
4080  throw std::runtime_error(oss.str());
4081  }
4082  auto decasted_arg_ti = decasted_arg->get_type_info();
4083  // We need to prevent any non-string type from being casted to a string, but can
4084  // permit non-integer types being casted to integers Todo: Find a cleaner way to
4085  // handle this (we haven't validated any of the casts that calcite has given us at the
4086  // point of RelAlgTranslation)
4087  if (arg_ti != decasted_arg_ti &&
4088  ((arg_ti.is_string() && !decasted_arg_ti.is_string()) ||
4089  (arg_ti.is_integer() && decasted_arg_ti.is_string()))) {
4090  arg_ti = decasted_arg_ti;
4091  }
4092 
4093  if (cols_first_arg_only && !is_arg_constant && arg_idx >= 1UL) {
4094  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4095  << "Currently only column inputs allowed for the primary argument, "
4096  << "but a column input was received for argument " << arg_idx + 1 << ".";
4097  throw std::runtime_error(oss.str());
4098  }
4099  switch (expected_type_family) {
4101  if (!arg_ti.is_string()) {
4102  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4103  << "Expected text type for argument " << arg_idx + 1 << " ("
4104  << arg_names[arg_idx] << ").";
4105  throw std::runtime_error(oss.str());
4106  break;
4107  }
4108  if (dict_encoded_cols_only &&
4109  (!is_arg_constant && !arg_ti.is_dict_encoded_string())) {
4110  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4111  << "Currently only text-encoded dictionary-encoded column inputs are "
4112  << "allowed, but a none-encoded text column argument was received.";
4113  throw std::runtime_error(oss.str());
4114  break;
4115  }
4116  break;
4117  }
4119  if (!IS_INTEGER(arg_ti.get_type())) {
4120  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4121  << "Expected integer type for argument " << arg_idx + 1 << " ("
4122  << arg_names[arg_idx] << ").";
4123  throw std::runtime_error(oss.str());
4124  break;
4125  }
4126  if (!is_arg_constant) {
4127  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4128  << "Currently only text-encoded dictionary column inputs are "
4129  << "allowed, but an integer-type column was provided.";
4130  throw std::runtime_error(oss.str());
4131  break;
4132  }
4133  break;
4134  }
4135  }
4136  }
4137 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
std::shared_ptr< Analyzer::Expr > remove_cast(const std::shared_ptr< Analyzer::Expr > &expr)
Definition: Analyzer.cpp:4244
bool g_enable_string_functions
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
Expression class for string functions The &quot;arg&quot; constructor parameter must be an expression that reso...
Definition: Analyzer.h:1464
SqlStringOpKind get_kind() const
Definition: Analyzer.h:1505
#define IS_INTEGER(T)
Definition: sqltypes.h:317
std::string toString() const override
Definition: Analyzer.cpp:3633

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Analyzer::StringOper::collect_column_var ( std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &  colvar_set,
bool  include_agg 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3364 of file Analyzer.cpp.

References args_.

Referenced by hasSingleDictEncodedColInput().

3366  {
3367  for (const auto& arg : args_) {
3368  arg->collect_column_var(colvar_set, include_agg);
3369  }
3370 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618

+ Here is the caller graph for this function:

void Analyzer::StringOper::collect_rte_idx ( std::set< int > &  rte_idx_set) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3304 of file Analyzer.cpp.

References args_.

3304  {
3305  for (const auto& arg : args_) {
3306  arg->collect_rte_idx(rte_idx_set);
3307  }
3308 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
std::shared_ptr< Analyzer::Expr > Analyzer::StringOper::deep_copy ( ) const
overridevirtual

Implements Analyzer::Expr.

Reimplemented in Analyzer::Base64DecodeStringOper, Analyzer::Base64EncodeStringOper, Analyzer::JsonValueStringOper, Analyzer::RegexpSubstrStringOper, Analyzer::RegexpReplaceStringOper, Analyzer::SplitPartStringOper, Analyzer::ReplaceStringOper, Analyzer::OverlayStringOper, Analyzer::SubstringStringOper, Analyzer::TrimStringOper, Analyzer::PadStringOper, Analyzer::ConcatStringOper, Analyzer::RepeatStringOper, Analyzer::ReverseStringOper, Analyzer::InitCapStringOper, Analyzer::UpperStringOper, and Analyzer::LowerStringOper.

Definition at line 3473 of file Analyzer.cpp.

References args_, chained_string_op_exprs_, and kind_.

Referenced by Analyzer::LowerStringOper::deep_copy(), Analyzer::UpperStringOper::deep_copy(), Analyzer::InitCapStringOper::deep_copy(), Analyzer::ReverseStringOper::deep_copy(), Analyzer::RepeatStringOper::deep_copy(), Analyzer::ConcatStringOper::deep_copy(), Analyzer::PadStringOper::deep_copy(), Analyzer::TrimStringOper::deep_copy(), Analyzer::SubstringStringOper::deep_copy(), Analyzer::OverlayStringOper::deep_copy(), Analyzer::ReplaceStringOper::deep_copy(), Analyzer::SplitPartStringOper::deep_copy(), Analyzer::RegexpReplaceStringOper::deep_copy(), Analyzer::RegexpSubstrStringOper::deep_copy(), Analyzer::JsonValueStringOper::deep_copy(), Analyzer::Base64EncodeStringOper::deep_copy(), Analyzer::Base64DecodeStringOper::deep_copy(), and DeepCopyVisitor::visitStringOper().

3473  {
3474  std::vector<std::shared_ptr<Analyzer::Expr>> args_copy;
3475  for (const auto& arg : args_) {
3476  args_copy.emplace_back(arg->deep_copy());
3477  }
3478  std::vector<std::shared_ptr<Analyzer::Expr>> chained_string_op_exprs_copy;
3479  for (const auto& chained_string_op_expr : chained_string_op_exprs_) {
3480  chained_string_op_exprs_copy.emplace_back(chained_string_op_expr->deep_copy());
3481  }
3482  return makeExpr<Analyzer::StringOper>(
3483  kind_, std::move(args_copy), std::move(chained_string_op_exprs_copy));
3484 }
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1619
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617

+ Here is the caller graph for this function:

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

Reimplemented from Analyzer::Expr.

Definition at line 3139 of file Analyzer.cpp.

References Analyzer::Expr::add_unique(), args_, and anonymous_namespace{Utm.h}::f.

3140  {
3141  if (f(this)) {
3142  add_unique(expr_list);
3143  return;
3144  }
3145  for (const auto& arg : args_) {
3146  arg->find_expr(f, expr_list);
3147  }
3148 }
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:3073
constexpr double f
Definition: Utm.h:31
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618

+ Here is the call graph for this function:

SqlStringOpKind Analyzer::StringOper::get_kind ( ) const
inline

Definition at line 1505 of file Analyzer.h.

References kind_.

Referenced by check_operand_types(), operator==(), TransientStringLiteralsVisitor::visitStringOper(), and anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitStringOper().

1505 { return kind_; }
SqlStringOpKind kind_
Definition: Analyzer.h:1617

+ Here is the caller graph for this function:

SQLTypeInfo Analyzer::StringOper::get_return_type ( const std::vector< std::shared_ptr< Analyzer::Expr >>  args)
staticprivate

Definition at line 4023 of file Analyzer.cpp.

References run_benchmark_import::args, Analyzer::Expr::get_type_info(), kENCODING_DICT, kNULLT, kTEXT, and SQLTypeInfo::set_notnull().

4024  {
4025  if (args.empty()) {
4026  return SQLTypeInfo(kNULLT);
4027  }
4028  // Constant literal first argument
4029  if (dynamic_cast<const Analyzer::Constant*>(args[0].get())) {
4030  return args[0]->get_type_info();
4031  }
4032  // None-encoded text column argument
4033  // Note that whether or not this is allowed is decided separately
4034  // in check_operand_types
4035  if (args[0]->get_type_info().is_none_encoded_string()) {
4036  return SQLTypeInfo(kTEXT, kENCODING_DICT, 0, kNULLT);
4037  }
4038  // If here, we have a dict-encoded column arg
4039  SQLTypeInfo ret_ti(args[0]->get_type_info());
4040  // Set return as nullable as string op can create nulls
4041  ret_ti.set_notnull(false);
4042  return ret_ti;
4043 }
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:82
Definition: sqltypes.h:66

+ Here is the call graph for this function:

const Expr* Analyzer::StringOper::getArg ( const size_t  i) const
inline

Definition at line 1519 of file Analyzer.h.

References args_, and CHECK_LT.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenPerRowStringOper(), getExpressionRange(), getLiteralArgs(), operator==(), pre_translate_string_ops(), and TransientStringLiteralsVisitor::visitStringOper().

1519  {
1520  CHECK_LT(i, args_.size());
1521  return args_[i].get();
1522  }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
#define CHECK_LT(x, y)
Definition: Logger.h:232

+ Here is the caller graph for this function:

size_t Analyzer::StringOper::getArity ( ) const
inline

Definition at line 1507 of file Analyzer.h.

References args_.

Referenced by CodeGenerator::codegen(), CodeGenerator::codegenPerRowStringOper(), getLiteralArgs(), operator==(), pre_translate_string_ops(), TransientStringLiteralsVisitor::visitStringOper(), and anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitStringOper().

1507 { return args_.size(); }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618

+ Here is the caller graph for this function:

std::vector<std::shared_ptr<Analyzer::Expr> > Analyzer::StringOper::getChainedStringOpExprs ( ) const
inline

Definition at line 1531 of file Analyzer.h.

References chained_string_op_exprs_.

Referenced by getExpressionRange(), getStringOpInfos(), and TransientStringLiteralsVisitor::visitStringOper().

1531  {
1532  return chained_string_op_exprs_;
1533  }
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1619

+ Here is the caller graph for this function:

std::vector< size_t > Analyzer::StringOper::getLiteralArgIndexes ( ) const

Definition at line 3995 of file Analyzer.cpp.

References args_.

3995  {
3996  std::vector<size_t> literal_arg_indexes;
3997  const auto num_args = args_.size();
3998  for (size_t idx = 0; idx < num_args; ++idx) {
3999  if (dynamic_cast<const Constant*>(args_[idx].get())) {
4000  literal_arg_indexes.emplace_back(idx);
4001  }
4002  }
4003  return literal_arg_indexes;
4004 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
LiteralArgMap Analyzer::StringOper::getLiteralArgs ( ) const

Definition at line 4008 of file Analyzer.cpp.

References getArg(), and getArity().

Referenced by TransientStringLiteralsVisitor::visitStringOper(), and anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitStringOper().

4008  {
4009  LiteralArgMap literal_arg_map;
4010  const auto num_args = getArity();
4011  for (size_t idx = 0; idx < num_args; ++idx) {
4012  const auto constant_arg_expr = dynamic_cast<const Analyzer::Constant*>(getArg(idx));
4013  if (constant_arg_expr) {
4014  literal_arg_map.emplace(
4015  std::make_pair(idx,
4016  std::make_pair(constant_arg_expr->get_type_info().get_type(),
4017  constant_arg_expr->get_constval())));
4018  }
4019  }
4020  return literal_arg_map;
4021 }
std::map< size_t, std::pair< SQLTypes, Datum >> LiteralArgMap
Definition: Analyzer.h:1568
size_t getArity() const
Definition: Analyzer.h:1507
const Expr * getArg(const size_t i) const
Definition: Analyzer.h:1519

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t Analyzer::StringOper::getLiteralsArity ( ) const
inline

Definition at line 1509 of file Analyzer.h.

References args_.

Referenced by TransientStringLiteralsVisitor::visitStringOper().

1509  {
1510  size_t num_literals{0UL};
1511  for (const auto& arg : args_) {
1512  if (dynamic_cast<const Constant*>(arg.get())) {
1513  num_literals++;
1514  }
1515  }
1516  return num_literals;
1517  }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618

+ Here is the caller graph for this function:

std::shared_ptr<Analyzer::Expr> Analyzer::StringOper::getOwnArg ( const size_t  i) const
inline

Definition at line 1524 of file Analyzer.h.

References args_, and CHECK_LT.

1524  {
1525  CHECK_LT(i, args_.size());
1526  return args_[i];
1527  }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
#define CHECK_LT(x, y)
Definition: Logger.h:232
std::vector<std::shared_ptr<Analyzer::Expr> > Analyzer::StringOper::getOwnArgs ( ) const
inline

Definition at line 1529 of file Analyzer.h.

References args_.

Referenced by ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitStringOper(), and anonymous_namespace{ExpressionRewrite.cpp}::ConstantFoldingVisitor::visitStringOper().

1529 { return args_; }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618

+ Here is the caller graph for this function:

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

Reimplemented from Analyzer::Expr.

Definition at line 1694 of file Analyzer.cpp.

References args_.

1696  {
1697  std::set<int> rte_idx_set;
1698  for (const auto& arg : args_) {
1699  arg->collect_rte_idx(rte_idx_set);
1700  }
1701  if (rte_idx_set.size() > 1) {
1702  join_predicates.push_back(this);
1703  } else if (rte_idx_set.size() == 1) {
1704  scan_predicates.push_back(this);
1705  } else {
1706  const_predicates.push_back(this);
1707  }
1708 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
bool Analyzer::StringOper::hasNoneEncodedTextArg ( ) const
inline

Definition at line 1542 of file Analyzer.h.

References args_, CHECK, and TRANSIENT_DICT_ID.

Referenced by CodeGenerator::codegen().

1542  {
1543  if (args_.empty()) {
1544  return false;
1545  }
1546  const auto& arg0_ti = args_[0]->get_type_info();
1547  if (!arg0_ti.is_string()) {
1548  return false;
1549  }
1550  if (arg0_ti.is_none_encoded_string()) {
1551  return true;
1552  }
1553  CHECK(arg0_ti.is_dict_encoded_string());
1554  return arg0_ti.get_comp_param() == TRANSIENT_DICT_ID;
1555  }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
#define TRANSIENT_DICT_ID
Definition: sqltypes.h:334
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the caller graph for this function:

bool Analyzer::StringOper::hasSingleDictEncodedColInput ( ) const

returns whether we have one and only one column involved in this StringOper and all its descendents, and that that column is a dictionary-encoded text type

Returns
std::vector<SqlTypeInfo>

Definition at line 3981 of file Analyzer.cpp.

References CHECK, collect_column_var(), and Analyzer::ColumnVar::colvar_comp().

3981  {
3982  auto comparator = Analyzer::ColumnVar::colvar_comp;
3983  std::set<const Analyzer::ColumnVar*,
3984  bool (*)(const Analyzer::ColumnVar*, const Analyzer::ColumnVar*)>
3985  colvar_set(comparator);
3986  collect_column_var(colvar_set, true);
3987  if (colvar_set.size() != 1UL) {
3988  return false;
3989  }
3990  auto col_expr_ptr = *colvar_set.begin();
3991  CHECK(col_expr_ptr);
3992  return col_expr_ptr->get_type_info().is_dict_encoded_string();
3993 }
static bool colvar_comp(const ColumnVar *l, const ColumnVar *r)
Definition: Analyzer.h:216
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3364
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

bool Analyzer::StringOper::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 3579 of file Analyzer.cpp.

References chained_string_op_exprs_, get_kind(), getArg(), and getArity().

3579  {
3580  const auto rhs_string_oper = dynamic_cast<const StringOper*>(&rhs);
3581 
3582  if (!rhs_string_oper) {
3583  return false;
3584  }
3585 
3586  if (get_kind() != rhs_string_oper->get_kind()) {
3587  return false;
3588  }
3589  if (getArity() != rhs_string_oper->getArity()) {
3590  return false;
3591  }
3592 
3593  for (size_t i = 0; i < getArity(); ++i) {
3594  if (!(*getArg(i) == *(rhs_string_oper->getArg(i)))) {
3595  return false;
3596  }
3597  }
3598  if (chained_string_op_exprs_.size() !=
3599  rhs_string_oper->chained_string_op_exprs_.size()) {
3600  return false;
3601  }
3602  for (size_t i = 0; i < chained_string_op_exprs_.size(); ++i) {
3603  if (!(*(chained_string_op_exprs_[i]) ==
3604  *(rhs_string_oper->chained_string_op_exprs_[i]))) {
3605  return false;
3606  }
3607  }
3608  return true;
3609 }
size_t getArity() const
Definition: Analyzer.h:1507
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1619
StringOper(const SqlStringOpKind kind, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1470
SqlStringOpKind get_kind() const
Definition: Analyzer.h:1505
const Expr * getArg(const size_t i) const
Definition: Analyzer.h:1519

+ Here is the call graph for this function:

std::shared_ptr< Analyzer::Expr > Analyzer::StringOper::rewrite_agg_to_var ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1969 of file Analyzer.cpp.

References args_, and kind_.

1970  {
1971  std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1972  for (const auto& arg : args_) {
1973  rewritten_args.emplace_back(arg->rewrite_agg_to_var(tlist));
1974  }
1975  return makeExpr<StringOper>(kind_, rewritten_args);
1976 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617
std::shared_ptr< Analyzer::Expr > Analyzer::StringOper::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1960 of file Analyzer.cpp.

References args_, and kind_.

1961  {
1962  std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1963  for (const auto& arg : args_) {
1964  rewritten_args.emplace_back(arg->rewrite_with_child_targetlist(tlist));
1965  }
1966  return makeExpr<StringOper>(kind_, rewritten_args);
1967 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617
std::shared_ptr< Analyzer::Expr > Analyzer::StringOper::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1951 of file Analyzer.cpp.

References args_, and kind_.

1952  {
1953  std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1954  for (const auto& arg : args_) {
1955  rewritten_args.emplace_back(arg->rewrite_with_targetlist(tlist));
1956  }
1957  return makeExpr<StringOper>(kind_, rewritten_args);
1958 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617
std::string Analyzer::StringOper::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 3633 of file Analyzer.cpp.

References args_, and kind_.

Referenced by check_operand_types().

3633  {
3634  std::string str{"(" + ::toString(kind_) + " "};
3635  for (const auto& arg : args_) {
3636  str += arg->toString();
3637  }
3638  str += ")";
3639  return str;
3640 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1618
SqlStringOpKind kind_
Definition: Analyzer.h:1617
std::string toString() const override
Definition: Analyzer.cpp:3633

+ Here is the caller graph for this function:

Member Data Documentation

std::vector<std::shared_ptr<Analyzer::Expr> > Analyzer::StringOper::chained_string_op_exprs_
private

Definition at line 1619 of file Analyzer.h.

Referenced by deep_copy(), getChainedStringOpExprs(), operator==(), and StringOper().

SqlStringOpKind Analyzer::StringOper::kind_
private

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