OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::CastExpr Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::CastExpr:
+ Collaboration diagram for Parser::CastExpr:

Public Member Functions

 CastExpr (Expr *a, SQLType *t)
 
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

std::unique_ptr< Exprarg
 
std::unique_ptr< SQLTypetarget_type
 

Additional Inherited Members

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

Detailed Description

Definition at line 637 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::CastExpr::CastExpr ( Expr a,
SQLType t 
)
inline

Definition at line 639 of file ParserNode.h.

639 : arg(a), target_type(t) {}
std::unique_ptr< SQLType > target_type
Definition: ParserNode.h:650
std::unique_ptr< Expr > arg
Definition: ParserNode.h:649

Member Function Documentation

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

Implements Parser::Expr.

Definition at line 863 of file ParserNode.cpp.

References kENCODING_NONE.

866  {
867  target_type->check_type();
868  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
869  SQLTypeInfo ti(target_type->get_type(),
870  target_type->get_param1(),
871  target_type->get_param2(),
872  arg_expr->get_type_info().get_notnull());
873  if (arg_expr->get_type_info().get_type() != target_type->get_type() &&
874  arg_expr->get_type_info().get_compression() != kENCODING_NONE) {
875  arg_expr->decompress();
876  }
877  return arg_expr->add_cast(ti);
878 }
std::unique_ptr< SQLType > target_type
Definition: ParserNode.h:650
std::unique_ptr< Expr > arg
Definition: ParserNode.h:649
std::string Parser::CastExpr::to_string ( ) const
inlineoverridevirtual

Implements Parser::Expr.

Definition at line 644 of file ParserNode.h.

References arg, and target_type.

644  {
645  return "CAST(" + arg->to_string() + " AS " + target_type->to_string() + ")";
646  }
std::unique_ptr< SQLType > target_type
Definition: ParserNode.h:650
std::unique_ptr< Expr > arg
Definition: ParserNode.h:649

Member Data Documentation

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

Definition at line 649 of file ParserNode.h.

Referenced by to_string().

std::unique_ptr<SQLType> Parser::CastExpr::target_type
private

Definition at line 650 of file ParserNode.h.

Referenced by to_string().


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