-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Add important timestamp/date builtins. #2420
Conversation
b498230
to
115bdc8
Compare
returnType: DummyFloat, | ||
fn: func(args DTuple) (Datum, error) { | ||
t := args[1].(DTimestamp) | ||
s := strings.ToLower(string(args[0].(DString))) |
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.
nit: t
and s
are not very descriptive variable names
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.
done
115bdc8
to
915f095
Compare
true | ||
|
||
query T | ||
SELECT now() - current_timestamp < interval '1s' |
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.
It looks like some of these work with or without parens, while others require parens. We should have a test that current_timestamp()
works and now
doesn't.
915f095
to
e2f78de
Compare
@@ -110,6 +110,8 @@ var keywords = map[string]int{ | |||
"DATABASES": DATABASES, | |||
"DATE": DATE, | |||
"DAY": DAY, | |||
"DAYOFWEEK": DAYOFWEEK, | |||
"DAYOFYEAR": DAYOFYEAR, |
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.
FYI, I'm pretty sure you don't have to add all of these here and you don't have to add them to sql.ly
either. The extract_arg
rule accepts IDENT
which will capture all of these strings.
e2f78de
to
1f2996c
Compare
related issue #2427 |
1f2996c
to
e562b60
Compare
LGTM |
@@ -470,3 +566,12 @@ func datumToRawString(datum Datum) (string, error) { | |||
|
|||
return "", fmt.Errorf("argument type unsupported: %s", datum.Type()) | |||
} | |||
|
|||
var nowImpl = builtin{ |
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.
can you put this near the other var
? weird to have it here.
LGTM |
e562b60
to
9550072
Compare
9550072
to
e23aad9
Compare
e23aad9
to
42447d2
Compare
Add important timestamp/date builtins.
closes #2329