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::ParsedExpressionIterator Class Reference

Static Public Member Functions

static void EnumerateChildren (const ParsedExpression &expression, const std::function< void(const ParsedExpression &child)> &callback)
static void EnumerateChildren (ParsedExpression &expr, const std::function< void(ParsedExpression &child)> &callback)
static void EnumerateChildren (ParsedExpression &expr, const std::function< void(unique_ptr< ParsedExpression > &child)> &callback)
static void EnumerateTableRefChildren (TableRef &ref, const std::function< void(unique_ptr< ParsedExpression > &child)> &expr_callback, const std::function< void(TableRef &ref)> &ref_callback=DefaultRefCallback)
static void EnumerateQueryNodeChildren (QueryNode &node, const std::function< void(unique_ptr< ParsedExpression > &child)> &expr_callback, const std::function< void(TableRef &ref)> &ref_callback=DefaultRefCallback)
static void EnumerateQueryNodeModifiers (QueryNode &node, const std::function< void(unique_ptr< ParsedExpression > &child)> &expr_callback)
static void VisitExpressionClass (const ParsedExpression &expr, ExpressionClass expr_class, const std::function< void(const ParsedExpression &child)> &callback)
static void VisitExpressionClassMutable (ParsedExpression &expr, ExpressionClass expr_class, const std::function< void(ParsedExpression &child)> &callback)
template<class T>
static void VisitExpressionMutable (ParsedExpression &expr, const std::function< void(T &child)> &callback)
template<class T>
static void VisitExpression (const ParsedExpression &expr, const std::function< void(const T &child)> &callback)

Static Private Member Functions

static void DefaultRefCallback (TableRef &ref)

Member Function Documentation

◆ EnumerateChildren() [1/3]

void duckdb::ParsedExpressionIterator::EnumerateChildren ( const ParsedExpression & expression,
const std::function< void(const ParsedExpression &child)> & callback )
static
340675 {
340676 EnumerateChildren((ParsedExpression &)expression, [&](unique_ptr<ParsedExpression> &child) {
340677 D_ASSERT(child);
340678 callback(*child);
340679 });
340680}

◆ EnumerateChildren() [2/3]

void duckdb::ParsedExpressionIterator::EnumerateChildren ( ParsedExpression & expr,
const std::function< void(ParsedExpression &child)> & callback )
static
340683 {
340684 EnumerateChildren(expr, [&](unique_ptr<ParsedExpression> &child) {
340685 D_ASSERT(child);
340686 callback(*child);
340687 });
340688}

◆ EnumerateChildren() [3/3]

void duckdb::ParsedExpressionIterator::EnumerateChildren ( ParsedExpression & expr,
const std::function< void(unique_ptr< ParsedExpression > &child)> & callback )
static
340691 {
340692 switch (expr.GetExpressionClass()) {
340693 case ExpressionClass::BETWEEN: {
340694 auto &cast_expr = expr.Cast<BetweenExpression>();
340695 callback(cast_expr.input);
340696 callback(cast_expr.lower);
340697 callback(cast_expr.upper);
340698 break;
340699 }
340700 case ExpressionClass::CASE: {
340701 auto &case_expr = expr.Cast<CaseExpression>();
340702 for (auto &check : case_expr.case_checks) {
340703 callback(check.when_expr);
340704 callback(check.then_expr);
340705 }
340706 callback(case_expr.else_expr);
340707 break;
340708 }
340709 case ExpressionClass::CAST: {
340710 auto &cast_expr = expr.Cast<CastExpression>();
340711 callback(cast_expr.child);
340712 break;
340713 }
340714 case ExpressionClass::COLLATE: {
340715 auto &cast_expr = expr.Cast<CollateExpression>();
340716 callback(cast_expr.child);
340717 break;
340718 }
340719 case ExpressionClass::COMPARISON: {
340720 auto &comp_expr = expr.Cast<ComparisonExpression>();
340721 callback(comp_expr.left);
340722 callback(comp_expr.right);
340723 break;
340724 }
340725 case ExpressionClass::CONJUNCTION: {
340726 auto &conj_expr = expr.Cast<ConjunctionExpression>();
340727 for (auto &child : conj_expr.children) {
340728 callback(child);
340729 }
340730 break;
340731 }
340732
340733 case ExpressionClass::FUNCTION: {
340734 auto &func_expr = expr.Cast<FunctionExpression>();
340735 for (auto &child : func_expr.children) {
340736 callback(child);
340737 }
340738 if (func_expr.filter) {
340739 callback(func_expr.filter);
340740 }
340741 if (func_expr.order_bys) {
340742 for (auto &order : func_expr.order_bys->orders) {
340743 callback(order.expression);
340744 }
340745 }
340746 break;
340747 }
340748 case ExpressionClass::TYPE: {
340749 auto &type_expr = expr.Cast<TypeExpression>();
340750 for (auto &child : type_expr.GetChildren()) {
340751 callback(child);
340752 }
340753 break;
340754 }
340755 case ExpressionClass::LAMBDA: {
340756 auto &lambda_expr = expr.Cast<LambdaExpression>();
340757 callback(lambda_expr.lhs);
340758 callback(lambda_expr.expr);
340759 break;
340760 }
340761 case ExpressionClass::OPERATOR: {
340762 auto &op_expr = expr.Cast<OperatorExpression>();
340763 for (auto &child : op_expr.children) {
340764 callback(child);
340765 }
340766 break;
340767 }
340768 case ExpressionClass::STAR: {
340769 auto &star_expr = expr.Cast<StarExpression>();
340770 if (star_expr.expr) {
340771 callback(star_expr.expr);
340772 }
340773 for (auto &item : star_expr.replace_list) {
340774 callback(item.second);
340775 }
340776 break;
340777 }
340778 case ExpressionClass::SUBQUERY: {
340779 auto &subquery_expr = expr.Cast<SubqueryExpression>();
340780 if (subquery_expr.child) {
340781 callback(subquery_expr.child);
340782 }
340783 break;
340784 }
340785 case ExpressionClass::WINDOW: {
340786 auto &window_expr = expr.Cast<WindowExpression>();
340787 for (auto &partition : window_expr.partitions) {
340788 callback(partition);
340789 }
340790 for (auto &order : window_expr.orders) {
340791 callback(order.expression);
340792 }
340793 for (auto &child : window_expr.children) {
340794 callback(child);
340795 }
340796 if (window_expr.filter_expr) {
340797 callback(window_expr.filter_expr);
340798 }
340799 if (window_expr.start_expr) {
340800 callback(window_expr.start_expr);
340801 }
340802 if (window_expr.end_expr) {
340803 callback(window_expr.end_expr);
340804 }
340805 if (window_expr.offset_expr) {
340806 callback(window_expr.offset_expr);
340807 }
340808 if (window_expr.default_expr) {
340809 callback(window_expr.default_expr);
340810 }
340811 for (auto &order : window_expr.arg_orders) {
340812 callback(order.expression);
340813 }
340814 break;
340815 }
340816 case ExpressionClass::BOUND_EXPRESSION:
340817 case ExpressionClass::COLUMN_REF:
340818 case ExpressionClass::LAMBDA_REF:
340819 case ExpressionClass::CONSTANT:
340820 case ExpressionClass::DEFAULT:
340821 case ExpressionClass::PARAMETER:
340822 case ExpressionClass::POSITIONAL_REFERENCE:
340823 // these node types have no children
340824 break;
340825 default:
340826 // called on non ParsedExpression type!
340827 throw NotImplementedException("Unimplemented expression class");
340828 }
340829}

◆ EnumerateTableRefChildren()

void duckdb::ParsedExpressionIterator::EnumerateTableRefChildren ( TableRef & ref,
const std::function< void(unique_ptr< ParsedExpression > &child)> & expr_callback,
const std::function< void(TableRef &ref)> & ref_callback = DefaultRefCallback )
static
340878 {
340879 switch (ref.type) {
340880 case TableReferenceType::EXPRESSION_LIST: {
340881 auto &el_ref = ref.Cast<ExpressionListRef>();
340882 for (idx_t i = 0; i < el_ref.values.size(); i++) {
340883 for (idx_t j = 0; j < el_ref.values[i].size(); j++) {
340884 expr_callback(el_ref.values[i][j]);
340885 }
340886 }
340887 break;
340888 }
340889 case TableReferenceType::JOIN: {
340890 auto &j_ref = ref.Cast<JoinRef>();
340891 EnumerateTableRefChildren(*j_ref.left, expr_callback, ref_callback);
340892 EnumerateTableRefChildren(*j_ref.right, expr_callback, ref_callback);
340893 if (j_ref.condition) {
340894 expr_callback(j_ref.condition);
340895 }
340896 break;
340897 }
340898 case TableReferenceType::PIVOT: {
340899 auto &p_ref = ref.Cast<PivotRef>();
340900 EnumerateTableRefChildren(*p_ref.source, expr_callback, ref_callback);
340901 for (auto &aggr : p_ref.aggregates) {
340902 expr_callback(aggr);
340903 }
340904 break;
340905 }
340906 case TableReferenceType::SUBQUERY: {
340907 auto &sq_ref = ref.Cast<SubqueryRef>();
340908 EnumerateQueryNodeChildren(*sq_ref.subquery->node, expr_callback, ref_callback);
340909 break;
340910 }
340911 case TableReferenceType::TABLE_FUNCTION: {
340912 auto &tf_ref = ref.Cast<TableFunctionRef>();
340913 expr_callback(tf_ref.function);
340914 break;
340915 }
340916 case TableReferenceType::BASE_TABLE:
340917 case TableReferenceType::EMPTY_FROM:
340918 case TableReferenceType::SHOW_REF:
340919 case TableReferenceType::COLUMN_DATA:
340920 case TableReferenceType::DELIM_GET:
340921 // these TableRefs do not need to be unfolded
340922 break;
340923 case TableReferenceType::INVALID:
340924 case TableReferenceType::CTE:
340925 case TableReferenceType::BOUND_TABLE_REF:
340926 throw NotImplementedException("TableRef type not implemented for traversal");
340927 }
340928 ref_callback(ref);
340929}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ EnumerateQueryNodeChildren()

void duckdb::ParsedExpressionIterator::EnumerateQueryNodeChildren ( QueryNode & node,
const std::function< void(unique_ptr< ParsedExpression > &child)> & expr_callback,
const std::function< void(TableRef &ref)> & ref_callback = DefaultRefCallback )
static
340933 {
340934 switch (node.type) {
340935 case QueryNodeType::RECURSIVE_CTE_NODE: {
340936 auto &rcte_node = node.Cast<RecursiveCTENode>();
340937 EnumerateQueryNodeChildren(*rcte_node.left, expr_callback, ref_callback);
340938 EnumerateQueryNodeChildren(*rcte_node.right, expr_callback, ref_callback);
340939 break;
340940 }
340941 case QueryNodeType::SELECT_NODE: {
340942 auto &sel_node = node.Cast<SelectNode>();
340943 for (idx_t i = 0; i < sel_node.select_list.size(); i++) {
340944 expr_callback(sel_node.select_list[i]);
340945 }
340946 for (idx_t i = 0; i < sel_node.groups.group_expressions.size(); i++) {
340947 expr_callback(sel_node.groups.group_expressions[i]);
340948 }
340949 if (sel_node.where_clause) {
340950 expr_callback(sel_node.where_clause);
340951 }
340952 if (sel_node.having) {
340953 expr_callback(sel_node.having);
340954 }
340955 if (sel_node.qualify) {
340956 expr_callback(sel_node.qualify);
340957 }
340958
340959 EnumerateTableRefChildren(*sel_node.from_table.get(), expr_callback, ref_callback);
340960 break;
340961 }
340962 case QueryNodeType::SET_OPERATION_NODE: {
340963 auto &setop_node = node.Cast<SetOperationNode>();
340964 for (auto &child : setop_node.children) {
340965 EnumerateQueryNodeChildren(*child, expr_callback, ref_callback);
340966 }
340967 break;
340968 }
340969 default:
340970 throw NotImplementedException("QueryNode type not implemented for traversal");
340971 }
340972
340973 if (!node.modifiers.empty()) {
340974 EnumerateQueryNodeModifiers(node, expr_callback);
340975 }
340976
340977 for (auto &kv : node.cte_map.map) {
340978 EnumerateQueryNodeChildren(*kv.second->query->node, expr_callback, ref_callback);
340979 }
340980}

◆ EnumerateQueryNodeModifiers()

void duckdb::ParsedExpressionIterator::EnumerateQueryNodeModifiers ( QueryNode & node,
const std::function< void(unique_ptr< ParsedExpression > &child)> & expr_callback )
static
340832 {
340833 for (auto &modifier : node.modifiers) {
340834 switch (modifier->type) {
340835 case ResultModifierType::LIMIT_MODIFIER: {
340836 auto &limit_modifier = modifier->Cast<LimitModifier>();
340837 if (limit_modifier.limit) {
340838 callback(limit_modifier.limit);
340839 }
340840 if (limit_modifier.offset) {
340841 callback(limit_modifier.offset);
340842 }
340843 } break;
340844
340845 case ResultModifierType::LIMIT_PERCENT_MODIFIER: {
340846 auto &limit_modifier = modifier->Cast<LimitPercentModifier>();
340847 if (limit_modifier.limit) {
340848 callback(limit_modifier.limit);
340849 }
340850 if (limit_modifier.offset) {
340851 callback(limit_modifier.offset);
340852 }
340853 } break;
340854
340855 case ResultModifierType::ORDER_MODIFIER: {
340856 auto &order_modifier = modifier->Cast<OrderModifier>();
340857 for (auto &order : order_modifier.orders) {
340858 callback(order.expression);
340859 }
340860 } break;
340861
340862 case ResultModifierType::DISTINCT_MODIFIER: {
340863 auto &distinct_modifier = modifier->Cast<DistinctModifier>();
340864 for (auto &target : distinct_modifier.distinct_on_targets) {
340865 callback(target);
340866 }
340867 } break;
340868
340869 // do nothing
340870 default:
340871 break;
340872 }
340873 }
340874}

◆ VisitExpressionClass()

void duckdb::ParsedExpressionIterator::VisitExpressionClass ( const ParsedExpression & expr,
ExpressionClass expr_class,
const std::function< void(const ParsedExpression &child)> & callback )
static
340984 {
340985 if (expr.GetExpressionClass() == expr_class) {
340986 callback(expr);
340987 return;
340988 }
340989 ParsedExpressionIterator::EnumerateChildren(
340990 expr, [&](const ParsedExpression &child) { VisitExpressionClass(child, expr_class, callback); });
340991}

◆ VisitExpressionClassMutable()

void duckdb::ParsedExpressionIterator::VisitExpressionClassMutable ( ParsedExpression & expr,
ExpressionClass expr_class,
const std::function< void(ParsedExpression &child)> & callback )
static
340994 {
340995 if (expr.GetExpressionClass() == expr_class) {
340996 callback(expr);
340997 return;
340998 }
340999 ParsedExpressionIterator::EnumerateChildren(
341000 expr, [&](ParsedExpression &child) { VisitExpressionClassMutable(child, expr_class, callback); });
341001}

◆ VisitExpressionMutable()

template<class T>
void duckdb::ParsedExpressionIterator::VisitExpressionMutable ( ParsedExpression & expr,
const std::function< void(T &child)> & callback )
inlinestatic
12529 {
12530 VisitExpressionClassMutable(expr, T::TYPE, [&](ParsedExpression &child) { callback(child.Cast<T>()); });
12531 }

◆ VisitExpression()

template<class T>
void duckdb::ParsedExpressionIterator::VisitExpression ( const ParsedExpression & expr,
const std::function< void(const T &child)> & callback )
inlinestatic
12533 {
12534 VisitExpressionClass(expr, T::TYPE, [&](const ParsedExpression &child) { callback(child.Cast<T>()); });
12535 }

◆ DefaultRefCallback()

void duckdb::ParsedExpressionIterator::DefaultRefCallback ( TableRef & ref)
inlinestaticprivate
12538{}; // NOP

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