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::BoundWindowExpression Class Reference
Inheritance diagram for duckdb::BoundWindowExpression:
Collaboration diagram for duckdb::BoundWindowExpression:

Public Member Functions

 BoundWindowExpression (ExpressionType type, LogicalType return_type, unique_ptr< AggregateFunction > aggregate, unique_ptr< FunctionData > bind_info)
bool IsWindow () const override
 Returns true if the expression has a window function or not.
bool IsFoldable () const override
string ToString () const override
 Convert the Expression to a String.
idx_t GetSharedOrders (const BoundWindowExpression &other) const
bool PartitionsAreEquivalent (const BoundWindowExpression &other) const
bool KeysAreCompatible (const BoundWindowExpression &other) const
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 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 idx_t GetSharedOrders (const vector< BoundOrderByNode > &lhs, const vector< BoundOrderByNode > &rhs)
 The number of ordering clauses the functions share.
static unique_ptr< Expression > Deserialize (Deserializer &deserializer)
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< AggregateFunction > aggregate
 The bound aggregate function.
unique_ptr< FunctionData > bind_info
 The bound function info.
vector< unique_ptr< Expression > > children
 The child expressions of the main window function.
vector< unique_ptr< Expression > > partitions
 The set of expressions to partition by.
vector< unique_ptr< BaseStatistics > > partitions_stats
 Statistics belonging to the partitions expressions.
vector< BoundOrderByNode > orders
 The set of ordering clauses.
unique_ptr< Expression > filter_expr
 Expression representing a filter, only used for aggregates.
bool ignore_nulls
 True to ignore NULL values.
bool distinct
 Whether or not the aggregate function is distinct, only used for aggregates.
WindowBoundary start = WindowBoundary::INVALID
 The window boundaries.
WindowBoundary end = WindowBoundary::INVALID
WindowExcludeMode exclude_clause = WindowExcludeMode::NO_OTHER
 The EXCLUDE clause.
unique_ptr< Expression > start_expr
unique_ptr< Expression > end_expr
unique_ptr< Expression > offset_expr
 Offset and default expressions for WINDOW_LEAD and WINDOW_LAG functions.
unique_ptr< Expression > default_expr
vector< BoundOrderByNode > arg_orders
vector< unique_ptr< BaseStatistics > > expr_stats
 Statistics belonging to the other expressions (start, end, offset, default).
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_WINDOW

Additional Inherited Members

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

Constructor & Destructor Documentation

◆ BoundWindowExpression()

duckdb::BoundWindowExpression::BoundWindowExpression ( ExpressionType type,
LogicalType return_type,
unique_ptr< AggregateFunction > aggregate,
unique_ptr< FunctionData > bind_info )
376867 : Expression(type, ExpressionClass::BOUND_WINDOW, std::move(return_type)), aggregate(std::move(aggregate)),
376868 bind_info(std::move(bind_info)), ignore_nulls(false), distinct(false) {
376869}
ExpressionType type
Type of the expression.
Definition duckdb.hpp:13287
bool distinct
Whether or not the aggregate function is distinct, only used for aggregates.
Definition duckdb.cpp:149826
bool ignore_nulls
True to ignore NULL values.
Definition duckdb.cpp:149824
unique_ptr< FunctionData > bind_info
The bound function info.
Definition duckdb.cpp:149812
unique_ptr< AggregateFunction > aggregate
The bound aggregate function.
Definition duckdb.cpp:149810
LogicalType return_type
The return type of the expression.
Definition duckdb.hpp:17743

Member Function Documentation

◆ IsWindow()

bool duckdb::BoundWindowExpression::IsWindow ( ) const
inlineoverridevirtual

Returns true if the expression has a window function or not.

Implements duckdb::BaseExpression.

149848 {
149849 return true;
149850 }

◆ IsFoldable()

bool duckdb::BoundWindowExpression::IsFoldable ( ) const
inlineoverridevirtual

Reimplemented from duckdb::Expression.

149851 {
149852 return false;
149853 }

◆ ToString()

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

Convert the Expression to a String.

Implements duckdb::BaseExpression.

376871 {
376872 string function_name = aggregate.get() ? aggregate->name : ExpressionTypeToString(type);
376874 function_name);
376875}
string ToString() const override
Convert the Expression to a String.
Definition duckdb.cpp:337784
Here is the call graph for this function:

