OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 437 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 439 of file ParserNode.h.

440  : is_not(n), arg(a), lower(l), upper(u) {}
std::unique_ptr< Expr > lower
Definition: ParserNode.h:454
std::unique_ptr< Expr > arg
Definition: ParserNode.h:453
std::unique_ptr< Expr > upper
Definition: ParserNode.h:455

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

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

409  {
410  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
411  auto lower_expr = lower->analyze(catalog, query, allow_tlist_ref);
412  auto upper_expr = upper->analyze(catalog, query, allow_tlist_ref);
413  SQLTypeInfo new_left_type, new_right_type;
415  arg_expr->get_type_info(),
416  lower_expr->get_type_info(),
417  &new_left_type,
418  &new_right_type);
419  auto lower_pred =
420  makeExpr<Analyzer::BinOper>(kBOOLEAN,
421  kGE,
422  kONE,
423  arg_expr->add_cast(new_left_type)->decompress(),
424  lower_expr->add_cast(new_right_type)->decompress());
426  arg_expr->get_type_info(),
427  lower_expr->get_type_info(),
428  &new_left_type,
429  &new_right_type);
430  auto upper_pred = makeExpr<Analyzer::BinOper>(
431  kBOOLEAN,
432  kLE,
433  kONE,
434  arg_expr->deep_copy()->add_cast(new_left_type)->decompress(),
435  upper_expr->add_cast(new_right_type)->decompress());
436  std::shared_ptr<Analyzer::Expr> result =
437  makeExpr<Analyzer::BinOper>(kBOOLEAN, kAND, kONE, lower_pred, upper_pred);
438  if (is_not) {
439  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
440  }
441  return result;
442 }
std::unique_ptr< Expr > lower
Definition: ParserNode.h:454
Definition: sqldefs.h:35
Definition: sqldefs.h:36
std::unique_ptr< Expr > arg
Definition: ParserNode.h:453
Definition: sqldefs.h:37
Definition: sqldefs.h:69
std::unique_ptr< Expr > upper
Definition: ParserNode.h:455
Definition: sqldefs.h:39
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:212

+ Here is the call graph for this function:

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

Definition at line 442 of file ParserNode.h.

References arg.

442 { return arg.get(); }
std::unique_ptr< Expr > arg
Definition: ParserNode.h:453
bool Parser::BetweenExpr::get_is_not ( ) const
inline

Definition at line 441 of file ParserNode.h.

References is_not.

441 { return is_not; }
const Expr* Parser::BetweenExpr::get_lower ( ) const
inline

Definition at line 443 of file ParserNode.h.

References lower.

443 { return lower.get(); }
std::unique_ptr< Expr > lower
Definition: ParserNode.h:454
const Expr* Parser::BetweenExpr::get_upper ( ) const
inline

Definition at line 444 of file ParserNode.h.

References upper.

444 { return upper.get(); }
std::unique_ptr< Expr > upper
Definition: ParserNode.h:455
std::string Parser::BetweenExpr::to_string ( ) const
overridevirtual

Implements Parser::Expr.

Definition at line 1416 of file ParserNode.cpp.

1416  {
1417  std::string str = arg->to_string();
1418  if (is_not) {
1419  str += " NOT BETWEEN ";
1420  } else {
1421  str += " BETWEEN ";
1422  }
1423  str += lower->to_string() + " AND " + upper->to_string();
1424  return str;
1425 }
std::unique_ptr< Expr > lower
Definition: ParserNode.h:454
std::unique_ptr< Expr > arg
Definition: ParserNode.h:453
std::unique_ptr< Expr > upper
Definition: ParserNode.h:455

Member Data Documentation

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

Definition at line 453 of file ParserNode.h.

Referenced by get_arg().

bool Parser::BetweenExpr::is_not
private

Definition at line 452 of file ParserNode.h.

Referenced by get_is_not().

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

Definition at line 454 of file ParserNode.h.

Referenced by get_lower().

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

Definition at line 455 of file ParserNode.h.

Referenced by get_upper().


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