TD_NORMALIZE_OVERLAP_MEET
Purpose
Combines the rows whose Period values either meet or overlap so that the resulting normalized row contains the earliest beginning bound and the latest ending bound from the Period values of all the rows involved.
Syntax
where:
Syntax element... |
Specifies... |
grouping_column_list |
one or more grouping columns, not including the Period column. You must specify the input as a dynamic UDT. |
period_column |
a column with a data type of PERIOD(DATE), PERIOD(TIMESTAMP), or PERIOD(TIMESTAMP WITH TIME ZONE). |
Invocation
TD_NORMALIZE_OVERLAP_MEET is an embedded services system function. For information on activating and invoking embedded services functions, see “Embedded Services System Functions” on page 24.
Usage Notes
TD_NORMALIZE_OVERLAP_MEET is a table function that takes two arguments. The arguments passed to the function are the specified columns in a subtable derived from using the WITH Request Modifier as follows:
Input to the table function must be columns that are hash-redistributed on the grouping columns and sorted by the grouping columns and the Period values as follows:
You must invoke the function with a RETURNS clause that specifies the output columns as follows:
Result
This function returns result rows with the columns specified in the RETURNS clause as follows:
Example
WITH subtbl(flight_id, duration) AS
(SELECT flight_id, duration FROM FlightExp)
SELECT *
FROM TABLE (TD_SYSFNLIB.TD_NORMALIZE_OVERLAP_MEET(NEW VARIANT_TYPE(subtbl.flight_id),
subtbl.duration)
RETURNS (flight_id INT, duration PERIOD(TIMESTAMP(6) WITH TIME ZONE), NrmCount INT)
HASH BY flight_id /* input data is redistributed on column, flight_id */
LOCAL ORDER BY flight_id, duration) /* input data is sorted on these columns */
AS DT(flight_id, duration, NrmCount) ORDER BY 1,2;