Skip to content

Add time_bucket field for TimescaleDB support #114

Open
@moritz89

Description

@moritz89

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions