All Products
Search
Document Center

:Aggregate functions

Last Updated:Jan 23, 2025

Aggregate functions aggregate multiple Point or LineString objects into a single LineString object. This topic describes the spatio-temporal aggregate functions supported by the Lindorm streaming engine.

ST_MakeLine_Agg

Constructs a LineString object based on the specified Point or LineString column.

Syntax

geometry ST_MakeLine_Agg(geometry geom);

Parameters

Parameter

Description

geom

The specified geometry column.

Note
  • This function only supports columns of the Point or LineString type.

  • If you specify multiple LineString objects, duplicate nodes are deleted during the construction process.

  • If you specify multiple Point objects, duplicate nodes are not deleted.

  • This function constructs the LineString object only based on the data input order and does not sort data.

Examples

  • Example 1:

    In this example, the data input order is from top to bottom.

    id

    name

    geom

    1

    A

    POINT (0 0)

    2

    B

    POINT (0 1)

    3

    C

    POINT (0 2)

    Execute the following statement to construct a LineString object based on the geom column:

    SELECT ST_AsText(ST_MakeLine_Agg(geom));

    Sample output:

    LINESTRING (0 0, 0 1, 0 2)
  • Example 2:

    In this example, the data input order is from top to bottom.

    id

    name

    geom

    1

    A

    POINT (0 0)

    3

    C

    POINT (0 2)

    2

    B

    POINT (0 1)

    Execute the following statement to construct a LindString object based on the geom column:

    SELECT ST_AsText(ST_MakeLine_Agg(geom));

    Sample output:

    LINESTRING (0 0, 0 2, 0 1)

The returned results in Example 1 and Example 2 show that the ST_MakeLine_Agg function constructs the LineString object only based on the data input order and does not sort data.

ST_MakeLine_Ts_Agg

Constructs a LineString object based on the specified Point or LineString column and sorts data based on the timestamp column.

Syntax

geometry ST_MakeLine_Ts_Agg(geometry geom, timestamp ts)

Parameters

Parameter

Description

geom

The specified geometry column.

ts

The specified timestamp column.

Note
  • This function only supports columns of the Point or LineString type.

  • If you specify multiple LineString objects, duplicate nodes are deleted during the construction process.

  • If you specify multiple Point objects, duplicate nodes are not deleted.

Examples

  • Example 1:

    In this example, the data input order is from top to bottom.

    id

    name

    ts

    geom

    1

    A

    2022-01-01 10:00:00

    POINT (0 0)

    2

    B

    2022-01-01 10:00:03

    POINT (0 1)

    3

    C

    2022-01-01 10:00:02

    POINT (0 2)

    Execute the following statement to construct a LindString object based on the geom column and sort data based on the ts column:

    SELECT ST_AsText(ST_MakeLine_Ts_Agg(geom,ts));

    Sample output:

    LINESTRING (0 0, 0 2, 0 1)
  • Example 2:

    In this example, the data input order is from top to bottom.

    id

    name

    ts

    geom

    1

    A

    2022-01-01 10:00:00

    POINT (0 0)

    3

    C

    2022-01-01 10:00:03

    POINT (0 2)

    2

    B

    2022-01-01 10:00:02

    POINT (0 1)

    Execute the following statement to construct a LindString object based on the geom column and sort data based on the ts column:

    SELECT ST_AsText(ST_MakeLine_Ts_Agg(geom,ts));

    Sample output:

    LINESTRING (0 0, 0 1, 0 2)