All Products
Search
Document Center

ApsaraDB RDS:ST_AsTableFormat

Last Updated:Jun 28, 2023

This topic describes the ST_AsTableFormat function. This function obtains the definition of a trajectory to specify the column type for the ST_AsTable function.

Syntax

text ST_AsTableFormat(trajectory traj);

Parameters

Parameter

Description

traj

The original trajectory object.

Description

This function obtains the definition of a trajectory and provides the record type as a text file. The record type is used when you call the ST_AsTable function to convert a trajectory into a table.

For example, if you want to convert a trajectory into a table, you must call the ST_AsTableFormat function to obtain the definition of a trajectory and then convert the trajectory into a table with specific columns. In this example, the definition is (t timestamp, x double precision, y double precision, sog real, cog integer, hdg integer, rot integer, status integer, is_satelite smallint, statictime integer).

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

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);
-----
(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)