OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::BetweenExpr Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::BetweenExpr:
+ Collaboration diagram for Parser::BetweenExpr:

Public Member Functions

 BetweenExpr (bool n, Expr *a, Expr *l, Expr *u)
 
bool get_is_not () const
 
const Exprget_arg () const
 
const Exprget_lower () const
 
const Exprget_upper () 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::Node
virtual ~Node ()
 

Private Attributes

bool is_not_
 
std::unique_ptr< Exprarg_
 
std::unique_ptr< Exprlower_
 
std::unique_ptr< Exprupper_
 

Additional Inherited Members

- Public Types inherited from Parser::Expr
enum  TlistRefType { TLIST_NONE, TLIST_REF, TLIST_COPY }
 

Detailed Description

Definition at line 427 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::BetweenExpr::BetweenExpr ( bool  n,
Expr a,
Expr l,
Expr u 
)
inline

Definition at line 429 of file ParserNode.h.

430  : is_not_(n), arg_(a), lower_(l), upper_(u) {}
std::unique_ptr< Expr > lower_
Definition: ParserNode.h:444
constexpr double a
Definition: Utm.h:32
std::unique_ptr< Expr > upper_
Definition: ParserNode.h:445
constexpr double n
Definition: Utm.h:38
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:443

Member Function Documentation

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

Implements Parser::Expr.

Definition at line 577 of file ParserNode.cpp.

References Analyzer::BinOper::analyze_type_info(), kAND, kBOOLEAN, kGE, kLE, kNOT, kONE, and run_benchmark_import::result.

580  {
581  auto arg_expr = arg_->analyze(catalog, query, allow_tlist_ref);
582  auto lower_expr = lower_->analyze(catalog, query, allow_tlist_ref);
583  auto upper_expr = upper_->analyze(catalog, query, allow_tlist_ref);
584  SQLTypeInfo new_left_type, new_right_type;
586  arg_expr->get_type_info(),
587  lower_expr->get_type_info(),
588  &new_left_type,
589  &new_right_type);
590  auto lower_pred =
591  makeExpr<Analyzer::BinOper>(kBOOLEAN,
592  kGE,
593  kONE,
594  arg_expr->add_cast(new_left_type)->decompress(),
595  lower_expr->add_cast(new_right_type)->decompress());
597  arg_expr->get_type_info(),
598  lower_expr->get_type_info(),
599  &new_left_type,
600  &new_right_type);
601  auto upper_pred = makeExpr<Analyzer::BinOper>(
602  kBOOLEAN,
603  kLE,
604  kONE,
605  arg_expr->deep_copy()->add_cast(new_left_type)->decompress(),
606  upper_expr->add_cast(new_right_type)->decompress());
607  std::shared_ptr<Analyzer::Expr> result =
608  makeExpr<Analyzer::BinOper>(kBOOLEAN, kAND, kONE, lower_pred, upper_pred);
609  if (is_not_) {
610  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
611  }
612  return result;
613 }
std::unique_ptr< Expr > lower_
Definition: ParserNode.h:444
Definition: sqldefs.h:37
Definition: sqldefs.h:38
Definition: sqldefs.h:39
Definition: sqldefs.h:74
std::unique_ptr< Expr > upper_
Definition: ParserNode.h:445
Definition: sqldefs.h:41
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:443
static SQLTypeInfo analyze_type_info(SQLOps op, const SQLTypeInfo &left_type, const SQLTypeInfo &right_type, SQLTypeInfo *new_left_type, SQLTypeInfo *new_right_type)
Definition: Analyzer.cpp:267

+ Here is the call graph for this function:

const Expr* Parser::BetweenExpr::get_arg ( ) const
inline

Definition at line 432 of file ParserNode.h.

References arg_.

432 { return arg_.get(); }
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:443
bool Parser::BetweenExpr::get_is_not ( ) const
inline

Definition at line 431 of file ParserNode.h.

References is_not_.

431 { return is_not_; }
const Expr* Parser::BetweenExpr::get_lower ( ) const
inline

Definition at line 433 of file ParserNode.h.

References lower_.

433 { return lower_.get(); }
std::unique_ptr< Expr > lower_
Definition: ParserNode.h:444
const Expr* Parser::BetweenExpr::get_upper ( ) const
inline

Definition at line 434 of file ParserNode.h.

References upper_.

434 { return upper_.get(); }
std::unique_ptr< Expr > upper_
Definition: ParserNode.h:445
std::string Parser::BetweenExpr::to_string ( ) const
overridevirtual

Implements Parser::Expr.

Definition at line 2228 of file ParserNode.cpp.

2228  {
2229  std::string str = arg_->to_string();
2230  if (is_not_) {
2231  str += " NOT BETWEEN ";
2232  } else {
2233  str += " BETWEEN ";
2234  }
2235  str += lower_->to_string() + " AND " + upper_->to_string();
2236  return str;
2237 }
std::unique_ptr< Expr > lower_
Definition: ParserNode.h:444
std::unique_ptr< Expr > upper_
Definition: ParserNode.h:445
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:443

Member Data Documentation

std::unique_ptr<Expr> Parser::BetweenExpr::arg_
private

Definition at line 443 of file ParserNode.h.

Referenced by get_arg().

bool Parser::BetweenExpr::is_not_
private

Definition at line 442 of file ParserNode.h.

Referenced by get_is_not().

std::unique_ptr<Expr> Parser::BetweenExpr::lower_
private

Definition at line 444 of file ParserNode.h.

Referenced by get_lower().

std::unique_ptr<Expr> Parser::BetweenExpr::upper_
private

Definition at line 445 of file ParserNode.h.

Referenced by get_upper().


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