Skip to content

Queries

amsdal_glue.AggregationQuery dataclass

Represents an aggregation query.

Attributes:

Name Type Description
expression AggregationExpression

The aggregation expression.

alias str

The alias for the aggregation.

amsdal_glue.AnnotationQuery dataclass

Represents an annotation query.

Attributes:

Name Type Description
value SubQueryStatement | ValueAnnotation

The value or subquery being annotated.

amsdal_glue.Avg dataclass

Bases: AggregationExpression

Represents an AVG aggregation expression.

Attributes:

Name Type Description
name ClassVar[str]

The name of the aggregation function, which is 'AVG'.

amsdal_glue.Condition dataclass

Represents a condition in a query.

Attributes:

Name Type Description
left Expression

The left expression to which the condition applies.

lookup FieldLookup

The lookup type for the condition.

right left

The right expression for the condition.

negate bool

Whether the condition is negated. Defaults to False.

amsdal_glue.Conditions

Represents a collection of conditions in a query.

Attributes:

Name Type Description
children list[Union[Conditions, Condition]]

The list of child conditions.

connector FilterConnector

The connector type (AND/OR) for the conditions.

negated bool

Whether the conditions are negated. Defaults to False.

amsdal_glue.Count dataclass

Bases: AggregationExpression

Represents a COUNT aggregation expression.

Attributes:

Name Type Description
name ClassVar[str]

The name of the aggregation function, which is 'COUNT'.

amsdal_glue.DataQueryOperation dataclass

Bases: QueryOperationBase

Represents a data query operation.

Attributes:

Name Type Description
query QueryStatement

The query statement to be executed.

amsdal_glue.Field dataclass

Represents a field in a schema.

Attributes:

Name Type Description
name str

The name of the field.

child Optional[Field]

The child field, if any. Defaults to None.

parent Optional[Field]

The parent field, if any. Defaults to None.

amsdal_glue.FieldLookup

Bases: str, Enum

Represents the lookup type for a field in a query.

Attributes:

Name Type Description
EXACT str

Exact match.

EQ str

Equal to.

NEQ str

Not equal to.

GT str

Greater than.

GTE str

Greater than or equal to.

LT str

Less than.

LTE str

Less than or equal to.

IN str

In a list.

CONTAINS str

Contains a value.

ICONTAINS str

Case-insensitive contains.

STARTSWITH str

Starts with a value.

ISTARTSWITH str

Case-insensitive starts with.

ENDSWITH str

Ends with a value.

IENDSWITH str

Case-insensitive ends with.

ISNULL str

Is null.

REGEX str

Matches a regular expression.

IREGEX str

Case-insensitive matches a regular expression.

amsdal_glue.FieldReference dataclass

Bases: Combinable

Represents a reference to a field in a table.

This class provides a reference to a field within a specific table, including the namespace of the field. It extends from Combinable to support combinable operations on field references.

Attributes:

Name Type Description
field Field

The field being referenced.

table_name str

The name of the table containing the field.

namespace str

The namespace of the field. Defaults to an empty string.

Example
from amsdal_glue_core.common.data_models.field_reference import Field, FieldReference

field = Field(name='age')
field_ref = FieldReference(field=field, table_name='users')

# Example of combining field references
combined_expr = field_ref + 10  # Represents users.age + 10

amsdal_glue.FieldReferenceAliased dataclass

Bases: FieldReference

Represents a reference to a field in a table with an alias.

Attributes:

Name Type Description
alias str

The alias for the field reference.

amsdal_glue.GroupByQuery dataclass

Represents a GROUP BY query.

Attributes:

Name Type Description
field FieldReference

The field to group by.

amsdal_glue.JoinQuery dataclass

Represents a join query.

Attributes:

Name Type Description
table SchemaReference | SubQueryStatement

The table or subquery being joined.

on Conditions

The conditions for the join.

join_type JoinType

The type of join. Defaults to JoinType.INNER.

amsdal_glue.JoinType

Bases: str, Enum

Represents the type of join in a query.

Attributes:

Name Type Description
INNER str

Inner join.

LEFT str

Left join.

RIGHT str

Right join.

FULL str

Full join.

amsdal_glue.LimitQuery dataclass

Represents a LIMIT query.

Attributes:

Name Type Description
limit int

The maximum number of records to return.

offset int

The number of records to skip before starting to return records. Defaults to 0.

amsdal_glue.Max dataclass

Bases: AggregationExpression

Represents a MAX aggregation expression.

Attributes:

Name Type Description
name ClassVar[str]

The name of the aggregation function, which is 'MAX'.

amsdal_glue.Min dataclass

Bases: AggregationExpression

Represents a MIN aggregation expression.

Attributes:

Name Type Description
name ClassVar[str]

The name of the aggregation function, which is 'MIN'.

amsdal_glue.OrderByQuery dataclass

Represents an ORDER BY query.

Attributes:

Name Type Description
field FieldReference

The field to order by.

direction OrderDirection

The direction of the order (ASC/DESC). Defaults to OrderDirection.ASC.

amsdal_glue.OrderDirection

Bases: str, Enum

Represents the direction of ordering in a query.

Attributes:

Name Type Description
ASC str

Ascending order.

DESC str

Descending order.

amsdal_glue.QueryStatement dataclass

Represents a query statement.

Attributes:

Name Type Description
table SchemaReference | SubQueryStatement

The table or subquery being queried.

only list[FieldReference | FieldReferenceAliased] | None

The list of fields to select. Defaults to None.

distinct bool | list[FieldReference | FieldReferenceAliased]

Whether to select distinct rows. Defaults to False. If a list of fields is provided, the distinct will be applied to the fields.

annotations list[AnnotationQuery] | None

The list of annotations in the query. Defaults to None.

aggregations list[AggregationQuery] | None

The list of aggregations in the query. Defaults to None.

joins list[JoinQuery] | None

The list of joins in the query. Defaults to None.

where Conditions | None

The conditions for the query. Defaults to None.

group_by list[GroupByQuery] | None

The list of group by clauses in the query. Defaults to None.

order_by list[OrderByQuery] | None

The list of order by clauses in the query. Defaults to None.

limit LimitQuery | None

The limit clause for the query. Defaults to None.

amsdal_glue.SchemaQueryOperation dataclass

Bases: QueryOperationBase

Represents a schema query operation.

Attributes:

Name Type Description
filters Conditions | None

The conditions to filter the schema query. Defaults to None.

amsdal_glue.SubQueryStatement dataclass

Represents a subquery statement.

Attributes:

Name Type Description
query QueryStatement

The query being used as a subquery.

alias str

The alias for the subquery.

amsdal_glue.Sum dataclass

Bases: AggregationExpression

Represents a SUM aggregation expression.

Attributes:

Name Type Description
name ClassVar[str]

The name of the aggregation function, which is 'SUM'.

amsdal_glue.Value dataclass

Bases: Expression

Represents a value expression.

Attributes:

Name Type Description
value Any

The value of the expression.

amsdal_glue.ValueAnnotation dataclass

Represents a value annotation.

Attributes:

Name Type Description
value Value

The value being annotated.

alias str

The alias for the annotation.