Skip to content

Clean up SQL time interval math expressions#796

Merged
tlento merged 3 commits intomainfrom
clean-up-sql-time-interval-math-expression
Oct 5, 2023
Merged

Clean up SQL time interval math expressions#796
tlento merged 3 commits intomainfrom
clean-up-sql-time-interval-math-expression

Conversation

@tlento
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

tlento commented Oct 5, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@github-actions
Copy link
Copy Markdown

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
@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