OmniSciDB  4201147b46
 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 1463 of file Analyzer.h.

Member Typedef Documentation

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

Definition at line 1567 of file Analyzer.h.

Member Enumeration Documentation

Enumerator
STRING_FAMILY 
INT_FAMILY 

Definition at line 1467 of file Analyzer.h.

1467 { 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 1469 of file Analyzer.h.

Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:72
static SQLTypeInfo get_return_type(const std::vector< std::shared_ptr< Analyzer::Expr >> args)
Definition: Analyzer.cpp:3915
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
SqlStringOpKind kind_
Definition: Analyzer.h:1616
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 1473 of file Analyzer.h.

References check_operand_types().

1479  check_operand_types(min_args, expected_type_families, arg_names);
1480  }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:72
static SQLTypeInfo get_return_type(const std::vector< std::shared_ptr< Analyzer::Expr >> args)
Definition: Analyzer.cpp:3915
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:3937
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
SqlStringOpKind kind_
Definition: Analyzer.h:1616

+ 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 1482 of file Analyzer.h.

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

Definition at line 1490 of file Analyzer.h.

References args_, chained_string_op_exprs_, and kind_.

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

Definition at line 1497 of file Analyzer.h.

References args_, chained_string_op_exprs_, and kind_.

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

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 3937 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().

3942  {
3943  std::ostringstream oss;
3945  oss << "Function " << ::toString(get_kind()) << " not supported.";
3946  throw std::runtime_error(oss.str());
3947  }
3948  const size_t num_args = args_.size();
3949  CHECK_EQ(expected_type_families.size(), arg_names.size());
3950  if (num_args < min_args || num_args > expected_type_families.size()) {
3951  oss << "Error instantiating " << ::toString(get_kind()) << " operator. ";
3952  oss << "Expected " << expected_type_families.size() << " arguments, but received "
3953  << num_args << ".";
3954  }
3955  for (size_t arg_idx = 0; arg_idx < num_args; ++arg_idx) {
3956  const auto& expected_type_family = expected_type_families[arg_idx];
3957  // We need to remove any casts that Calcite may add to try the right operand type,
3958  // even if we don't support them. Need to check how this works with casts we do
3959  // support.
3960  auto arg_ti = args_[arg_idx]->get_type_info();
3961  const auto decasted_arg = remove_cast(args_[arg_idx]);
3962  const bool is_arg_constant =
3963  dynamic_cast<const Analyzer::Constant*>(decasted_arg.get()) != nullptr;
3964  const bool is_arg_column_var =
3965  dynamic_cast<const Analyzer::ColumnVar*>(decasted_arg.get()) != nullptr;
3966  const bool is_arg_string_oper =
3967  dynamic_cast<const Analyzer::StringOper*>(decasted_arg.get()) != nullptr;
3968  if (!(is_arg_constant || is_arg_column_var || is_arg_string_oper)) {
3969  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
3970  << "Currently only constant, column, or other string operator arguments "
3971  << "are allowed as inputs.";
3972  throw std::runtime_error(oss.str());
3973  }
3974  auto decasted_arg_ti = decasted_arg->get_type_info();
3975  // We need to prevent any non-string type from being casted to a string, but can
3976  // permit non-integer types being casted to integers Todo: Find a cleaner way to
3977  // handle this (we haven't validated any of the casts that calcite has given us at the
3978  // point of RelAlgTranslation)
3979  if (arg_ti != decasted_arg_ti &&
3980  ((arg_ti.is_string() && !decasted_arg_ti.is_string()) ||
3981  (arg_ti.is_integer() && decasted_arg_ti.is_string()))) {
3982  arg_ti = decasted_arg_ti;
3983  }
3984 
3985  if (cols_first_arg_only && !is_arg_constant && arg_idx >= 1UL) {
3986  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
3987  << "Currently only column inputs allowed for the primary argument, "
3988  << "but a column input was received for argument " << arg_idx + 1 << ".";
3989  throw std::runtime_error(oss.str());
3990  }
3991  switch (expected_type_family) {
3993  if (!arg_ti.is_string()) {
3994  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
3995  << "Expected text type for argument " << arg_idx + 1 << " ("
3996  << arg_names[arg_idx] << ").";
3997  throw std::runtime_error(oss.str());
3998  break;
3999  }
4000  if (dict_encoded_cols_only &&
4001  (!is_arg_constant && !arg_ti.is_dict_encoded_string())) {
4002  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4003  << "Currently only text-encoded dictionary-encoded column inputs are "
4004  << "allowed, but a none-encoded text column argument was received.";
4005  throw std::runtime_error(oss.str());
4006  break;
4007  }
4008  break;
4009  }
4011  if (!IS_INTEGER(arg_ti.get_type())) {
4012  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4013  << "Expected integer type for argument " << arg_idx + 1 << " ("
4014  << arg_names[arg_idx] << ").";
4015  throw std::runtime_error(oss.str());
4016  break;
4017  }
4018  if (!is_arg_constant) {
4019  oss << "Error instantiating " << ::toString(get_kind()) << " operator. "
4020  << "Currently only text-encoded dictionary column inputs are "
4021  << "allowed, but an integer-type column was provided.";
4022  throw std::runtime_error(oss.str());
4023  break;
4024  }
4025  break;
4026  }
4027  }
4028  }
4029 }
#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:4136
bool g_enable_string_functions
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
Expression class for string functions The &quot;arg&quot; constructor parameter must be an expression that reso...
Definition: Analyzer.h:1463
SqlStringOpKind get_kind() const
Definition: Analyzer.h:1504
#define IS_INTEGER(T)
Definition: sqltypes.h:245
std::string toString() const override
Definition: Analyzer.cpp:3531

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

References args_.

Referenced by hasSingleDictEncodedColInput().

3279  {
3280  for (const auto& arg : args_) {
3281  arg->collect_column_var(colvar_set, include_agg);
3282  }
3283 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617

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

References args_.

3217  {
3218  for (const auto& arg : args_) {
3219  arg->collect_rte_idx(rte_idx_set);
3220  }
3221 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
std::shared_ptr< Analyzer::Expr > Analyzer::StringOper::deep_copy ( ) const
overridevirtual

Implements Analyzer::Expr.

Reimplemented in 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 3386 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(), and DeepCopyVisitor::visitStringOper().

3386  {
3387  std::vector<std::shared_ptr<Analyzer::Expr>> args_copy;
3388  for (const auto& arg : args_) {
3389  args_copy.emplace_back(arg->deep_copy());
3390  }
3391  std::vector<std::shared_ptr<Analyzer::Expr>> chained_string_op_exprs_copy;
3392  for (const auto& chained_string_op_expr : chained_string_op_exprs_) {
3393  chained_string_op_exprs_copy.emplace_back(chained_string_op_expr->deep_copy());
3394  }
3395  return makeExpr<Analyzer::StringOper>(
3396  kind_, std::move(args_copy), std::move(chained_string_op_exprs_copy));
3397 }
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1618
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
SqlStringOpKind kind_
Definition: Analyzer.h:1616

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

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

3053  {
3054  if (f(this)) {
3055  add_unique(expr_list);
3056  return;
3057  }
3058  for (const auto& arg : args_) {
3059  arg->find_expr(f, expr_list);
3060  }
3061 }
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:2986
constexpr double f
Definition: Utm.h:31
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617

+ Here is the call graph for this function:

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

Definition at line 1504 of file Analyzer.h.

References kind_.

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

1504 { return kind_; }
SqlStringOpKind kind_
Definition: Analyzer.h:1616

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

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

3916  {
3917  if (args.empty()) {
3918  return SQLTypeInfo(kNULLT);
3919  }
3920  // Constant literal first argument
3921  if (dynamic_cast<const Analyzer::Constant*>(args[0].get())) {
3922  return args[0]->get_type_info();
3923  }
3924  // None-encoded text column argument
3925  // Note that whether or not this is allowed is decided separately
3926  // in check_operand_types
3927  if (args[0]->get_type_info().is_none_encoded_string()) {
3928  return SQLTypeInfo(kTEXT, kENCODING_DICT, 0, kNULLT);
3929  }
3930  // If here, we have a dict-encoded column arg
3931  SQLTypeInfo ret_ti(args[0]->get_type_info());
3932  // Set return as nullable as string op can create nulls
3933  ret_ti.set_notnull(false);
3934  return ret_ti;
3935 }
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:81
Definition: sqltypes.h:52

+ Here is the call graph for this function:

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

Definition at line 1518 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().

1518  {
1519  CHECK_LT(i, args_.size());
1520  return args_[i].get();
1521  }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
#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 1506 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().

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

+ Here is the caller graph for this function:

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

Definition at line 1530 of file Analyzer.h.

References chained_string_op_exprs_.

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

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

+ Here is the caller graph for this function:

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

Definition at line 3887 of file Analyzer.cpp.

References args_.

3887  {
3888  std::vector<size_t> literal_arg_indexes;
3889  const auto num_args = args_.size();
3890  for (size_t idx = 0; idx < num_args; ++idx) {
3891  if (dynamic_cast<const Constant*>(args_[idx].get())) {
3892  literal_arg_indexes.emplace_back(idx);
3893  }
3894  }
3895  return literal_arg_indexes;
3896 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
LiteralArgMap Analyzer::StringOper::getLiteralArgs ( ) const

Definition at line 3900 of file Analyzer.cpp.

References getArg(), and getArity().

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

3900  {
3901  LiteralArgMap literal_arg_map;
3902  const auto num_args = getArity();
3903  for (size_t idx = 0; idx < num_args; ++idx) {
3904  const auto constant_arg_expr = dynamic_cast<const Analyzer::Constant*>(getArg(idx));
3905  if (constant_arg_expr) {
3906  literal_arg_map.emplace(
3907  std::make_pair(idx,
3908  std::make_pair(constant_arg_expr->get_type_info().get_type(),
3909  constant_arg_expr->get_constval())));
3910  }
3911  }
3912  return literal_arg_map;
3913 }
std::map< size_t, std::pair< SQLTypes, Datum >> LiteralArgMap
Definition: Analyzer.h:1567
size_t getArity() const
Definition: Analyzer.h:1506
const Expr * getArg(const size_t i) const
Definition: Analyzer.h:1518

+ 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 1508 of file Analyzer.h.

References args_.

Referenced by TransientStringLiteralsVisitor::visitStringOper().

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

+ 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 1523 of file Analyzer.h.

References args_, and CHECK_LT.

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

Definition at line 1528 of file Analyzer.h.

References args_.

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

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

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

References args_.

1665  {
1666  std::set<int> rte_idx_set;
1667  for (const auto& arg : args_) {
1668  arg->collect_rte_idx(rte_idx_set);
1669  }
1670  if (rte_idx_set.size() > 1) {
1671  join_predicates.push_back(this);
1672  } else if (rte_idx_set.size() == 1) {
1673  scan_predicates.push_back(this);
1674  } else {
1675  const_predicates.push_back(this);
1676  }
1677 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
bool Analyzer::StringOper::hasNoneEncodedTextArg ( ) const
inline

Definition at line 1541 of file Analyzer.h.

References args_, CHECK, and TRANSIENT_DICT_ID.

Referenced by CodeGenerator::codegen().

1541  {
1542  if (args_.empty()) {
1543  return false;
1544  }
1545  const auto& arg0_ti = args_[0]->get_type_info();
1546  if (!arg0_ti.is_string()) {
1547  return false;
1548  }
1549  if (arg0_ti.is_none_encoded_string()) {
1550  return true;
1551  }
1552  CHECK(arg0_ti.is_dict_encoded_string());
1553  return arg0_ti.get_comp_param() == TRANSIENT_DICT_ID;
1554  }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
#define TRANSIENT_DICT_ID
Definition: sqltypes.h:259
#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 3873 of file Analyzer.cpp.

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

3873  {
3874  auto comparator = Analyzer::ColumnVar::colvar_comp;
3875  std::set<const Analyzer::ColumnVar*,
3876  bool (*)(const Analyzer::ColumnVar*, const Analyzer::ColumnVar*)>
3877  colvar_set(comparator);
3878  collect_column_var(colvar_set, true);
3879  if (colvar_set.size() != 1UL) {
3880  return false;
3881  }
3882  auto col_expr_ptr = *colvar_set.begin();
3883  CHECK(col_expr_ptr);
3884  return col_expr_ptr->get_type_info().is_dict_encoded_string();
3885 }
static bool colvar_comp(const ColumnVar *l, const ColumnVar *r)
Definition: Analyzer.h:215
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3277
#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 3477 of file Analyzer.cpp.

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

3477  {
3478  const auto rhs_string_oper = dynamic_cast<const StringOper*>(&rhs);
3479 
3480  if (!rhs_string_oper) {
3481  return false;
3482  }
3483 
3484  if (get_kind() != rhs_string_oper->get_kind()) {
3485  return false;
3486  }
3487  if (getArity() != rhs_string_oper->getArity()) {
3488  return false;
3489  }
3490 
3491  for (size_t i = 0; i < getArity(); ++i) {
3492  if (!(*getArg(i) == *(rhs_string_oper->getArg(i)))) {
3493  return false;
3494  }
3495  }
3496  if (chained_string_op_exprs_.size() !=
3497  rhs_string_oper->chained_string_op_exprs_.size()) {
3498  return false;
3499  }
3500  for (size_t i = 0; i < chained_string_op_exprs_.size(); ++i) {
3501  if (!(*(chained_string_op_exprs_[i]) ==
3502  *(rhs_string_oper->chained_string_op_exprs_[i]))) {
3503  return false;
3504  }
3505  }
3506  return true;
3507 }
size_t getArity() const
Definition: Analyzer.h:1506
std::vector< std::shared_ptr< Analyzer::Expr > > chained_string_op_exprs_
Definition: Analyzer.h:1618
StringOper(const SqlStringOpKind kind, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1469
SqlStringOpKind get_kind() const
Definition: Analyzer.h:1504
const Expr * getArg(const size_t i) const
Definition: Analyzer.h:1518

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

References args_, and kind_.

1939  {
1940  std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1941  for (const auto& arg : args_) {
1942  rewritten_args.emplace_back(arg->rewrite_agg_to_var(tlist));
1943  }
1944  return makeExpr<StringOper>(kind_, rewritten_args);
1945 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
SqlStringOpKind kind_
Definition: Analyzer.h:1616
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 1929 of file Analyzer.cpp.

References args_, and kind_.

1930  {
1931  std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1932  for (const auto& arg : args_) {
1933  rewritten_args.emplace_back(arg->rewrite_with_child_targetlist(tlist));
1934  }
1935  return makeExpr<StringOper>(kind_, rewritten_args);
1936 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
SqlStringOpKind kind_
Definition: Analyzer.h:1616
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 1920 of file Analyzer.cpp.

References args_, and kind_.

1921  {
1922  std::vector<std::shared_ptr<Analyzer::Expr>> rewritten_args;
1923  for (const auto& arg : args_) {
1924  rewritten_args.emplace_back(arg->rewrite_with_targetlist(tlist));
1925  }
1926  return makeExpr<StringOper>(kind_, rewritten_args);
1927 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
SqlStringOpKind kind_
Definition: Analyzer.h:1616
std::string Analyzer::StringOper::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 3531 of file Analyzer.cpp.

References args_, and kind_.

Referenced by check_operand_types().

3531  {
3532  std::string str{"(" + ::toString(kind_) + " "};
3533  for (const auto& arg : args_) {
3534  str += arg->toString();
3535  }
3536  str += ")";
3537  return str;
3538 }
std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1617
SqlStringOpKind kind_
Definition: Analyzer.h:1616
std::string toString() const override
Definition: Analyzer.cpp:3531

+ 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 1618 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: