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

Public Member Functions

 WindowExpression (ExpressionType type, string catalog_name, string schema_name, const string &function_name)
bool IsWindow () const override
 Returns true if the expression has a window function or not.
string ToString () const override
 Convert the Expression to a String.
bool HasBoundedParts ()
unique_ptr< ParsedExpression > Copy () const override
 Create a copy of this expression.
void Serialize (Serializer &serializer) const override
Public Member Functions inherited from duckdb::ParsedExpression
 ParsedExpression (ExpressionType type, ExpressionClass expression_class)
 Create an Expression.
bool IsAggregate () const override
 Returns true if this expression is an aggregate 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.
bool Equals (const BaseExpression &other) const override
 Returns true if this expression is equal to another expression.
hash_t Hash () const override
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 bool Equal (const WindowExpression &a, const WindowExpression &b)
static unique_ptr< ParsedExpression > Deserialize (Deserializer &deserializer)
static const WindowFunctionDefinition * WindowFunctions ()
static ExpressionType WindowToExpressionType (string &fun_name)
static string ToUnits (const WindowBoundary boundary, const WindowBoundary rows, const WindowBoundary range, const WindowBoundary groups)
template<class T, class BASE, class ORDER_NODE>
static string ToString (const T &entry, const string &schema, const string &function_name)
Static Public Member Functions inherited from duckdb::ParsedExpression
static unique_ptr< ParsedExpression > Deserialize (Deserializer &deserializer)
static bool Equals (const unique_ptr< ParsedExpression > &left, const unique_ptr< ParsedExpression > &right)
static bool ListEquals (const vector< unique_ptr< ParsedExpression > > &left, const vector< unique_ptr< ParsedExpression > > &right)
Static Public Member Functions inherited from duckdb::BaseExpression
static bool Equals (const BaseExpression &left, const BaseExpression &right)

Public Attributes

string catalog
 Catalog of the aggregate function.
string schema
 Schema of the aggregate function.
string function_name
 Name of the aggregate function.
vector< unique_ptr< ParsedExpression > > children
 The child expression of the main window function.
vector< unique_ptr< ParsedExpression > > partitions
 The set of expressions to partition by.
vector< OrderByNode > orders
 The set of ordering clauses.
unique_ptr< ParsedExpression > filter_expr
 Expression representing a filter, only used for aggregates.
bool ignore_nulls = false
 True to ignore NULL values.
bool distinct = false
 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< ParsedExpression > start_expr
unique_ptr< ParsedExpression > end_expr
unique_ptr< ParsedExpression > offset_expr
 Offset and default expressions for WINDOW_LEAD and WINDOW_LAG functions.
unique_ptr< ParsedExpression > default_expr
vector< OrderByNode > arg_orders
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::WINDOW

Private Member Functions

 WindowExpression (ExpressionType type)

Additional Inherited Members

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

Detailed Description

The WindowExpression represents a window function in the query. They are a special case of aggregates which is why they inherit from them.

Constructor & Destructor Documentation

◆ WindowExpression() [1/2]

duckdb::WindowExpression::WindowExpression ( ExpressionType type,
string catalog_name,
string schema_name,
const string & function_name )
337729 : ParsedExpression(type, ExpressionClass::WINDOW), catalog(std::move(catalog_name)), schema(std::move(schema)),
337731 switch (type) {
337732 case ExpressionType::WINDOW_AGGREGATE:
337733 case ExpressionType::WINDOW_ROW_NUMBER:
337734 case ExpressionType::WINDOW_FIRST_VALUE:
337735 case ExpressionType::WINDOW_LAST_VALUE:
337736 case ExpressionType::WINDOW_NTH_VALUE:
337737 case ExpressionType::WINDOW_RANK:
337738 case ExpressionType::WINDOW_RANK_DENSE:
337739 case ExpressionType::WINDOW_PERCENT_RANK:
337740 case ExpressionType::WINDOW_CUME_DIST:
337741 case ExpressionType::WINDOW_LEAD:
337742 case ExpressionType::WINDOW_LAG:
337743 case ExpressionType::WINDOW_NTILE:
337744 case ExpressionType::WINDOW_FILL:
337745 break;
337746 default:
337747 throw NotImplementedException("Window aggregate type %s not supported", ExpressionTypeToString(type).c_str());
337748 }
337749}
ExpressionType type
Type of the expression.
Definition duckdb.hpp:13287
ParsedExpression(ExpressionType type, ExpressionClass expression_class)
Create an Expression.
Definition duckdb.hpp:13557
static DUCKDB_API string Lower(const string &str)
Convert a string to lowercase.
Definition duckdb.cpp:109630
string function_name
Name of the aggregate function.
Definition duckdb.cpp:60855
string schema
Schema of the aggregate function.
Definition duckdb.cpp:60853
string catalog
Catalog of the aggregate function.
Definition duckdb.cpp:60851
bool ignore_nulls
True to ignore NULL values.
Definition duckdb.cpp:60865
bool distinct
Whether or not the aggregate function is distinct, only used for aggregates.
Definition duckdb.cpp:60867

◆ WindowExpression() [2/2]

duckdb::WindowExpression::WindowExpression ( ExpressionType type)
explicitprivate
337725 : ParsedExpression(type, ExpressionClass::WINDOW) {
337726}

Member Function Documentation

◆ IsWindow()

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

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

Reimplemented from duckdb::ParsedExpression.

60886 {
60887 return true;
60888 }

◆ ToString() [1/2]

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

Convert the Expression to a String.

Implements duckdb::BaseExpression.

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

◆ Equal()

bool duckdb::WindowExpression::Equal ( const WindowExpression & a,
const WindowExpression & b )
static
337788 {
337789 // check if the child expressions are equivalent
337790 if (a.ignore_nulls != b.ignore_nulls) {
337791 return false;
337792 }
337793 if (a.distinct != b.distinct) {
337794 return false;
337795 }
337796 if (!ParsedExpression::ListEquals(a.children, b.children)) {
337797 return false;
337798 }
337799 if (a.start != b.start || a.end != b.end) {
337800 return false;
337801 }
337802 if (a.exclude_clause != b.exclude_clause) {
337803 return false;
337804 }
337805 // check if the framing expressions are equivalent
337806 if (!ParsedExpression::Equals(a.start_expr, b.start_expr) || !ParsedExpression::Equals(a.end_expr, b.end_expr) ||
337807 !ParsedExpression::Equals(a.offset_expr, b.offset_expr) ||
337808 !ParsedExpression::Equals(a.default_expr, b.default_expr)) {
337809 return false;
337810 }
337811
337812 // check if the argument orderings are equivalent
337813 if (a.arg_orders.size() != b.arg_orders.size()) {
337814 return false;
337815 }
337816 for (idx_t i = 0; i < a.arg_orders.size(); i++) {
337817 if (a.arg_orders[i].type != b.arg_orders[i].type) {
337818 return false;
337819 }
337820 if (a.arg_orders[i].null_order != b.arg_orders[i].null_order) {
337821 return false;
337822 }
337823 if (!a.arg_orders[i].expression->Equals(*b.arg_orders[i].expression)) {
337824 return false;
337825 }
337826 }
337827
337828 // check if the partitions are equivalent
337829 if (!ParsedExpression::ListEquals(a.partitions, b.partitions)) {
337830 return false;
337831 }
337832 // check if the orderings are equivalent
337833 if (a.orders.size() != b.orders.size()) {
337834 return false;
337835 }
337836 for (idx_t i = 0; i < a.orders.size(); i++) {
337837 if (a.orders[i].type != b.orders[i].type) {
337838 return false;
337839 }
337840 if (a.orders[i].null_order != b.orders[i].null_order) {
337841 return false;
337842 }
337843 if (!a.orders[i].expression->Equals(*b.orders[i].expression)) {
337844 return false;
337845 }
337846 }
337847 // check if the filter clauses are equivalent
337848 if (!ParsedExpression::Equals(a.filter_expr, b.filter_expr)) {
337849 return false;
337850 }
337851
337852 return true;
337853}
bool Equals(const BaseExpression &other) const override
Returns true if this expression is equal to another expression.
Definition duckdb.cpp:340462
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ HasBoundedParts()

bool duckdb::WindowExpression::HasBoundedParts ( )
337855 {
337856 for (auto &child : children) {
337857 if ((*child).GetExpressionClass() == ExpressionClass::BOUND_EXPRESSION) {
337858 return true;
337859 }
337860 }
337861 for (auto &partition : partitions) {
337862 if ((*partition).GetExpressionClass() == ExpressionClass::BOUND_EXPRESSION) {
337863 return true;
337864 }
337865 }
337866
337867 for (auto &o : orders) {
337868 if ((*o.expression).GetExpressionClass() == ExpressionClass::BOUND_EXPRESSION) {
337869 return true;
337870 }
337871 }
337872
337873 for (auto &o : arg_orders) {
337874 if ((*o.expression).GetExpressionClass() == ExpressionClass::BOUND_EXPRESSION) {
337875 return true;
337876 }
337877 }
337878 return false;
337879}
vector< OrderByNode > orders
The set of ordering clauses.
Definition duckdb.cpp:60861
vector< OrderByNode > arg_orders
Definition duckdb.cpp:60883
vector< unique_ptr< ParsedExpression > > children
The child expression of the main window function.
Definition duckdb.cpp:60857
vector< unique_ptr< ParsedExpression > > partitions
The set of expressions to partition by.
Definition duckdb.cpp:60859

◆ Copy()

unique_ptr< ParsedExpression > duckdb::WindowExpression::Copy ( ) const
overridevirtual

Create a copy of this expression.

Implements duckdb::ParsedExpression.

337881 {
337882 auto new_window = make_uniq<WindowExpression>(type, catalog, schema, function_name);
337883 new_window->CopyProperties(*this);
337884
337885 for (auto &child : children) {
337886 new_window->children.push_back(child->Copy());
337887 }
337888
337889 for (auto &e : partitions) {
337890 new_window->partitions.push_back(e->Copy());
337891 }
337892
337893 for (auto &o : orders) {
337894 new_window->orders.emplace_back(o.type, o.null_order, o.expression->Copy());
337895 }
337896
337897 for (auto &o : arg_orders) {
337898 new_window->arg_orders.emplace_back(o.type, o.null_order, o.expression->Copy());
337899 }
337900
337901 new_window->filter_expr = filter_expr ? filter_expr->Copy() : nullptr;
337902
337903 new_window->start = start;
337904 new_window->end = end;
337905 new_window->exclude_clause = exclude_clause;
337906 new_window->start_expr = start_expr ? start_expr->Copy() : nullptr;
337907 new_window->end_expr = end_expr ? end_expr->Copy() : nullptr;
337908 new_window->offset_expr = offset_expr ? offset_expr->Copy() : nullptr;
337909 new_window->default_expr = default_expr ? default_expr->Copy() : nullptr;
337910 new_window->ignore_nulls = ignore_nulls;
337911 new_window->distinct = distinct;
337912
337913 return std::move(new_window);
337914}
unique_ptr< ParsedExpression > filter_expr
Expression representing a filter, only used for aggregates.
Definition duckdb.cpp:60863
unique_ptr< ParsedExpression > offset_expr
Offset and default expressions for WINDOW_LEAD and WINDOW_LAG functions.
Definition duckdb.cpp:60877
WindowExcludeMode exclude_clause
The EXCLUDE clause.
Definition duckdb.cpp:60872
WindowBoundary start
The window boundaries.
Definition duckdb.cpp:60869
Here is the caller graph for this function:

◆ Serialize()

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

Reimplemented from duckdb::ParsedExpression.

418986 {
418987 ParsedExpression::Serialize(serializer);
418988 serializer.WritePropertyWithDefault<string>(200, "function_name", function_name);
418989 serializer.WritePropertyWithDefault<string>(201, "schema", schema);
418990 serializer.WritePropertyWithDefault<string>(202, "catalog", catalog);
418991 serializer.WritePropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(203, "children", children);
418992 serializer.WritePropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(204, "partitions", partitions);
418993 serializer.WritePropertyWithDefault<vector<OrderByNode>>(205, "orders", orders);
418994 serializer.WriteProperty<WindowBoundary>(206, "start", start);
418995 serializer.WriteProperty<WindowBoundary>(207, "end", end);
418996 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(208, "start_expr", start_expr);
418997 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(209, "end_expr", end_expr);
418998 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(210, "offset_expr", offset_expr);
418999 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(211, "default_expr", default_expr);
419000 serializer.WritePropertyWithDefault<bool>(212, "ignore_nulls", ignore_nulls);
419001 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(213, "filter_expr", filter_expr);
419002 serializer.WritePropertyWithDefault<WindowExcludeMode>(214, "exclude_clause", exclude_clause, WindowExcludeMode::NO_OTHER);
419003 serializer.WritePropertyWithDefault<bool>(215, "distinct", distinct);
419004 serializer.WritePropertyWithDefault<vector<OrderByNode>>(216, "arg_orders", arg_orders);
419005}
WindowExcludeMode
Represents the window exclusion mode.
Definition duckdb.cpp:60837

◆ Deserialize()

unique_ptr< ParsedExpression > duckdb::WindowExpression::Deserialize ( Deserializer & deserializer)
static
419007 {
419008 auto result = duckdb::unique_ptr<WindowExpression>(new WindowExpression(deserializer.Get<ExpressionType>()));
419009 deserializer.ReadPropertyWithDefault<string>(200, "function_name", result->function_name);
419010 deserializer.ReadPropertyWithDefault<string>(201, "schema", result->schema);
419011 deserializer.ReadPropertyWithDefault<string>(202, "catalog", result->catalog);
419012 deserializer.ReadPropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(203, "children", result->children);
419013 deserializer.ReadPropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(204, "partitions", result->partitions);
419014 deserializer.ReadPropertyWithDefault<vector<OrderByNode>>(205, "orders", result->orders);
419015 deserializer.ReadProperty<WindowBoundary>(206, "start", result->start);
419016 deserializer.ReadProperty<WindowBoundary>(207, "end", result->end);
419017 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(208, "start_expr", result->start_expr);
419018 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(209, "end_expr", result->end_expr);
419019 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(210, "offset_expr", result->offset_expr);
419020 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(211, "default_expr", result->default_expr);
419021 deserializer.ReadPropertyWithDefault<bool>(212, "ignore_nulls", result->ignore_nulls);
419022 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(213, "filter_expr", result->filter_expr);
419023 deserializer.ReadPropertyWithExplicitDefault<WindowExcludeMode>(214, "exclude_clause", result->exclude_clause, WindowExcludeMode::NO_OTHER);
419024 deserializer.ReadPropertyWithDefault<bool>(215, "distinct", result->distinct);
419025 deserializer.ReadPropertyWithDefault<vector<OrderByNode>>(216, "arg_orders", result->arg_orders);
419026 return std::move(result);
419027}

◆ WindowFunctions()

const WindowFunctionDefinition * duckdb::WindowExpression::WindowFunctions ( )
static
337769 {
337770 return internal_window_functions;
337771}

◆ WindowToExpressionType()

ExpressionType duckdb::WindowExpression::WindowToExpressionType ( string & fun_name)
static
337773 {
337774 D_ASSERT(StringUtil::IsLower(fun_name));
337775 auto functions = WindowFunctions();
337776 for (idx_t i = 0; functions[i].name != nullptr; i++) {
337777 if (fun_name == functions[i].name) {
337778 return functions[i].expression_type;
337779 }
337780 }
337781 return ExpressionType::WINDOW_AGGREGATE;
337782}

◆ ToUnits()

string duckdb::WindowExpression::ToUnits ( const WindowBoundary boundary,
const WindowBoundary rows,
const WindowBoundary range,
const WindowBoundary groups )
inlinestatic
60907 {
60908 if (boundary == rows) {
60909 return "ROWS";
60910 } else if (boundary == range) {
60911 return "RANGE";
60912 } else {
60913 return "GROUPS";
60914 }
60915 }
int rows

◆ ToString() [2/2]