◆ GetSharedOrders() [1/2]

idx_t duckdb::BoundWindowExpression::GetSharedOrders ( const vector< BoundOrderByNode > & lhs,
const vector< BoundOrderByNode > & rhs )
static

The number of ordering clauses the functions share.

376957 {
376958 const auto overlap = MinValue<idx_t>(lhs.size(), rhs.size());
376959
376960 idx_t result = 0;
376961 for (; result < overlap; ++result) {
376962 if (!lhs.at(result).Equals(rhs.at(result))) {
376963 return 0;
376964 }
376965 }
376966
376967 return result;
376968}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ GetSharedOrders() [2/2]

idx_t duckdb::BoundWindowExpression::GetSharedOrders ( const BoundWindowExpression & other) const
376970 {
376971 return GetSharedOrders(orders, other.orders);
376972}
static idx_t GetSharedOrders(const vector< BoundOrderByNode > &lhs, const vector< BoundOrderByNode > &rhs)
The number of ordering clauses the functions share.
Definition duckdb.cpp:376957
vector< BoundOrderByNode > orders
The set of ordering clauses.
Definition duckdb.cpp:149820

◆ PartitionsAreEquivalent()

bool duckdb::BoundWindowExpression::PartitionsAreEquivalent ( const BoundWindowExpression & other) const
376939 {
376940 // Partitions are not order sensitive.
376941 if (partitions.size() != other.partitions.size()) {
376942 return false;
376943 }
376944 // TODO: Should partitions be an expression_set_t?
376945 expression_set_t others;
376946 for (const auto &partition : other.partitions) {
376947 others.insert(*partition);
376948 }
376949 for (const auto &partition : partitions) {
376950 if (!others.count(*partition)) {
376951 return false;
376952 }
376953 }
376954 return true;
376955}
vector< unique_ptr< Expression > > partitions
The set of expressions to partition by.
Definition duckdb.cpp:149816

◆ KeysAreCompatible()

bool duckdb::BoundWindowExpression::KeysAreCompatible ( const BoundWindowExpression & other) const
376974 {
376975 if (!PartitionsAreEquivalent(other)) {
376976 return false;
376977 }
376978 // check if the orderings are equivalent
376979 if (orders.size() != other.orders.size()) {
376980 return false;
376981 }
376982 for (idx_t i = 0; i < orders.size(); i++) {
376983 if (!orders[i].Equals(other.orders[i])) {
376984 return false;
376985 }
376986 }
376987 return true;
376988}
bool Equals(const BaseExpression &other) const override
Returns true if this expression is equal to another expression.
Definition duckdb.cpp:376877

◆ Equals()

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

Returns true if this expression is equal to another expression.

Reimplemented from duckdb::BaseExpression.

