OmniSciDB  dfae7c3b14
Parser::InValues Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::InValues:
+ Collaboration diagram for Parser::InValues:

Public Member Functions

 InValues (bool n, Expr *a, std::list< Expr *> *v)
 
const std::list< std::unique_ptr< Expr > > & get_value_list () const
 
std::shared_ptr< Analyzer::Expranalyze (const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
 
std::string to_string () const override
 
- Public Member Functions inherited from Parser::InExpr
 InExpr (bool n, Expr *a)
 
bool get_is_not () const
 
const Exprget_arg () const
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Private Attributes

std::list< std::unique_ptr< Expr > > value_list
 

Additional Inherited Members

- Public Types inherited from Parser::Expr
enum  TlistRefType { TLIST_NONE, TLIST_REF, TLIST_COPY }
 
- Protected Attributes inherited from Parser::InExpr
bool is_not
 
std::unique_ptr< Exprarg
 

Detailed Description

Definition at line 397 of file ParserNode.h.

Constructor & Destructor Documentation

◆ InValues()

Parser::InValues::InValues ( bool  n,
Expr a,
std::list< Expr *> *  v 
)
inline

Definition at line 399 of file ParserNode.h.

References CHECK.

399  : InExpr(n, a) {
400  CHECK(v);
401  for (const auto e : *v) {
402  value_list.emplace_back(e);
403  }
404  delete v;
405  }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
InExpr(bool n, Expr *a)
Definition: ParserNode.h:361
#define CHECK(condition)
Definition: Logger.h:197

Member Function Documentation

◆ analyze()

std::shared_ptr< Analyzer::Expr > Parser::InValues::analyze ( const Catalog_Namespace::Catalog catalog,
Analyzer::Query query,
TlistRefType  allow_tlist_ref = TLIST_NONE 
) const
overridevirtual

Implements Parser::InExpr.

Definition at line 379 of file ParserNode.cpp.

References Analyzer::BinOper::common_numeric_type(), Analyzer::BinOper::common_string_type(), SQLTypeInfo::get_compression(), SQLTypeInfo::is_number(), SQLTypeInfo::is_string(), kBOOLEAN, kENCODING_DICT, kNOT, and run_benchmark_import::result.

382  {
383  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
384  SQLTypeInfo ti = arg_expr->get_type_info();
385  bool dict_comp = ti.get_compression() == kENCODING_DICT;
386  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
387  for (auto& p : value_list) {
388  auto e = p->analyze(catalog, query, allow_tlist_ref);
389  if (ti != e->get_type_info()) {
390  if (ti.is_string() && e->get_type_info().is_string()) {
391  ti = Analyzer::BinOper::common_string_type(ti, e->get_type_info());
392  } else if (ti.is_number() && e->get_type_info().is_number()) {
393  ti = Analyzer::BinOper::common_numeric_type(ti, e->get_type_info());
394  } else {
395  throw std::runtime_error("IN expressions must contain compatible types.");
396  }
397  }
398  if (dict_comp) {
399  value_exprs.push_back(e->add_cast(arg_expr->get_type_info()));
400  } else {
401  value_exprs.push_back(e);
402  }
403  }
404  if (!dict_comp) {
405  arg_expr = arg_expr->decompress();
406  arg_expr = arg_expr->add_cast(ti);
407  std::list<std::shared_ptr<Analyzer::Expr>> cast_vals;
408  for (auto p : value_exprs) {
409  cast_vals.push_back(p->add_cast(ti));
410  }
411  value_exprs.swap(cast_vals);
412  }
413  std::shared_ptr<Analyzer::Expr> result =
414  makeExpr<Analyzer::InValues>(arg_expr, value_exprs);
415  if (is_not) {
416  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
417  }
418  return result;
419 }
bool is_string() const
Definition: sqltypes.h:417
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:267
std::unique_ptr< Expr > arg
Definition: ParserNode.h:372
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:398
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:438
Definition: sqldefs.h:39
bool is_number() const
Definition: sqltypes.h:422
+ Here is the call graph for this function:

◆ get_value_list()

const std::list<std::unique_ptr<Expr> >& Parser::InValues::get_value_list ( ) const
inline

Definition at line 406 of file ParserNode.h.

References to_string().

406 { return value_list; }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
+ Here is the call graph for this function:

◆ to_string()

std::string Parser::InValues::to_string ( ) const
overridevirtual

Reimplemented from Parser::InExpr.

Definition at line 1343 of file ParserNode.cpp.

References to_string().

1343  {
1344  std::string str = InExpr::to_string() + "(";
1345  bool notfirst = false;
1346  for (auto& p : value_list) {
1347  if (notfirst) {
1348  str += ", ";
1349  } else {
1350  notfirst = true;
1351  }
1352  str += p->to_string();
1353  }
1354  str += ")";
1355  return str;
1356 }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:414
std::string to_string() const override
+ Here is the call graph for this function:

Member Data Documentation

◆ value_list

std::list<std::unique_ptr<Expr> > Parser::InValues::value_list
private

Definition at line 414 of file ParserNode.h.


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