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

Add time_bucket field for TimescaleDB support #114

Open
moritz89 opened this issue Nov 9, 2022 · 0 comments
Open

Add time_bucket field for TimescaleDB support #114

moritz89 opened this issue Nov 9, 2022 · 0 comments

Comments

@moritz89
Copy link

moritz89 commented Nov 9, 2022

TimescaleDB has the time_bucket field to take full advantage of their hypertables: https://docs.timescale.com/api/latest/hyperfunctions/time_bucket/

This could be supported with:

class TimeBucketField(MultiField):
    def __init__(self, bucket_seconds=60.0, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.bucket_seconds = float(bucket_seconds)
        self.auto_alias = f"{self.field.name}_bucket"

    def get_select_sql(self):
        return f"""time_bucket('{self.bucket_seconds:.3f}s',"{self.field.name}")"""

Would this be in the scope of the project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant