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

Clean up SQL time interval math expressions #796

Merged
merged 3 commits into from
Oct 5, 2023

Conversation

tlento
Copy link
Contributor

@tlento tlento commented Oct 5, 2023

Our time interval math expressions were originally represented in a class called
SqlTimeDeltaExpression. There were two issues with this:

  1. The class does not represent a time delta. It represents an interval subtraction
    from an input time value.
  2. The class includes an unused parameter called grain_to_date, which would change
    it's behavior from rendering an interval subtraction to rendering date_trunc

This PR addresses both of these, and improves some of the documentation and class
labeling properties as part of these updates.

tlento added 3 commits October 4, 2023 18:34
The original implementation of SqlTimeDeltaExpression had a custom
override for grain_to_date intended to support cumulative metrics.
This parameter would change the expression from a time delta to a
date_trunc. At some point we cleaned up the callsites to invoke
date_trunc directly instead of offloading this work to an overloaded
class.

This commit simply removes the confusing parameter in order to streamline
the expression rendering for time delta operations.
The original name for this class was misleading, as a time delta is
effectively an interval computed as a difference. This suggested either
that the rendering should be a date_diff to produce an interval between
two timestamps, or that it should be an interval expression for use
in some other operation.

In reality, this class provides the functionality of a date_subtract,
where we subtract an interval value from a given input timestamp.
We had a couple of copy/paste issues with sql expression nodes
identifying themselves as IS_NULL expressions. This tidies that up.
@cla-bot cla-bot bot added the cla:yes label Oct 5, 2023
Copy link
Contributor Author

tlento commented Oct 5, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@github-actions
Copy link

github-actions bot commented Oct 5, 2023

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@tlento tlento requested a review from plypaul October 5, 2023 18:46
@tlento tlento merged commit 385465d into main Oct 5, 2023
33 of 35 checks passed
@tlento tlento deleted the clean-up-sql-time-interval-math-expression branch October 5, 2023 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants