A temporal value can be transformed to another duration. An error is raised if the durations are incompatible.
Transform a temporal value to another duration
ttypeinst(ttype): ttypeinst
ttypei(ttype): ttypei
ttypeseq(ttype): ttypeseq
ttypes(ttype): ttypes
SELECT tboolinst(tbool '{[true@2001-01-01]}'); -- "t@2001-01-01 00:00:00+00" SELECT tboolinst(tbool '{[true@2001-01-01, true@2001-01-02]}'); -- ERROR: Cannot transform input to a temporal instant SELECT tbooli(tbool 'true@2001-01-01'); -- "{t@2001-01-01}" SELECT tintseq(tint '1@2001-01-01'); -- "[1@2001-01-01]" SELECT tfloats(tfloat '2.5@2001-01-01'); -- "{[2.5@2001-01-01]}" SELECT tfloats(tfloat '{2.5@2001-01-01, 1.5@2001-01-02, 3.5@2001-01-02}'); -- "{[2.5@2001-01-01],[1.5@2001-01-02],[3.5@2001-01-03]}"
Transform a temporal value with continuous base type from stepwise to linear interpolation
toLinear(ttype) : ttype
SELECT toLinear(tfloat 'Interp=Stepwise;[1@2000-01-01, 2@2000-01-02, 1@2000-01-03, 2@2000-01-04]'); -- "{[1@2000-01-01, 1@2000-01-02), [2@2000-01-02, 2@2000-01-03), [1@2000-01-03, 1@2000-01-04), [2@2000-01-04]}" SELECT asText(toLinear(tgeompoint 'Interp=Stepwise;{[Point(1 1)@2000-01-01, Point(2 2)@2000-01-02], [Point(3 3)@2000-01-05, Point(4 4)@2000-01-06]}')); -- "{[POINT(1 1)@2000-01-01, POINT(1 1)@2000-01-02), [POINT(2 2)@2000-01-02], [POINT(3 3)@2000-01-05, POINT(3 3)@2000-01-06), [POINT(4 4)@2000-01-06]}"
Append a temporal instant to a temporal value
appendInstant(ttype, ttypeinst) : ttype
SELECT appendInstant(tint '1@2000-01-01', tint '1@2000-01-02'); -- "{1@2000-01-01, 1@2000-01-02}" SELECT appendInstant(tintseq(tint '1@2000-01-01'), tint '1@2000-01-02'); -- "[1@2000-01-01, 1@2000-01-02]" SELECT asText(appendInstant(tgeompoint '{[Point(1 1 1)@2000-01-01, Point(2 2 2)@2000-01-02], [Point(3 3 3)@2000-01-04, Point(3 3 3)@2000-01-05]}', tgeompoint 'Point(1 1 1)@2000-01-06')); -- "{[POINT Z (1 1 1)@2000-01-01, POINT Z (2 2 2)@2000-01-02], [POINT Z (3 3 3)@2000-01-04, POINT Z (3 3 3)@2000-01-05, POINT Z (1 1 1)@2000-01-06]}"
Merge temporal values
merge(ttype, ttype) : ttype
merge(ttype[]) : ttype
The values may share a single timestamp, in that case the temporal values are joined in the result if their value at the common timestamp is the same, otherwise an error is raised.
SELECT merge(tint '1@2000-01-01', tint '1@2000-01-02'); -- "{1@2000-01-01, 1@2000-01-02}" SELECT merge(tint '[1@2000-01-01, 2@2000-01-02]', tint '[2@2000-01-02, 1@2000-01-03]'); -- "[1@2000-01-01, 2@2000-01-02, 1@2000-01-03]" SELECT merge(tint '[1@2000-01-01, 2@2000-01-02]', tint '[3@2000-01-03, 1@2000-01-04]'); -- "{[1@2000-01-01, 2@2000-01-02], [3@2000-01-03, 1@2000-01-04]}" SELECT merge(tint '[1@2000-01-01, 2@2000-01-02]', tint '[1@2000-01-02, 2@2000-01-03]'); -- ERROR: Both arguments have different value at their overlapping timestamp SELECT asText(merge(tgeompoint '{[Point(1 1 1)@2000-01-01, Point(2 2 2)@2000-01-02], [Point(3 3 3)@2000-01-04, Point(3 3 3)@2000-01-05]}', tgeompoint '{[Point(3 3 3)@2000-01-05, Point(1 1 1)@2000-01-06]}')); -- "{[POINT Z (1 1 1)@2000-01-01, POINT Z (2 2 2)@2000-01-02], [POINT Z (3 3 3)@2000-01-04, POINT Z (3 3 3)@2000-01-05, POINT Z (1 1 1)@2000-01-06]}" SELECT merge(ARRAY[tint '1@2000-01-01', '1@2000-01-02']); -- "{1@2000-01-01, 1@2000-01-02}" SELECT merge(ARRAY[tint '{1@2000-01-01, 2@2000-01-02}', '{2@2000-01-02, 3@2000-01-03}']); -- "{1@2000-01-01, 2@2000-01-02, 3@2000-01-03}" SELECT merge(ARRAY[tint '{1@2000-01-01, 2@2000-01-02}', '{3@2000-01-03, 4@2000-01-04}']); -- "{1@2000-01-01, 2@2000-01-02, 3@2000-01-03, 4@2000-01-04}" SELECT merge(ARRAY[tint '[1@2000-01-01, 2@2000-01-02]', '[2@2000-01-02, 1@2000-01-03]']); -- "[1@2000-01-01, 2@2000-01-02, 1@2000-01-03]" SELECT merge(ARRAY[tint '[1@2000-01-01, 2@2000-01-02]', '[3@2000-01-03, 4@2000-01-04]']); -- "{[1@2000-01-01, 2@2000-01-02], [3@2000-01-03, 4@2000-01-04]}" SELECT merge(ARRAY[tgeompoint '{[Point(1 1)@2000-01-01, Point(2 2)@2000-01-02], [Point(3 3)@2000-01-03, Point(4 4)@2000-01-04]}', '{[Point(4 4)@2000-01-04, Point(3 3)@2000-01-05], [Point(6 6)@2000-01-06, Point(7 7)@2000-01-07]}']); -- "{[Point(1 1)@2000-01-01, Point(2 2)@2000-01-02], [Point(3 3)@2000-01-03, Point(4 4)@2000-01-04, Point(3 3)@2000-01-05], [Point(6 6)@2000-01-06, Point(7 7)@2000-01-07]}" SELECT merge(ARRAY[tgeompoint '{[Point(1 1)@2000-01-01, Point(2 2)@2000-01-02]}', '{[Point(2 2)@2000-01-02, Point(1 1)@2000-01-03]}']); -- "[Point(1 1)@2000-01-01, Point(2 2)@2000-01-02, Point(1 1)@2000-01-03]"