-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add missing function mappings #945
base: main
Are you sure you want to change the base?
Changes from all commits
7788909
504e851
ff71fcb
362ab68
4e568af
d6b9ef3
af8f4b0
1efb231
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,29 +20,26 @@ const StandardFunctions = { | |
month: x => `date_part('month', ${castVal(x)})`, | ||
day: x => `date_part('day', ${castVal(x)})`, | ||
time: x => `to_char(${castVal(x)}, 'HH24:MI:SS')`, | ||
date: x => `to_char(${castVal(x)}, 'YYYY-MM-DD')`, | ||
hour: x => `date_part('hour', ${castVal(x)})`, | ||
minute: x => `date_part('minute', ${castVal(x)})`, | ||
second: x => `floor(date_part('second', ${castVal(x)}))`, | ||
fractionalseconds: x => `CAST(date_part('second', ${castVal(x)}) - floor(date_part('second', ${castVal(x)})) AS DECIMAL)`, | ||
// 1. Extract and convert days to seconds | ||
// 2. Extract and convert hours to seconds | ||
// 3. Extract and convert minutes to seconds | ||
// 4. Extract seconds (including fractional part) and convert to double | ||
// --> Add all together | ||
totalseconds: x => `( | ||
CAST(substring(${x}, 2, strpos(${x}, 'DT') - 2) AS INTEGER) * 86400 | ||
) + ( | ||
( | ||
( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. didnt work before, because we already have seconds from the EXTRACT(EPOCH) step, so multiplying by 86400 again drastically inflates the result. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why no just move the multiplication and keep the |
||
CAST(substring(${x},2,strpos(${x},'DT') - 2) AS INTEGER) | ||
) + ( | ||
EXTRACT (EPOCH FROM | ||
CAST( | ||
replace( | ||
replace( | ||
replace( | ||
substring(${x},strpos(${x},'DT') + 2), | ||
'H',':' | ||
),'M',':' | ||
),'S','Z' | ||
) | ||
as TIME) | ||
) - 0.5 | ||
) | ||
) * 86400 | ||
CAST(split_part(substring(${x}, strpos(${x}, 'DT') + 2), 'H', 1) AS INTEGER) * 3600 | ||
) + ( | ||
CAST(split_part(split_part(substring(${x}, strpos(${x}, 'DT') + 2), 'H', 2), 'M', 1) AS INTEGER) * 60 | ||
) + ( | ||
CAST(replace(split_part(split_part(substring(${x}, strpos(${x}, 'DT') + 2), 'M', 2), 'S', 1), 'Z', '') AS DOUBLE PRECISION) | ||
) | ||
)`, | ||
now: function() { | ||
return this.session_context({val: '$now'}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what happened with this sentence, but it should be something more like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes more sense, however why not state what the function returns as well?