Skip to content
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

Quarterly truncation no longer allowed in backends.sql.compilers.base.visit_TimestampTruncate #9714

Closed
1 task done
ph-eip opened this issue Jul 29, 2024 · 4 comments · Fixed by #9715
Closed
1 task done
Assignees
Labels
bug Incorrect behavior inside of ibis
Milestone

Comments

@ph-eip
Copy link

ph-eip commented Jul 29, 2024

What happened?

When truncating my timestamps to quarterly, the error: Unsupported truncate unit None was reported.

However, in the documentation quarterly is listed as supported: https://ibis-project.org/reference/expression-temporal.html#parameters-4. (Also, database backends support quarterly truncation).

The error appears to be the definition of 'unit_mapping' in the function visit_TimestampTruncate found at:

def visit_TimestampTruncate(self, op, *, arg, unit):

    def visit_TimestampTruncate(self, op, *, arg, unit):
        unit_mapping = {
            "Y": "year",
            "M": "month",
            "W": "week",
            "D": "day",
            "h": "hour",
            "m": "minute",
            "s": "second",
            "ms": "ms",
            "us": "us",
        }

        if (unit := unit_mapping.get(unit.short)) is None:
            raise com.UnsupportedOperationError(f"Unsupported truncate unit {unit}")

There you can see that 'Q' is missing from the unit_mapping keys.

What version of ibis are you using?

9.2.0

What backend(s) are you using, if any?

Postgres

Relevant log output

https://github.com/ibis-project/ibis/blob/038a95a19d979fde23fee95df5df8c1838eaa9b3/ibis/backends/sql/compilers/base.py#L837

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ph-eip ph-eip added the bug Incorrect behavior inside of ibis label Jul 29, 2024
@lostmygithubaccount
Copy link
Member

I hit this recently too (DuckDB backend) but hadn't investigated, appreciate the thorough report!

@cpcloud
Copy link
Member

cpcloud commented Jul 29, 2024

Thanks! This looks like might have been a casualty of the port to sqlglot in 9.0, and that we may not have enough test coverage. Great bug report!

@ph-eip
Copy link
Author

ph-eip commented Jul 30, 2024

Nice. Appreciate the swift resolution. Will this be part of a new minor release soon?

@cpcloud
Copy link
Member

cpcloud commented Jul 30, 2024

We'll try to cut 9.3 this week!

@cpcloud cpcloud added this to the 9.3 milestone Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Incorrect behavior inside of ibis
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants