Skip to content

Commit

Permalink
Add Cuebot SQL epoch function (#1437)
Browse files Browse the repository at this point in the history
Add Cuebot SQL epoch function
- Create or replace the epoch function to fix issues with conversion of
timestamp with timezone to account daylight saving time.
- This function uses postgresql internal extract and epoch function.

Co-authored-by: Ramon Figueiredo
<[[email protected]](mailto:[email protected])>
Co-authored-by: Harinder Tehara
<[[email protected]](mailto:[email protected])>

---------

Co-authored-by: Harinder Tehara <[email protected]>
Co-authored-by: Diego Tavares <[email protected]>
  • Loading branch information
3 people authored Jul 31, 2024
1 parent 4e35887 commit d10af68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.33
0.34
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- Create or replace the epoch function to fix issue with conversion of timestamp with timezone to account daylight
-- saving time
-- This function use postgresql internal extract and epoch function

CREATE OR REPLACE FUNCTION public.epoch(
timestamp with time zone)
RETURNS numeric
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
DECLARE
t ALIAS FOR $1;
delta integer;
BEGIN

delta := extract(epoch from t);
RETURN delta;
END;
$BODY$;

0 comments on commit d10af68

Please sign in to comment.