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

Implementation of temporal type and operators #316

Open
8 tasks
hadrienk opened this issue Apr 2, 2024 · 5 comments
Open
8 tasks

Implementation of temporal type and operators #316

hadrienk opened this issue Apr 2, 2024 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@hadrienk
Copy link
Collaborator

hadrienk commented Apr 2, 2024

Type system:

  • Type mapping
    • time
      • date - java.time.Instant
      • time_period - java.time.Instant + java.time.Instant / java.time.Instant + java.time.Period?
    • duration - java.time.Period
  • Serialization/Deserialization examples
  • Timezone gotchas
  • Operators

Notes:
The manual points out that the time is the root time, and represents time interval (start, end). It should support shift, mutation of start / end values, split and so on.

The date is defined as a time with start = end.

The time period is a "non-overlapping time interval" with a "regular duration". The regular duration is only relevant for months (varying number of days) and days (timeshifts). It seems the intent is to represent duration in time, such as 2018W1 (first week of 2018) or 2020Q1 (first quarter of 2020).

@hadrienk hadrienk self-assigned this Apr 2, 2024
@hadrienk
Copy link
Collaborator Author

hadrienk commented Apr 4, 2024

Using the threeten-extra (additional date-time classes that complement those in Java SE 8.) the mapping can be as follow:

date -> java.time.Instant
time_period -> Interval
duration -> PeriodDuration

This simplify the parsing of ISO_8601 format.

@hadrienk
Copy link
Collaborator Author

hadrienk commented Apr 4, 2024

Test case:

d1 := cast("P1Y2M10DT2H30M", duration);
d2 := cast("P1Y15M2DT086401S", duration);
p1 := cast("2015-03-03T09:30:45Z/2018-04-05T12:30:15Z", time_period);
p2 := cast("2007-03-01T13:00:00Z/P1Y2M10DT2H30M", time_period);
p3 := cast("P1Y2M10DT2H30M/2008-05-11T15:30:00Z", time_period);

The truncated representation of period is left unimplemented as it seems to be deprecated

p3 := cast("P1Y2M10DT2H30M/2008-05-11T15:30:00Z", time_period);

@hadrienk
Copy link
Collaborator Author

The temporal functions are defined in the grammar as follow:

timeOperators:
    PERIOD_INDICATOR LPAREN expr? RPAREN                                                                                                # periodAtom
    | FILL_TIME_SERIES LPAREN expr (COMMA (SINGLE|ALL))? RPAREN                                                                         # fillTimeAtom
    | op=(FLOW_TO_STOCK | STOCK_TO_FLOW) LPAREN expr RPAREN	                                                                            # flowAtom
    | TIMESHIFT LPAREN expr COMMA signedInteger RPAREN                                                                                  # timeShiftAtom
    | TIME_AGG LPAREN periodIndTo=STRING_CONSTANT (COMMA periodIndFrom=(STRING_CONSTANT| OPTIONAL ))? (COMMA op=optionalExpr)? (COMMA (FIRST|LAST))? RPAREN     # timeAggAtom
    | CURRENT_DATE LPAREN RPAREN

Turning normal function invocations into special case with untyped parameters.

@hadrienk
Copy link
Collaborator Author

In order to handle time_agg, the group all needs to be implemented. The group all only supports one expression. This is surprising as one might want to use other expressions to adjust the groups (contat, split, math, etc)

@hadrienk
Copy link
Collaborator Author

In order to handle time_agg, the group all needs to be implemented. The group all only supports one expression. This is surprising as one might want to use other expressions to adjust the groups (contat, split, math, etc)

Even worse, what should be the name of the new column that the group all uses? Using convention here requires evaluating the expression itself.

@NicoLaval NicoLaval added the enhancement New feature or request label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants