OmniSciDB  04ee39c94c
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 402 of file ParserNode.h.

Constructor & Destructor Documentation

◆ InValues()

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

Definition at line 404 of file ParserNode.h.

References CHECK, and v().

404  : InExpr(n, a) {
405  CHECK(v);
406  for (const auto e : *v) {
407  value_list.emplace_back(e);
408  }
409  delete v;
410  }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:419
T v(const TargetValue &r)
InExpr(bool n, Expr *a)
Definition: ParserNode.h:366
#define CHECK(condition)
Definition: Logger.h:187
+ Here is the call graph for this function:

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 360 of file ParserNode.cpp.

References Analyzer::BinOper::common_numeric_type(), Analyzer::BinOper::common_string_type(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_compression(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_number(), SQLTypeInfoCore< TYPE_FACET_PACK >::is_string(), kBOOLEAN, kENCODING_DICT, kNOT, and run-benchmark-import::result.

363  {
364  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
365  SQLTypeInfo ti = arg_expr->get_type_info();
366  bool dict_comp = ti.get_compression() == kENCODING_DICT;
367  std::list<std::shared_ptr<Analyzer::Expr>> value_exprs;
368  for (auto& p : value_list) {
369  auto e = p->analyze(catalog, query, allow_tlist_ref);
370  if (ti != e->get_type_info()) {
371  if (ti.is_string() && e->get_type_info().is_string()) {
372  ti = Analyzer::BinOper::common_string_type(ti, e->get_type_info());
373  } else if (ti.is_number() && e->get_type_info().is_number()) {
374  ti = Analyzer::BinOper::common_numeric_type(ti, e->get_type_info());
375  } else {
376  throw std::runtime_error("IN expressions must contain compatible types.");
377  }
378  }
379  if (dict_comp) {
380  value_exprs.push_back(e->add_cast(arg_expr->get_type_info()));
381  } else {
382  value_exprs.push_back(e);
383  }
384  }
385  if (!dict_comp) {
386  arg_expr = arg_expr->decompress();
387  arg_expr = arg_expr->add_cast(ti);
388  std::list<std::shared_ptr<Analyzer::Expr>> cast_vals;
389  for (auto p : value_exprs) {
390  cast_vals.push_back(p->add_cast(ti));
391  }
392  value_exprs.swap(cast_vals);
393  }
394  std::shared_ptr<Analyzer::Expr> result =
395  makeExpr<Analyzer::InValues>(arg_expr, value_exprs);
396  if (is_not) {
397  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
398  }
399  return result;
400 }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:331
std::unique_ptr< Expr > arg
Definition: ParserNode.h:377
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:419
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:379
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:419
bool is_number() const
Definition: sqltypes.h:455
bool is_string() const
Definition: sqltypes.h:450
Definition: sqldefs.h:39
+ 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 411 of file ParserNode.h.

References anonymous_namespace{UpdateMetadataTest.cpp}::query, and to_string().

411 { return value_list; }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:419
+ 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 1386 of file ParserNode.cpp.

References to_string().

1386  {
1387  std::string str = InExpr::to_string() + "(";
1388  bool notfirst = false;
1389  for (auto& p : value_list) {
1390  if (notfirst) {
1391  str += ", ";
1392  } else {
1393  notfirst = true;
1394  }
1395  str += p->to_string();
1396  }
1397  str += ")";
1398  return str;
1399 }
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:419
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 419 of file ParserNode.h.


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