Table of Contents

Search

  1. Preface
  2. Introduction to Informatica Big Data Management
  3. Connections
  4. Mappings in the Hadoop Environment
  5. Mapping Objects in the Hadoop Environment
  6. Processing Hierarchical Data on the Spark Engine
  7. Stateful Computing on the Spark Engine
  8. Monitoring Mappings in the Hadoop Environment
  9. Mappings in the Native Environment
  10. Profiles
  11. Native Environment Optimization
  12. Data Type Reference
  13. Complex File Data Object Properties
  14. Function Reference
  15. Parameter Reference

GPS Pings Example

GPS Pings Example

Your organization receives GPS pings from vehicles that include trip and event IDs and a time stamp. You want to calculate the time difference between each ping and flag the row as skipped if the time difference with the previous row is less than 60 seconds.
You order the events chronologically and partition the events by trip. You define a window function that accesses the event time from the previous row, and you use an ADD_TO_DATE function to calculate the time difference between the two events.

Windowing Properties

You define the following windowing properties on the Windowing tab:
Property
Description
Order key
_event_id Ascending
. Arranges the data chronologically by ascending event ID.
Partition key
trip_id
. Groups the rows according to trip ID so calculations are based on events from the same trip.
Frame
Not specified. Window functions access rows based on the offset argument and ignore the frame specification.
The following image shows the windowing properties you configure in the Expression transformation:
On the Windowing tab, _event_id is selected as the order key and trip_id is selected as the partition key. The frame specification is not defined.

Window Function

You define the following LAG function to get the event time from the previous row:
LAG ( _event_time, 1, NULL )
Where:
  • _event_time
    is the column name whose value from the previous row is to be returned.
  • 1
    is the offset. This value represents the row immediately before the current row.
  • NULL
    is the default value. The function returns NULL if the return value is outside the bounds of the partition.
You define the following DATE_DIFF function to calculate the length of time between the two dates:
DATE_DIFF ( _event_time, LAG ( _event_time, 1, NULL ), 'ss' )
You flag the row as skipped if the DATE_DIFF is less than 60 seconds, or if the _event_time is NULL:
IIF ( DATE_DIFF < 60 or ISNULL ( _event_time ), 'Skip', 'Valid' )
The following image shows the expressions you define in the transformation properties:
The LAG function, the DATE_DIFF function, and the IIF flag are defined on the Ports tab in the Expression transformation.

Output

The transformation produces the following outputs:
Trip ID
Event ID
Event Time
Time Difference
Flag
101
1
2017-05-03 12:00:00
NULL*
Skip
101
2
2017-05-03 12:00:34
34
Skip
101
3
2017-05-03 12:02:00
86
Valid
101
4
2017-05-03 12:02:23
23
Skip
102
1
2017-05-03 12:00:00
NULL*
Skip
102
2
2017-05-03 12:01:56
116
Valid
102
3
2017-05-03 12:02:00
4
Skip
102
4
2017-05-03 13:00:00
3480
Valid
103
1
2017-05-03 12:00:00
NULL*
Skip
103
2
2017-05-03 12:00:12
12
Skip
103
3
2017-05-03 12:01:12
60
Valid
*The rows preceding these rows are outside the bounds of the partition, so the transformation produced NULL values.


Updated November 09, 2018