OmniSciDB  c07336695a
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 426 of file ParserNode.h.

Constructor & Destructor Documentation

◆ BetweenExpr()

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

Definition at line 428 of file ParserNode.h.

429  : is_not(n), arg(a), lower(l), upper(u) {}
std::unique_ptr< Expr > lower
Definition: ParserNode.h:443
std::unique_ptr< Expr > arg
Definition: ParserNode.h:442
std::unique_ptr< Expr > upper
Definition: ParserNode.h:444

Member Function Documentation

◆ analyze()

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

References Analyzer::BinOper::analyze_type_info(), kAND, kBOOLEAN, kGE, kLE, kNOT, kONE, and run-benchmark-import::result.

405  {
406  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
407  auto lower_expr = lower->analyze(catalog, query, allow_tlist_ref);
408  auto upper_expr = upper->analyze(catalog, query, allow_tlist_ref);
409  SQLTypeInfo new_left_type, new_right_type;
411  arg_expr->get_type_info(),
412  lower_expr->get_type_info(),
413  &new_left_type,
414  &new_right_type);
415  auto lower_pred =
416  makeExpr<Analyzer::BinOper>(kBOOLEAN,
417  kGE,
418  kONE,
419  arg_expr->add_cast(new_left_type)->decompress(),
420  lower_expr->add_cast(new_right_type)->decompress());
422  arg_expr->get_type_info(),
423  lower_expr->get_type_info(),
424  &new_left_type,
425  &new_right_type);
426  auto upper_pred = makeExpr<Analyzer::BinOper>(
427  kBOOLEAN,
428  kLE,
429  kONE,
430  arg_expr->deep_copy()->add_cast(new_left_type)->decompress(),
431  upper_expr->add_cast(new_right_type)->decompress());
432  std::shared_ptr<Analyzer::Expr> result =
433  makeExpr<Analyzer::BinOper>(kBOOLEAN, kAND, kONE, lower_pred, upper_pred);
434  if (is_not) {
435  result = makeExpr<Analyzer::UOper>(kBOOLEAN, kNOT, result);
436  }
437  return result;
438 }
std::unique_ptr< Expr > lower
Definition: ParserNode.h:443
Definition: sqldefs.h:35
Definition: sqldefs.h:36
std::unique_ptr< Expr > arg
Definition: ParserNode.h:442
Definition: sqldefs.h:37
Definition: sqldefs.h:69
std::unique_ptr< Expr > upper
Definition: ParserNode.h:444
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:204
+ Here is the call graph for this function:

◆ get_arg()

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

Definition at line 431 of file ParserNode.h.

431 { return arg.get(); }
std::unique_ptr< Expr > arg
Definition: ParserNode.h:442

◆ get_is_not()

bool Parser::BetweenExpr::get_is_not ( ) const
inline

Definition at line 430 of file ParserNode.h.

430 { return is_not; }

◆ get_lower()

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

Definition at line 432 of file ParserNode.h.

432 { return lower.get(); }
std::unique_ptr< Expr > lower
Definition: ParserNode.h:443

◆ get_upper()

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

Definition at line 433 of file ParserNode.h.

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

433 { return upper.get(); }
std::unique_ptr< Expr > upper
Definition: ParserNode.h:444
+ Here is the call graph for this function:

◆ to_string()

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

Implements Parser::Expr.

Definition at line 1401 of file ParserNode.cpp.

1401  {
1402  std::string str = arg->to_string();
1403  if (is_not) {
1404  str += " NOT BETWEEN ";
1405  } else {
1406  str += " BETWEEN ";
1407  }
1408  str += lower->to_string() + " AND " + upper->to_string();
1409  return str;
1410 }
std::unique_ptr< Expr > lower
Definition: ParserNode.h:443
std::unique_ptr< Expr > arg
Definition: ParserNode.h:442
std::unique_ptr< Expr > upper
Definition: ParserNode.h:444

Member Data Documentation

◆ arg

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

Definition at line 442 of file ParserNode.h.

◆ is_not

bool Parser::BetweenExpr::is_not
private

Definition at line 441 of file ParserNode.h.

◆ lower

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

Definition at line 443 of file ParserNode.h.

◆ upper

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

Definition at line 444 of file ParserNode.h.


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