-
Notifications
You must be signed in to change notification settings - Fork 232
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
CAST string to temporal type now calls isTimestamp #1718
Conversation
…puts Signed-off-by: Andy Grove <andygrove@nvidia.com>
build |
sql-plugin/src/main/scala/com/nvidia/spark/rapids/GpuCast.scala
Outdated
Show resolved
Hide resolved
convertTimestampOr(sanitizedInput, TIMESTAMP_REGEX_YYYY_MM, "%Y-%m", | ||
convertTimestampOrNull(sanitizedInput, TIMESTAMP_REGEX_YYYY, "%Y")))) | ||
convertTimestampOr(sanitizedInput, TIMESTAMP_REGEX_FULL_1, "%Y-%m-%d %H:%M:%S.%f", | ||
convertTimestampOr(sanitizedInput, TIMESTAMP_REGEX_FULL_2, "%Y-%m-%dT%H:%M:%S.%f", |
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.
Do we have to do an extra regex pass? IIRC the regex passes are really expensive, and I'm curious how it compares to the cost of isValidTimestamp
and asTimestampMicrosceonds
. I'm wondering if it would be overall cheaper to use the original regex and ifElse the two valid+conversion formats corresponding to that regex instead of adding another regex pass.
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.
Yes, that makes sense. I'll refactor this part to avoid the additional regex call.
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.
I pushed one commit that refactors this to use a single regex and then pushed another commit to remove the regex completely for this full timestamp case and tests pass with the current test values.
@revans2 would you have any concerns about removing regex use in this case?
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.
Once we have sanitized the inputs the regular expressions are redundant and should be removed.
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.
I think we can probably remove even more regular expressions from the code.
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.
I looked at this some more and remembered why we have the regex here. We need to make sure there is no additional text after the sanitized date/timestamp string. I added an additional test case to demonstrate this for timestamps and reverted the change to remove the regex for this case.
I do think could remove more of these regexes by checking the length of the sanitized strings (in conjunction with calling cuDF isTimestamp
) rather than using regex and have filed an issue for this: #1738
Signed-off-by: Andy Grove <andygrove@nvidia.com>
Signed-off-by: Andy Grove <andygrove@nvidia.com>
Signed-off-by: Andy Grove <andygrove@nvidia.com>
Signed-off-by: Andy Grove <andygrove@nvidia.com>
Signed-off-by: Andy Grove <andygrove@nvidia.com>
build |
Signed-off-by: Andy Grove andygrove@nvidia.com
CAST string to temporal types now uses
isTimestamp
to detect valid inputs.Closes #1117 and #716