Build aggregate for group by requests

Functions for aggregation in group_by.

avg(mdp, cast_type=<class 'float'>)

Aggregate function to make a AVG.

Parameters:
  • mdp (MagicDotPath) – A MagicDotPath to give the path of the function.

  • cast_type (type) – Type in which we want to cast the path(s). Its optional. By default: float

Returns:
  • MagicDotPathAggregate – MagicDotPathAggregate with the mdp and the type of aggregation.

Source code in py_linq_sql/build_request/consult_aggregate.py
def avg(mdp: MagicDotPath, cast_type: type = float) -> MagicDotPathAggregate:
    """
    Aggregate function to make a AVG.

    Args:
        mdp: A MagicDotPath to give the path of the function.
        cast_type: Type in which we want to cast the path(s). Its optional.
            By default: float

    Returns:
        MagicDotPathAggregate with the mdp and the type of aggregation.
    """
    return MagicDotPathAggregate(mdp, AggregateType.AVG, cast_type)

concat(mdp, separator)

Aggregate function to make a CONCAT.

Parameters:
  • mdp (MagicDotPath) – A MagicDotPath to give the path of the function.

Returns:
  • MagicDotPathAggregate – MagicDotPathAggregate with the mdp, the type of aggregation and the separator.

Source code in py_linq_sql/build_request/consult_aggregate.py
def concat(
    mdp: MagicDotPath,
    separator: str,
) -> MagicDotPathAggregate:
    """
    Aggregate function to make a CONCAT.

    Args:
        mdp: A MagicDotPath to give the path of the function.

    Returns:
        MagicDotPathAggregate with the mdp, the type of aggregation and the separator.
    """
    return MagicDotPathAggregate(
        mdp,
        AggregateType.CONCAT,
        separator=separator,
        cast_type=str,
    )

count(mdp, cast_type=<class 'float'>)

Aggregate function to make a COUNT.

Parameters:
  • - (mdp) – A MagicDotPath to give the path of the function.

  • - (cast_type) – Type in which we want to cast the path(s). Its optional. By default: float

Returns:
  • MagicDotPathAggregate – MagicDotPathAggregate with the mdp and the type of aggregation.

Source code in py_linq_sql/build_request/consult_aggregate.py
def count(mdp: MagicDotPath, cast_type: type = float) -> MagicDotPathAggregate:
    """
    Aggregate function to make a COUNT.

    Args:
        - mdp: A MagicDotPath to give the path of the function.
        - cast_type: Type in which we want to cast the path(s). Its optional.
            By default: float

    Returns:
        MagicDotPathAggregate with the mdp and the type of aggregation.
    """
    return MagicDotPathAggregate(mdp, AggregateType.COUNT, cast_type)

max(mdp, cast_type=<class 'float'>)

Aggregate function to make a MAX.

Parameters:
  • mdp (MagicDotPath) – A MagicDotPath to give the path of the function.

  • cast_type (type) – Type in which we want to cast the path(s). Its optional. By default: float

Returns:
  • MagicDotPathAggregate – MagicDotPathAggregate with the mdp and the type of aggregation.

Source code in py_linq_sql/build_request/consult_aggregate.py
def max(  # noqa: A001
    mdp: MagicDotPath,
    cast_type: type = float,
) -> MagicDotPathAggregate:
    """
    Aggregate function to make a MAX.

    Args:
        mdp: A MagicDotPath to give the path of the function.
        cast_type: Type in which we want to cast the path(s). Its optional.
            By default: float

    Returns:
        MagicDotPathAggregate with the mdp and the type of aggregation.
    """
    return MagicDotPathAggregate(mdp, AggregateType.MAX, cast_type)

min(mdp, cast_type=<class 'float'>)

Aggregate function to make a MIN.

Parameters:
  • mdp (MagicDotPath) – A MagicDotPath to give the path of the function.

  • cast_type (type) – Type in which we want to cast the path(s). Its optional. By default: float

Returns:
  • MagicDotPathAggregate – MagicDotPathAggregate with the mdp and the type of aggregation.

Source code in py_linq_sql/build_request/consult_aggregate.py
def min(  # noqa: A001
    mdp: MagicDotPath,
    cast_type: type = float,
) -> MagicDotPathAggregate:
    """
    Aggregate function to make a MIN.

    Args:
        mdp: A MagicDotPath to give the path of the function.
        cast_type: Type in which we want to cast the path(s). Its optional.
            By default: float

    Returns:
        MagicDotPathAggregate with the mdp and the type of aggregation.
    """
    return MagicDotPathAggregate(mdp, AggregateType.MIN, cast_type)

sum(mdp, cast_type=<class 'float'>)

Aggregate function to make a SUM.

Parameters:
  • mdp (MagicDotPath) – A MagicDotPath to give the path of the function.

  • cast_type (type) – Type in which we want to cast the path(s). Its optional. By default: float

Returns:
  • MagicDotPathAggregate – MagicDotPathAggregate with the mdp and the type of aggregation.

Source code in py_linq_sql/build_request/consult_aggregate.py
def sum(  # noqa: A001
    mdp: MagicDotPath,
    cast_type: type = float,
) -> MagicDotPathAggregate:
    """
    Aggregate function to make a SUM.

    Args:
        mdp: A MagicDotPath to give the path of the function.
        cast_type: Type in which we want to cast the path(s). Its optional.
            By default: float

    Returns:
        MagicDotPathAggregate with the mdp and the type of aggregation.
    """
    return MagicDotPathAggregate(mdp, AggregateType.SUM, cast_type)