Loading...

vastorbit.sql.functions.apply

vastorbit.sql.functions.apply(func: Annotated[str | list[str] | StringSQL | list[StringSQL], ''], *args, **kwargs) StringSQL

Applies any VAST function on the input expressions.

Parameters:
  • func (SQLExpression) – VAST Function. For geospatial functions, you can write the function name without the ST_ prefix.

  • args (SQLExpression, optional) – Expressions.

  • kwargs (SQLExpression, optional) – Optional Parameters Expressions.

Returns:

SQL string.

Return type:

StringSQL

Examples

First, let’s import the VastFrame in order to create a dummy dataset.

from vastorbit import VastFrame

Now, let’s import the vastorbit SQL functions.

import vastorbit.sql.functions as vof

We can now build a dummy dataset.

df = VastFrame({"x": [11.4, -2.5, 3.5, -4.2]})

Now, let’s go ahead and apply the function.

df["avg_x"] = vof.apply("avg", df["x"])._over()
display(df)
123
x
Decimal(3,1)
100%
123
avg_x
Decimal(3,1)
100%
1-2.52.1
211.42.1
3-4.22.1
43.52.1

Note

It’s crucial to utilize vastorbit SQL functions in coding, as they can be updated over time with new syntax. While SQL functions typically remain stable, they may vary across platforms or versions. vastorbit effectively manages these changes, a task not achievable with pure SQL.

See also

VastFrame.eval() : Evaluates the expression.