| /* ----------------------------------------------------------------------- */ |
| /** |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| * |
| * @file sessionize.sql_in |
| * |
| * @brief SQL functions for sessionizatino functions |
| * @date May 2016 |
| * |
| */ |
| /* ----------------------------------------------------------------------- */ |
| |
| CREATE TABLE eventlog_installchk ( |
| event_timestamp TIMESTAMP, |
| "user id" INT, |
| original_session_id INT, |
| page TEXT, |
| revenue FLOAT, |
| row INT, |
| part_expr BOOLEAN); |
| INSERT INTO eventlog_installchk VALUES |
| (to_timestamp('04/15/2015 01:03:00', 'MM/DD/YYYY HH:MI:SS'), 100821, 1, 'LANDING', 0, 1, 'f'), |
| (to_timestamp('04/15/2015 01:05:00', 'MM/DD/YYYY HH:MI:SS'), 100821, 1, 'WINE', 0, 1, 'f'), |
| (to_timestamp('04/15/2016 02:17:00', 'MM/DD/YYYY HH:MI:SS'), 103711, 1, 'BEER', 0, 1, 't'), |
| (to_timestamp('04/15/2016 02:21:00', 'MM/DD/YYYY HH:MI:SS'), 103711, 2, 'LANDING', 0, 1, 't'), |
| (to_timestamp('04/15/2016 02:31:0.05', 'MM/DD/YYYY HH:MI:SS'), 103711, 3, 'WINE', 0, 1, 't'); |
| |
| |
| SELECT sessionize( |
| 'eventlog_installchk', -- Name of the input table |
| 'sessionize_output_v', -- Name of the output table |
| '"user id"', -- Partition expression to group the data |
| 'event_timestamp', -- Order expression to sort the tuples of the data table |
| '0:3:0' -- Max time that can elapse between consecutive rows to be considered part of the same session |
| ); |
| |