All Products
Search
Document Center

PolarDB:ST_trajAttrsAsInteger

Last Updated:Mar 28, 2026

Returns an integer array containing the values of an integer-type attribute field from a trajectory object. NULL values in the field are preserved in the returned array.

Syntax

integer[] st_trajAttrsAsInteger(trajectory traj, text attr_name);

Parameters

ParameterDescription
trajThe trajectory object.
attr_nameThe name of the attribute field.

Example

The following example retrieves the values of the speed attribute from a trajectory with two points.

With traj AS (
  select '{"trajectory":{"version":1,"type":"STPOINT","leafcount":2,"start_time":"2010-01-01 11:30:00","end_time":"2010-01-01 12:30:00","spatial":"SRID=4326;LINESTRING(1 1,3 5)","timeline":["2010-01-01 11:30:00","2010-01-01 12:30:00"],"attributes":{"leafcount":2,"velocity":{"type":"integer","length":4,"nullable":true,"value":[1,null]},"speed":{"type":"float","length":8,"nullable":true,"value":[null,1.0]},"angle":{"type":"string","length":64,"nullable":true,"value":["test",null]}, "tngel2":{"type":"timestamp","length":8,"nullable":true,"value":["2010-01-01 12:30:00",null]},"bearing":{"type":"bool","length":1,"nullable":true,"value":[null,true]}}}}'::trajectory a)
Select st_trajAttrsAsInteger(a, 'speed') from traj;
 st_trajattrsasinteger
-----------------------
 {NULL,1}
(1 row)