-
Notifications
You must be signed in to change notification settings - Fork 608
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
feat: add to_date function to StringValue #9030
Conversation
ACTION NEEDED Ibis follows the Conventional Commits specification for release automation. The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification. |
@gforsyth I am struggling a little with running the tests. I couldn't find much on setting up the database. I can see that in conftest.py some env variable are read so I provided those for my local postgres database via the .env file (on a side note: I found it weird that the .env is committed? ) Now I seem to be missing an extension
and it doesn't seem trivial to install it. Is there any documentation on setting up the env for running the tests? |
Hey @saschahofmann -- rather than using your own instance, I'd recommend installing |
There are also some instructions here: https://ibis-project.org/contribute/02_workflow#running-the-test-suite If you're using a mac M2 it's more involved because of the architecture |
Perfect. No idea why i didnt find that section. Will experiment around and hopefully have something more complete soon. |
I now implemented the default fallback in sql/compiler.py L804 like this def visit_StringToDate(self, op, *, arg, format_str):
return self.f.date(self.f.str_to_time(arg, format_str)) Is there a way to do it using ibis (something like |
For postgres, the format for to_timestamp seems to be translated to the postgres native format but its not obvious to me where this happens? I would need to do something similar for to_date |
@saschahofmann -- |
Alright. I found that SQLGlot has actually implemented StrToDate so I am just using that. What do I need to do make the doc test pass? |
Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
I think its ready for review ! |
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.
This looks really nice, @saschahofmann !
I think this patch will get snowflake passing:
index 75bfd7ce6..c0915d059 100644
--- a/ibis/backends/snowflake/compiler.py
+++ b/ibis/backends/snowflake/compiler.py
@@ -78,6 +78,7 @@ class SnowflakeCompiler(SQLGlotCompiler):
ops.Hash: "hash",
ops.Median: "median",
ops.Mode: "mode",
+ ops.StringToDate: "to_date",
ops.StringToTimestamp: "to_timestamp_tz",
ops.TimeFromHMS: "time_from_parts",
ops.TimestampFromYMDHMS: "timestamp_from_parts",
Huh, I think I actually had this but removed it because I thought it was in SQLGlot. Will put it back |
I assume that the failing test is unrelated? At least its not clear to me where this would be coming from? |
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.
Thanks for putting this together @saschahofmann! The snowpark error is definitely unrelated and might be flaky, so I'm going to merge this and see what happens on CI.
This showed up in #9030 and I wasn't sure if it was flaky, but it looks like Snowpark can now run Ibis as `caller`, too!
Description of changes
Adds
to_date
to string types that accepts a format string and parses a string to Date type.Uses a cast to timestamp and extract time as a fallback like this
Issues closed
Implements half of #8908