planner

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package planner converts AQL ASTs to execution plans.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIParams

type APIParams struct {
	// Common parameters
	Query        string     // q parameter for name search
	Page         int        // page number
	PerPage      int        // results per page
	UpdatedSince *time.Time // updated_since filter
	Tag          string     // tag filter

	// Feature-specific parameters
	AssignedToUser string // assigned_to_user filter
	WorkflowStatus string // workflow_status filter (features and ideas)

	// Idea-specific parameters
	CreatedSince  *time.Time // created_since filter
	CreatedBefore *time.Time // created_before filter
	UserID        string     // user_id filter
	Spam          *bool      // spam filter
	Sort          string     // sort order (recent, trending, popular)

	// Context parameters (required for some endpoints)
	ProductID string // required for product-scoped queries
	ReleaseID string // required for release-scoped queries
}

APIParams represents parameters that can be pushed to the Aha API.

func (*APIParams) HasAPIFilters

func (p *APIParams) HasAPIFilters() bool

HasAPIFilters returns true if there are any API-level filters.

func (*APIParams) IsEmpty

func (p *APIParams) IsEmpty() bool

IsEmpty returns true if there are no API parameters set.

type Aggregation

type Aggregation struct {
	Func     ast.AggregateType
	Field    string // empty for COUNT(*)
	Distinct bool
	Alias    string
}

Aggregation represents an aggregate function to apply.

type Filter

type Filter struct {
	Field string
	Op    ast.CompareOp
	Value *ast.Value

	// SubqueryIndex is the index into Plan.Subqueries if this filter
	// uses a subquery. -1 indicates no subquery.
	SubqueryIndex int

	// SubqueryResult holds the resolved subquery result after execution.
	// For scalar subqueries: a single value (int64, float64, string)
	// For list subqueries: a []any of values
	SubqueryResult any
}

Filter represents a client-side filter.

type JoinPlan

type JoinPlan struct {
	Type      ast.JoinType
	Entity    ast.EntityType
	Alias     string
	Condition ast.Expr
}

JoinPlan represents a planned join operation.

type OrderBy

type OrderBy struct {
	Field     string
	Direction ast.SortDirection
}

OrderBy represents the sort order.

type Plan

type Plan struct {
	// Entity is the entity type to query.
	Entity ast.EntityType

	// APIParams are parameters that can be pushed to the Aha API.
	APIParams APIParams

	// ClientFilters are filters that must be applied client-side.
	ClientFilters []Filter

	// SelectFields are the fields to return. Nil means all fields.
	SelectFields []string

	// SelectItems contains the original select items (for aggregate queries).
	SelectItems []ast.SelectItem

	// Aggregations defines aggregate functions to apply.
	Aggregations []Aggregation

	// GroupBy fields for grouping results.
	GroupBy []string

	// Having filter applied after aggregation.
	Having ast.Expr

	// Joins for multi-entity queries.
	Joins []*JoinPlan

	// OrderBy specifies the sort field and direction.
	OrderBy *OrderBy

	// Limit is the maximum number of results to return.
	Limit *int

	// RequiresPagination indicates if we need to fetch all pages
	// (true when client-side filtering or sorting is required).
	RequiresPagination bool

	// HasAggregates indicates if the query contains aggregate functions.
	HasAggregates bool

	// NeedsCustomFields indicates if the query references custom.* fields.
	// When true, the executor needs to fetch full entity details (not just meta).
	NeedsCustomFields bool

	// Subqueries contains any subqueries that need to be executed first.
	// Each subquery is identified by an index and will be resolved before
	// the main query is executed.
	Subqueries []*SubqueryPlan
}

Plan represents an execution plan for an AQL query.

type Planner

type Planner struct {
	// contains filtered or unexported fields
}

Planner converts AQL queries to execution plans.

func New

func New() *Planner

New creates a new planner.

func (*Planner) Plan

func (p *Planner) Plan(query *ast.Query) *Plan

Plan creates an execution plan from a parsed query.

type SubqueryPlan

type SubqueryPlan struct {
	// Query is the AST for the subquery.
	Query *ast.Query

	// Plan is the execution plan for the subquery (populated by planner).
	Plan *Plan

	// Index identifies this subquery for result substitution.
	Index int

	// Field is the main query field this subquery is compared against.
	Field string

	// Op is the comparison operator used.
	Op ast.CompareOp

	// IsScalar indicates if this subquery should return a single value
	// (true for comparisons like >, <, =; false for IN).
	IsScalar bool
}

SubqueryPlan represents a subquery that needs to be executed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL