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

Date literal as @ notation #416

Merged
merged 4 commits into from Apr 25, 2022
Merged

Date literal as @ notation #416

merged 4 commits into from Apr 25, 2022

Conversation

saig0
Copy link
Member

@saig0 saig0 commented Apr 22, 2022

Description

  • support the new @ - notation for temporal values (e.g. @"2022-04-22")
  • the new notation is equal to the existing notation using the temporal functions (e.g. date("2022-04-22"))
  • update the docs and mention the new notation

Note that I used the existing parser capabilities for temporal values to keep the changes small. At some point, we should refactor how temporal values are parsed. But not now 😅

Related issues

closes #297

Copy link
Contributor

@remcowesterhoud remcowesterhoud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good @saig0! 🚀

I have some very minor suggestions for the documentation. But I'm mostly interested in the question I asked 😄

Comment on lines 414 to 417
P(
("duration" | "date and time" | "date" | "time").! ~ "(" ~ stringWithQuotes ~ ")"
(("duration" | "date and time" | "date" | "time").! ~ "(" ~ stringWithQuotes ~ ")") |
("@".! ~ stringWithQuotes)
).map {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Just verifying I understand what this does correctly. I'm not sure what the P is, but it seems to be part of some parsing library (and it's different from the generic P used in the function definition).

I suppose it is matching an input string to see if it contains either duration, date and time, date or time followed by a string with quotes between parentheses. E.g. duration("P1Y").
Or it contains an @ followed by a string with quotes. E.g. @"P1Y".

I'm not sure what this P function returns but we match this against the temporal and find the correct parsing function for it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can read more about the underlying parser library here: https://com-lihaoyi.github.io/fastparse/
The docs are nicely written. But I'm also happy to talk about it and how it is used in the FEEL engine. Just ping me 🛎️

docs/docs/reference/language-guide/feel-data-types.md Outdated Show resolved Hide resolved
docs/docs/reference/language-guide/feel-data-types.md Outdated Show resolved Hide resolved
docs/docs/reference/language-guide/feel-data-types.md Outdated Show resolved Hide resolved
@saig0 saig0 merged commit 8552b02 into master Apr 25, 2022
@saig0 saig0 deleted the 297-temporal branch April 25, 2022 03:50
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

Successfully merging this pull request may close these issues.

Date literal as @ notation
2 participants