template<class T, class BASE, class ORDER_NODE>
string duckdb::WindowExpression::ToString ( const T & entry,
const string & schema,
const string & function_name )
inlinestatic
60918 {
60919 // Start with function call
60920 string result = schema.empty() ? function_name : schema + "." + function_name;
60921 result += "(";
60922 if (entry.children.size()) {
60923 // Only one DISTINCT is allowed (on the first argument)
60924 int distincts = entry.distinct ? 0 : 1;
60925 result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
60926 return (distincts++ ? "" : "DISTINCT ") + child->ToString();
60927 });
60928 }
60929 // Lead/Lag extra arguments
60930 if (entry.offset_expr.get()) {
60931 result += ", ";
60932 result += entry.offset_expr->ToString();
60933 }
60934 if (entry.default_expr.get()) {
60935 result += ", ";
60936 result += entry.default_expr->ToString();
60937 }
60938 // ORDER BY arguments
60939 if (!entry.arg_orders.empty()) {
60940 result += " ORDER BY ";
60941 result += StringUtil::Join(entry.arg_orders, entry.arg_orders.size(), ", ",
60942 [](const ORDER_NODE &order) { return order.ToString(); });
60943 }
60944
60945 // IGNORE NULLS
60946 if (entry.ignore_nulls) {
60947 result += " IGNORE NULLS";
60948 }
60949 // FILTER
60950 if (entry.filter_expr) {
60951 result += ") FILTER (WHERE " + entry.filter_expr->ToString();
60952 }
60953
60954 // Over clause
60955 result += ") OVER (";
60956 string sep;
60957
60958 // Partitions
60959 if (!entry.partitions.empty()) {
60960 result += "PARTITION BY ";
60961 result += StringUtil::Join(entry.partitions, entry.partitions.size(), ", ",
60962 [](const unique_ptr<BASE> &partition) { return partition->ToString(); });
60963 sep = " ";
60964 }
60965
60966 // Orders
60967 if (!entry.orders.empty()) {
60968 result += sep;
60969 result += "ORDER BY ";
60970 result += StringUtil::Join(entry.orders, entry.orders.size(), ", ",
60971 [](const ORDER_NODE &order) { return order.ToString(); });
60972 sep = " ";
60973 }
60974
60975 // Rows/Range
60976 string units = "ROWS";
60977 string from;
60978 switch (entry.start) {
60979 case WindowBoundary::CURRENT_ROW_RANGE:
60980 case WindowBoundary::CURRENT_ROW_ROWS:
60981 case WindowBoundary::CURRENT_ROW_GROUPS:
60982 from = "CURRENT ROW";
60983 units = ToUnits(entry.start, WindowBoundary::CURRENT_ROW_ROWS, WindowBoundary::CURRENT_ROW_RANGE,
60984 WindowBoundary::CURRENT_ROW_GROUPS);
60985 break;
60986 case WindowBoundary::UNBOUNDED_PRECEDING:
60987 if (entry.end != WindowBoundary::CURRENT_ROW_RANGE) {
60988 from = "UNBOUNDED PRECEDING";
60989 }
60990 break;
60991 case WindowBoundary::EXPR_PRECEDING_ROWS:
60992 case WindowBoundary::EXPR_PRECEDING_RANGE:
60993 case WindowBoundary::EXPR_PRECEDING_GROUPS:
60994 from = entry.start_expr->ToString() + " PRECEDING";
60995 units = ToUnits(entry.start, WindowBoundary::EXPR_PRECEDING_ROWS, WindowBoundary::EXPR_PRECEDING_RANGE,
60996 WindowBoundary::EXPR_PRECEDING_GROUPS);
60997 break;
60998 case WindowBoundary::EXPR_FOLLOWING_ROWS:
60999 case WindowBoundary::EXPR_FOLLOWING_RANGE:
61000 case WindowBoundary::EXPR_FOLLOWING_GROUPS:
61001 from = entry.start_expr->ToString() + " FOLLOWING";
61002 units = ToUnits(entry.start, WindowBoundary::EXPR_FOLLOWING_ROWS, WindowBoundary::EXPR_FOLLOWING_RANGE,
61003 WindowBoundary::EXPR_FOLLOWING_GROUPS);
61004 break;
61005 case WindowBoundary::UNBOUNDED_FOLLOWING:
61006 case WindowBoundary::INVALID:
61007 throw InternalException("Unrecognized FROM in WindowExpression");
61008 }
61009
61010 string to;
61011 switch (entry.end) {
61012 case WindowBoundary::CURRENT_ROW_RANGE:
61013 if (entry.start != WindowBoundary::UNBOUNDED_PRECEDING) {
61014 to = "CURRENT ROW";
61015 units = "RANGE";
61016 }
61017 break;
61018 case WindowBoundary::CURRENT_ROW_ROWS:
61019 case WindowBoundary::CURRENT_ROW_GROUPS:
61020 to = "CURRENT ROW";
61021 units = ToUnits(entry.end, WindowBoundary::CURRENT_ROW_ROWS, WindowBoundary::CURRENT_ROW_RANGE,
61022 WindowBoundary::CURRENT_ROW_GROUPS);
61023 break;
61024 case WindowBoundary::UNBOUNDED_PRECEDING:
61025 to = "UNBOUNDED PRECEDING";
61026 break;
61027 case WindowBoundary::UNBOUNDED_FOLLOWING:
61028 to = "UNBOUNDED FOLLOWING";
61029 break;
61030 case WindowBoundary::EXPR_PRECEDING_ROWS:
61031 case WindowBoundary::EXPR_PRECEDING_RANGE:
61032 case WindowBoundary::EXPR_PRECEDING_GROUPS:
61033 to = entry.end_expr->ToString() + " PRECEDING";
61034 units = ToUnits(entry.end, WindowBoundary::EXPR_PRECEDING_ROWS, WindowBoundary::EXPR_PRECEDING_RANGE,
61035 WindowBoundary::EXPR_PRECEDING_GROUPS);
61036 break;
61037 case WindowBoundary::EXPR_FOLLOWING_ROWS:
61038 case WindowBoundary::EXPR_FOLLOWING_RANGE:
61039 case WindowBoundary::EXPR_FOLLOWING_GROUPS:
61040 to = entry.end_expr->ToString() + " FOLLOWING";
61041 units = ToUnits(entry.end, WindowBoundary::EXPR_FOLLOWING_ROWS, WindowBoundary::EXPR_FOLLOWING_RANGE,
61042 WindowBoundary::EXPR_FOLLOWING_GROUPS);
61043 break;
61044 case WindowBoundary::INVALID:
61045 throw InternalException("Unrecognized TO in WindowExpression");
61046 }
61047 if (entry.exclude_clause != WindowExcludeMode::NO_OTHER) {
61048 // if we have an explicit EXCLUDE we always need to fill in from/to
61049 if (from.empty()) {
61050 from = "UNBOUNDED PRECEDING";
61051 }
61052 if (to.empty()) {
61053 to = "CURRENT ROW";
61054 units = "RANGE";
61055 }
61056 }
61057
61058 if (!from.empty() || !to.empty()) {
61059 result += sep + units;
61060 }
61061 if (!from.empty() && !to.empty()) {
61062 result += " BETWEEN ";
61063 result += from;
61064 result += " AND ";
61065 result += to;
61066 } else if (!from.empty()) {
61067 result += " ";
61068 result += from;
61069 } else if (!to.empty()) {
61070 result += " ";
61071 result += to;
61072 }
61073
61074 if (entry.exclude_clause != WindowExcludeMode::NO_OTHER) {
61075 result += " EXCLUDE ";
61076 }
61077 switch (entry.exclude_clause) {
61078 case WindowExcludeMode::CURRENT_ROW:
61079 result += "CURRENT ROW";
61080 break;
61081 case WindowExcludeMode::GROUP:
61082 result += "GROUP";
61083 break;
61084 case WindowExcludeMode::TIES:
61085 result += "TIES";
61086 break;
61087 default:
61088 break;
61089 }
61090
61091 result += ")";
61092
61093 return result;
61094 }
static DUCKDB_API string Join(const vector< string > &input, const string &separator)
Join multiple strings into one string. Components are concatenated by the given separator.
Definition duckdb.cpp:109497

Member Data Documentation

◆ arg_orders

vector<OrderByNode> duckdb::WindowExpression::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: