-
Notifications
You must be signed in to change notification settings - Fork 6
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
having datetime-strings in input parameters will produce errors #75
Comments
Are you sure |
Ah, sorry, you are right: it should be 'timestamp' and not 'datetime'. The fractional seconds are optional, however, but can have at maximum three digits. Timestamps of the format '2020-01-31T11:59:25Z' do not work, however. |
This is true, however I think this bug fix should be sufficient enough for what it is try to achieve. |
Yes! If one wants similar handling of timestamps, there is an additional hurdle: dbplyr formats timestamp variables in the above mentioned format (e.g., '2020-01-31T11:59:25Z', https://github.com/tidyverse/dbplyr/blob/38cdafd74303baaee02e545831d242de6c656f4c/R/escape.R#L76) so one would need to either be able to write an athena specific version of escape.POSIXt (that is, dbplyr should export the generic or a sql_escape_POSIXt etc) or alternatively one could just drop the T's and Z's and what not before passing the string on, but then one will surely get in trouble with timezones. So the dates seem to be the low hanging fruit and timestamps spell trouble (as usual)... |
PR #72 now includes this bug fix. Will leave issue open |
FYI: If I am not missing something, this should not affect the functionality of RAthena of noctua. For the case of real date variables (as opposed to date strings such as "2020-01-01"), dbplyr shoud add the 'date' keyword out of the box and the "is this string actually a date" -deduction will not be needed nor done for those cases. For the date strings, the implemented date test is still required. That is something Hadley didn't want to implement in dbplyr as the default behaviour. However, in my opinion, that feature is super useful. Do you see some issues with these changes? |
Ah perfect. it looks like you have done alot of work with dbplyr to make it simpler. If I have understood this correctly the |
@OssiLehtinen just had a deeper look at the new changes in dbplyr and it looks like no change is require for |
Issue Description
A query such as:
will produce an error, as Athena does not understand a literal of the form date '2020-01-31 51:59:25', but R can cast it to a date even with 'as.Date(x, tryFormats = "%Y-%m-%d")' used for testing in sql_escape_string.AthenaConnection.
This can be fixed with;
However, it wouldn't be a bad idea to have similar handling of date times and format those to, e.g., "datetime'2020-01-31 51:59:25'".
I will look into it, but it would be good to at least have the fix above included before pushing to cran.
The text was updated successfully, but these errors were encountered: