All Products
Search
Document Center

PolarDB:ST_AsTableFormat

Last Updated:Mar 28, 2026

Returns the column definition of a trajectory as a text string. Use the output to specify column types when calling ST_AsTable to convert a trajectory into a relational table.

Syntax

text ST_AsTableFormat(trajectory traj);

Parameters

ParameterDescription
trajThe trajectory object.

Description

ST_AsTableFormat inspects a trajectory and returns its record type as a text string. Pass this string as the column definition in ST_AsTable to control how the trajectory is expanded into table columns.

For example, after calling ST_AsTableFormat to get the column definition, use it in ST_AsTable as follows:

SELECT f.*
FROM table_name,
     ST_AsTable(traj) AS f(t timestamp, x double precision, y double precision, sog real, cog integer, hdg integer, rot integer, status integer, is_satelite smallint, statictime integer);

Examples

Call ST_AsTableFormat on a trajectory value to retrieve its column definition:

SELECT ST_AsTableFormat('{"trajectory":{"version":1,"type":"STPOINT","leafcount":1,"start_time":"2010-01-01 11:30:00","end_time":"2010-01-01 11:30:00","spatial":"SRID=4326;POINT(1 1)","timeline":["2010-01-01 11:30:00"],"attributes":{"leafcount":1,"i1":{"type":"integer","length":1,"nullable":true,"value":[1]},"i2":{"type":"integer","length":2,"nullable":true,"value":[1]},"i4":{"type":"integer","length":4,"nullable":true,"value":[1]},"i8":{"type":"integer","length":8,"nullable":true,"value":[1]}, "f4":{"type":"float","length":4,"nullable":true,"value":[1]},"f8":{"type":"float","length":8,"nullable":true,"value":[1]},"string":{"type":"string","length":10,"nullable":true,"value":["fat"]},"timestamp":{"type":"timestamp","length":8,"nullable":true,"value":["2010-01-01 11:30:00"]},"bool":{"type":"bool","length":1,"nullable":true,"value":["true"]}}}}'::trajectory);

Output:

(t timestamp, x double precision, y double precision, i1 integer, i2 smallint, i4 integer, i8 bigint, f4 real, f8 double precision, string text, timestamp timestamp, bool boolean)