Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::BoundComparisonExpression Class Reference
Inheritance diagram for duckdb::BoundComparisonExpression:
Collaboration diagram for duckdb::BoundComparisonExpression:

Public Member Functions

 BoundComparisonExpression (ExpressionType type, unique_ptr< Expression > left, unique_ptr< Expression > right)
string ToString () const override
 Convert the Expression to a String.
bool Equals (const BaseExpression &other) const override
 Returns true if this expression is equal to another expression.
unique_ptr< Expression > Copy () const override
 Create a copy of this expression.
void Serialize (Serializer &serializer) const override
Public Member Functions inherited from duckdb::Expression
 Expression (ExpressionType type, ExpressionClass expression_class, LogicalType return_type)
bool IsAggregate () const override
 Returns true if this expression is an aggregate or not.
bool IsWindow () const override
 Returns true if the expression has a window function or not.
bool HasSubquery () const override
 Returns true if the query contains a subquery.
bool IsScalar () const override
 Returns true if expression does not contain a group ref or col ref or parameter.
bool HasParameter () const override
 Returns true if the expression has a parameter.
virtual bool IsVolatile () const
virtual bool IsConsistent () const
virtual bool PropagatesNullValues () const
virtual bool IsFoldable () const
virtual bool CanThrow () const
hash_t Hash () const override
bool Equals (const BaseExpression &other) const override
 Returns true if this expression is equal to another expression.
Public Member Functions inherited from duckdb::BaseExpression
 BaseExpression (ExpressionType type, ExpressionClass expression_class)
 Create an Expression.
ExpressionClass GetExpressionClass () const
 Returns the class of the expression.
ExpressionType GetExpressionType () const
 Returns the type of the expression.
void SetExpressionTypeUnsafe (ExpressionType new_type)
optional_idx GetQueryLocation () const
 Returns the location in the query (if any).
void SetQueryLocation (optional_idx location)
 Sets the location in the query.
bool HasAlias () const
 Returns true if the expression has a non-empty alias.
const string & GetAlias () const
 Returns the alias of the expression.
void SetAlias (const string &alias_p)
 Sets the alias of the expression.
void SetAlias (string &&alias_p)
 Sets the alias of the expression.
void ClearAlias ()
 Clears the alias of the expression.
virtual string GetName () const
 Get the name of the expression.
void Print () const
 Print the expression to stdout.
bool operator== (const BaseExpression &rhs) const
virtual void Verify () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< Expression > Deserialize (Deserializer &deserializer)
static LogicalType BindComparison (ClientContext &context, const LogicalType &left_type, const LogicalType &right_type, ExpressionType comparison_type)
static bool TryBindComparison (ClientContext &context, const LogicalType &left_type, const LogicalType &right_type, LogicalType &result_type, ExpressionType comparison_type)
Static Public Member Functions inherited from duckdb::Expression
static bool Equals (const Expression &left, const Expression &right)
static bool Equals (const unique_ptr< Expression > &left, const unique_ptr< Expression > &right)
static bool ListEquals (const vector< unique_ptr< Expression > > &left, const vector< unique_ptr< Expression > > &right)
static unique_ptr< Expression > Deserialize (Deserializer &deserializer)
Static Public Member Functions inherited from duckdb::BaseExpression
static bool Equals (const BaseExpression &left, const BaseExpression &right)

Public Attributes

unique_ptr< Expression > left
unique_ptr< Expression > right
Public Attributes inherited from duckdb::Expression
LogicalType return_type
 The return type of the expression.
unique_ptr< BaseStatistics > verification_stats
 Expression statistics (if any) - ONLY USED FOR VERIFICATION.
Public Attributes inherited from duckdb::BaseExpression
ExpressionType type
 Type of the expression.
ExpressionClass expression_class
 The expression class of the node.
string alias
 The alias of the expression,.
optional_idx query_location
 The location in the query (if any).

Static Public Attributes

static constexpr const ExpressionClass TYPE = ExpressionClass::BOUND_COMPARISON

Additional Inherited Members

Protected Member Functions inherited from duckdb::Expression
void CopyProperties (const Expression &other)

Constructor & Destructor Documentation

◆ BoundComparisonExpression()

duckdb::BoundComparisonExpression::BoundComparisonExpression ( ExpressionType type,
unique_ptr< Expression > left,
unique_ptr< Expression > right )
376075 : Expression(type, ExpressionClass::BOUND_COMPARISON, LogicalType::BOOLEAN), left(std::move(left)),
376076 right(std::move(right)) {
376077}
ExpressionType type
Type of the expression.
Definition duckdb.hpp:13287

Member Function Documentation

◆ ToString()

string duckdb::BoundComparisonExpression::ToString ( ) const
overridevirtual

Convert the Expression to a String.

Implements duckdb::BaseExpression.

376079 {
376081}
string ToString() const override
Convert the Expression to a String.
Definition duckdb.cpp:336572
Here is the call graph for this function:

◆ Equals()

bool duckdb::BoundComparisonExpression::Equals ( const BaseExpression & other) const
overridevirtual

Returns true if this expression is equal to another expression.

Reimplemented from duckdb::BaseExpression.

376083 {
376084 if (!Expression::Equals(other_p)) {
376085 return false;
376086 }
376087 auto &other = other_p.Cast<BoundComparisonExpression>();
376088 if (!Expression::Equals(*left, *other.left)) {
376089 return false;
376090 }
376091 if (!Expression::Equals(*right, *other.right)) {
376092 return false;
376093 }
376094 return true;
376095}
bool Equals(const BaseExpression &other) const override
Returns true if this expression is equal to another expression.
Definition duckdb.hpp:17762
Here is the call graph for this function:

◆ Copy()

unique_ptr< Expression > duckdb::BoundComparisonExpression::Copy ( ) const
overridevirtual