376877 {
376878 if (!Expression::Equals(other_p)) {
376879 return false;
376880 }
376881 auto &other = other_p.Cast<BoundWindowExpression>();
376882
376883 if (ignore_nulls != other.ignore_nulls) {
376884 return false;
376885 }
376886 if (distinct != other.distinct) {
376887 return false;
376888 }
376889 if (start != other.start || end != other.end) {
376890 return false;
376891 }
376892 if (exclude_clause != other.exclude_clause) {
376893 return false;
376894 }
376895
376896 // If there are aggregates, check they are equal
376897 if (aggregate.get() != other.aggregate.get()) {
376898 if (!aggregate || !other.aggregate || *aggregate != *other.aggregate) {
376899 return false;
376900 }
376901 }
376902 // If there's function data, check if they are equal
376903 if (bind_info.get() != other.bind_info.get()) {
376904 if (!bind_info || !other.bind_info || !bind_info->Equals(*other.bind_info)) {
376905 return false;
376906 }
376907 }
376908 // check if the child expressions are equivalent
376909 if (!Expression::ListEquals(children, other.children)) {
376910 return false;
376911 }
376912 if (!Expression::ListEquals(partitions, other.partitions)) {
376913 return false;
376914 }
376915 // check if the filter expressions are equivalent
376916 if (!Expression::Equals(filter_expr, other.filter_expr)) {
376917 return false;
376918 }
376919
376920 // check if the argument orderings are equivalent
376921 if (arg_orders.size() != other.arg_orders.size()) {
376922 return false;
376923 }
376924 for (idx_t i = 0; i < arg_orders.size(); i++) {
376925 if (!arg_orders[i].Equals(other.arg_orders[i])) {
376926 return false;
376927 }
376928 }
376929
376930 // check if the framing expressions are equivalent
376931 if (!Expression::Equals(start_expr, other.start_expr) || !Expression::Equals(end_expr, other.end_expr) ||
376932 !Expression::Equals(offset_expr, other.offset_expr) || !Expression::Equals(default_expr, other.default_expr)) {
376933 return false;
376934 }
376935
376936 return KeysAreCompatible(other);
376937}
unique_ptr< Expression > offset_expr
Offset and default expressions for WINDOW_LEAD and WINDOW_LAG functions.
Definition duckdb.cpp:149836
vector< unique_ptr< Expression > > children
The child expressions of the main window function.
Definition duckdb.cpp:149814
unique_ptr< Expression > filter_expr
Expression representing a filter, only used for aggregates.
Definition duckdb.cpp:149822
vector< BoundOrderByNode > arg_orders
Definition duckdb.cpp:149842
WindowExcludeMode exclude_clause
The EXCLUDE clause.
Definition duckdb.cpp:149831
WindowBoundary start
The window boundaries.
Definition duckdb.cpp:149828
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:
Here is the caller graph for this function:

◆ Copy()

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

Create a copy of this expression.

Implements duckdb::Expression.

376990 {
376991 auto new_window = make_uniq<BoundWindowExpression>(type, return_type, nullptr, nullptr);
376992 new_window->CopyProperties(*this);
376993
376994 if (aggregate) {
376995 new_window->aggregate = make_uniq<AggregateFunction>(*aggregate);
376996 }
376997 if (bind_info) {
376998 new_window->bind_info = bind_info->Copy();
376999 }
377000 for (auto &child : children) {
377001 new_window->children.push_back(child->Copy());
377002 }
377003 for (auto &e : partitions) {
377004 new_window->partitions.push_back(e->Copy());
377005 }
377006 for (auto &ps : partitions_stats) {
377007 if (ps) {
377008 new_window->partitions_stats.push_back(ps->ToUnique());
377009 } else {
377010 new_window->partitions_stats.push_back(nullptr);
377011 }
377012 }
377013 for (auto &o : orders) {
377014 new_window->orders.emplace_back(o.type, o.null_order, o.expression->Copy());
377015 }
377016
377017 for (auto &o : arg_orders) {
377018 new_window->arg_orders.emplace_back(o.type, o.null_order, o.expression->Copy());
377019 }
377020
377021 new_window->filter_expr = filter_expr ? filter_expr->Copy() : nullptr;
377022
377023 new_window->start = start;
377024 new_window->end = end;
377025 new_window->exclude_clause = exclude_clause;
377026 new_window->start_expr = start_expr ? start_expr->Copy() : nullptr;
377027 new_window->end_expr = end_expr ? end_expr->Copy() : nullptr;
377028 new_window->offset_expr = offset_expr ? offset_expr->Copy() : nullptr;
377029 new_window->default_expr = default_expr ? default_expr->Copy() : nullptr;
377030 new_window->ignore_nulls = ignore_nulls;
377031 new_window->distinct = distinct;
377032
377033 for (auto &es : expr_stats) {
377034 if (es) {
377035 new_window->expr_stats.push_back(es->ToUnique());
377036 } else {
377037 new_window->expr_stats.push_back(nullptr);
377038 }
377039 }
377040 return std::move(new_window);
377041}
vector< unique_ptr< BaseStatistics > > partitions_stats
Statistics belonging to the partitions expressions.
Definition duckdb.cpp:149818
vector< unique_ptr< BaseStatistics > > expr_stats
Statistics belonging to the other expressions (start, end, offset, default).
Definition duckdb.cpp:149845

◆ Serialize()

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

Reimplemented from duckdb::Expression.

377043 {
377044 Expression::Serialize(serializer);
377045 serializer.WriteProperty(200, "return_type", return_type);
377046 serializer.WriteProperty(201, "children", children);
377047 if (type == ExpressionType::WINDOW_AGGREGATE) {
377048 D_ASSERT(aggregate);
377049 FunctionSerializer::Serialize(serializer, *aggregate, bind_info.get());
377050 }
377051 serializer.WriteProperty(202, "partitions", partitions);
377052 serializer.WriteProperty(203, "orders", orders);
377053 serializer.WritePropertyWithDefault(204, "filters", filter_expr, unique_ptr<Expression>());
377054 serializer.WriteProperty(205, "ignore_nulls", ignore_nulls);
377055 serializer.WriteProperty(206, "start", start);
377056 serializer.WriteProperty(207, "end", end);
377057 serializer.WritePropertyWithDefault(208, "start_expr", start_expr, unique_ptr<Expression>());
377058 serializer.WritePropertyWithDefault(209, "end_expr", end_expr, unique_ptr<Expression>());
377059 serializer.WritePropertyWithDefault(210, "offset_expr", offset_expr, unique_ptr<Expression>());
377060 serializer.WritePropertyWithDefault(211, "default_expr", default_expr, unique_ptr<Expression>());
377061 serializer.WriteProperty(212, "exclude_clause", exclude_clause);
377062 serializer.WriteProperty(213, "distinct", distinct);
377063 serializer.WriteProperty(214, "arg_orders", arg_orders);
377064}

◆ Deserialize()

unique_ptr< Expression > duckdb::BoundWindowExpression::Deserialize ( Deserializer & deserializer)
static
377066 {
377067 auto expression_type = deserializer.Get<ExpressionType>();
377068 auto return_type = deserializer.ReadProperty<LogicalType>(200, "return_type");
377069 auto children = deserializer.ReadProperty<vector<unique_ptr<Expression>>>(201, "children");
377070 unique_ptr<AggregateFunction> aggregate;
377071 unique_ptr<FunctionData> bind_info;
377072 if (expression_type == ExpressionType::WINDOW_AGGREGATE) {
377073 auto entry = FunctionSerializer::Deserialize<AggregateFunction, AggregateFunctionCatalogEntry>(
377074 deserializer, CatalogType::AGGREGATE_FUNCTION_ENTRY, children, return_type);
377075 aggregate = make_uniq<AggregateFunction>(std::move(entry.first));
377076 bind_info = std::move(entry.second);
377077 }
377078 auto result =
377079 make_uniq<BoundWindowExpression>(expression_type, return_type, std::move(aggregate), std::move(bind_info));
377080 result->children = std::move(children);
377081 deserializer.ReadProperty(202, "partitions", result->partitions);
377082 deserializer.ReadProperty(203, "orders", result->orders);
377083 deserializer.ReadPropertyWithExplicitDefault(204, "filters", result->filter_expr, unique_ptr<Expression>());
377084 deserializer.ReadProperty(205, "ignore_nulls", result->ignore_nulls);
377085 deserializer.ReadProperty(206, "start", result->start);
377086 deserializer.ReadProperty(207, "end", result->end);
377087 deserializer.ReadPropertyWithExplicitDefault(208, "start_expr", result->start_expr, unique_ptr<Expression>());
377088 deserializer.ReadPropertyWithExplicitDefault(209, "end_expr", result->end_expr, unique_ptr<Expression>());
377089 deserializer.ReadPropertyWithExplicitDefault(210, "offset_expr", result->offset_expr, unique_ptr<Expression>());
377090 deserializer.ReadPropertyWithExplicitDefault(211, "default_expr", result->default_expr, unique_ptr<Expression>());
377091 deserializer.ReadProperty(212, "exclude_clause", result->exclude_clause);
377092 deserializer.ReadProperty(213, "distinct", result->distinct);
377093 deserializer.ReadPropertyWithExplicitDefault(214, "arg_orders", result->arg_orders, vector<BoundOrderByNode>());
377094 return std::move(result);
377095}

Member Data Documentation

◆ arg_orders

vector<BoundOrderByNode> duckdb::BoundWindowExpression::arg_orders

The set of argument ordering clauses These are distinct from the frame ordering clauses e.g., the "x" in FIRST_VALUE(a ORDER BY x) OVER (PARTITION BY p ORDER BY s)


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