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

Constructor & Destructor Documentation

◆ CastExpr()

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

Definition at line 644 of file ParserNode.h.

References anonymous_namespace{UpdateMetadataTest.cpp}::query.

644 : arg(a), target_type(t) {}
std::unique_ptr< SQLType > target_type
Definition: ParserNode.h:655
std::unique_ptr< Expr > arg
Definition: ParserNode.h:654

Member Function Documentation

◆ analyze()

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

References kENCODING_NONE.

845  {
846  target_type->check_type();
847  auto arg_expr = arg->analyze(catalog, query, allow_tlist_ref);
848  SQLTypeInfo ti(target_type->get_type(),
849  target_type->get_param1(),
850  target_type->get_param2(),
851  arg_expr->get_type_info().get_notnull());
852  if (arg_expr->get_type_info().get_type() != target_type->get_type() &&
853  arg_expr->get_type_info().get_compression() != kENCODING_NONE) {
854  arg_expr->decompress();
855  }
856  return arg_expr->add_cast(ti);
857 }
std::unique_ptr< SQLType > target_type
Definition: ParserNode.h:655
std::unique_ptr< Expr > arg
Definition: ParserNode.h:654

◆ to_string()

std::string Parser::CastExpr::to_string ( ) const
inlineoverridevirtual

Implements Parser::Expr.

Definition at line 649 of file ParserNode.h.

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

Member Data Documentation

◆ arg

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

Definition at line 654 of file ParserNode.h.

◆ target_type

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

Definition at line 655 of file ParserNode.h.


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