Create a copy of this expression.

Implements duckdb::Expression.

376097 {
376098 auto copy = make_uniq<BoundComparisonExpression>(type, left->Copy(), right->Copy());
376099 copy->CopyProperties(*this);
376100 return std::move(copy);
376101}

◆ Serialize()

void duckdb::BoundComparisonExpression::Serialize ( Serializer & serializer) const
overridevirtual

Reimplemented from duckdb::Expression.

416064 {
416065 Expression::Serialize(serializer);
416066 serializer.WritePropertyWithDefault<unique_ptr<Expression>>(200, "left", left);
416067 serializer.WritePropertyWithDefault<unique_ptr<Expression>>(201, "right", right);
416068}

◆ Deserialize()

unique_ptr< Expression > duckdb::BoundComparisonExpression::Deserialize ( Deserializer & deserializer)
static
416070 {
416071 auto left = deserializer.ReadPropertyWithDefault<unique_ptr<Expression>>(200, "left");
416072 auto right = deserializer.ReadPropertyWithDefault<unique_ptr<Expression>>(201, "right");
416073 auto result = duckdb::unique_ptr<BoundComparisonExpression>(new BoundComparisonExpression(deserializer.Get<ExpressionType>(), std::move(left), std::move(right)));
416074 return std::move(result);
416075}

◆ BindComparison()

LogicalType duckdb::BoundComparisonExpression::BindComparison ( ClientContext & context,
const LogicalType & left_type,
const LogicalType & right_type,
ExpressionType comparison_type )
static
360713 {
360714 LogicalType result_type;
360715 if (!BoundComparisonExpression::TryBindComparison(context, left_type, right_type, result_type, comparison_type)) {
360716 throw BinderException("Cannot mix values of type %s and %s - an explicit cast is required",
360717 left_type.ToString(), right_type.ToString());
360718 }
360719 return result_type;
360720}

◆ TryBindComparison()

bool duckdb::BoundComparisonExpression::TryBindComparison ( ClientContext & context,
const LogicalType & left_type,
const LogicalType & right_type,
LogicalType & result_type,
ExpressionType comparison_type )
static
360643 {
360644 LogicalType res;
360645 bool is_equality;
360646 switch (comparison_type) {
360647 case ExpressionType::COMPARE_EQUAL:
360648 case ExpressionType::COMPARE_NOTEQUAL:
360649 case ExpressionType::COMPARE_IN:
360650 case ExpressionType::COMPARE_NOT_IN:
360651 case ExpressionType::COMPARE_DISTINCT_FROM:
360652 case ExpressionType::COMPARE_NOT_DISTINCT_FROM:
360653 is_equality = true;
360654 break;
360655 default:
360656 is_equality = false;
360657 break;
360658 }
360659 if (is_equality) {
360660 res = LogicalType::ForceMaxLogicalType(left_type, right_type);
360661 } else {
360662 if (!LogicalType::TryGetMaxLogicalType(context, left_type, right_type, res)) {
360663 return false;
360664 }
360665 }
360666 switch (res.id()) {
360667 case LogicalTypeId::DECIMAL: {
360668 // result is a decimal: we need the maximum width and the maximum scale over width
360669 vector<LogicalType> argument_types = {left_type, right_type};
360670 uint8_t max_width = 0, max_scale = 0, max_width_over_scale = 0;
360671 for (idx_t i = 0; i < argument_types.size(); i++) {
360672 uint8_t width, scale;
360673 auto can_convert = argument_types[i].GetDecimalProperties(width, scale);
360674 if (!can_convert) {
360675 result_type = res;
360676 return true;
360677 }
360678 max_width = MaxValue<uint8_t>(width, max_width);
360679 max_scale = MaxValue<uint8_t>(scale, max_scale);
360680 max_width_over_scale = MaxValue<uint8_t>(width - scale, max_width_over_scale);
360681 }
360682 max_width = MaxValue<uint8_t>(max_scale + max_width_over_scale, max_width);
360683 if (max_width > Decimal::MAX_WIDTH_DECIMAL) {
360684 // target width does not fit in decimal: truncate the scale (if possible) to try and make it fit
360685 max_width = Decimal::MAX_WIDTH_DECIMAL;
360686 }
360687 res = LogicalType::DECIMAL(max_width, max_scale);
360688 break;
360689 }
360690 case LogicalTypeId::VARCHAR:
360691 // for comparison with strings, we prefer to bind to the numeric types
360692 if (left_type.id() != LogicalTypeId::VARCHAR && SwitchVarcharComparison(left_type)) {
360693 res = LogicalType::NormalizeType(left_type);
360694 } else if (right_type.id() != LogicalTypeId::VARCHAR && SwitchVarcharComparison(right_type)) {
360695 res = LogicalType::NormalizeType(right_type);
360696 } else {
360697 // else: check if collations are compatible
360698 auto left_collation = StringType::GetCollation(left_type);
360699 auto right_collation = StringType::GetCollation(right_type);
360700 if (!left_collation.empty() && !right_collation.empty() && left_collation != right_collation) {
360701 throw BinderException("Cannot combine types with different collation!");
360702 }
360703 }
360704 break;
360705 default:
360706 break;
360707 }
360708 result_type = res;
360709 return true;
360710}
void scale(cv::Mat &mat, const cv::Mat &range, const T min, const T max)
::uint8_t uint8_t
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
static DUCKDB_API LogicalType ForceMaxLogicalType(const LogicalType &left, const LogicalType &right)
Forcibly returns a maximum logical type - similar to MaxLogicalType but never throws....
Definition duckdb.cpp:140319
static DUCKDB_API LogicalType NormalizeType(const LogicalType &type)
Normalize a type - removing literals.
Definition duckdb.cpp:139907

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