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

SQL: Implement FORMAT function #54965

Open
matriv opened this issue Apr 8, 2020 · 9 comments
Open

SQL: Implement FORMAT function #54965

matriv opened this issue Apr 8, 2020 · 9 comments

Comments

@matriv
Copy link
Contributor

@matriv matriv commented Apr 8, 2020

Implement FORMAT according to the SQL Server spec: https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-ver15#ExampleD by translating to the java.time patterns used in DATETIME_FORMAT.

Follows: #54832

@elasticmachine
Copy link
Collaborator

@elasticmachine elasticmachine commented Apr 8, 2020

Pinging @elastic/es-ql (:Query Languages/SQL)

@binu-r
Copy link

@binu-r binu-r commented Apr 10, 2020

Hi, Can I start working on this?

@matriv
Copy link
Contributor Author

@matriv matriv commented Apr 10, 2020

@binu-r You' re welcome to do so, thank you!

@aarush00
Copy link

@aarush00 aarush00 commented Apr 10, 2020

hi my name is Aarush Chopra and I use elastic search bundled with Redis, because I want to learn internal of es I want to contribute to the project. Please assign me some task and some guidance will be appreciated.

@matriv
Copy link
Contributor Author

@matriv matriv commented Apr 10, 2020

@aarush00 Please pick another issue labeled as good first issue, as this has already been picked up by another contributor.

@binu-r
Copy link

@binu-r binu-r commented Apr 11, 2020

By referring to DotNet Date Format Strings, here are the list of replacements in Java Date Format Strings

Description Dot Net Java
AM/PM “tt” "a"
AM/PM "t" "a"
Day of week (Saturday) "dddd" "eeee"
Day of week (Sat) "ddd" "eee"
Time Zone ID "K" "v"
era(AD) "g" "G"
fraction-of-second "f" "S"

Remaining strings will be used as such from input
Shall I proceed with that conversion.

@matriv
Copy link
Contributor Author

@matriv matriv commented Apr 11, 2020

@binu-r
Copy link

@binu-r binu-r commented Apr 11, 2020

@matriv
Thanks for sharing the links. They particularly mention about how to convert strings to date or time. But we want to convert date/time to string format.

I checked DotNet format because it is mentioned in the format function specification by Microsoft.

Arguments
value
Expression of a supported data type to format. For a list of valid types, see the table in the following Remarks section.
format
nvarchar format pattern.
The format argument must contain a valid .NET Framework format string, either as a standard format string (for example, "C" or "D"), or as a pattern of custom characters for dates and numeric values (for example, "MMMM DD, yyyy (dddd)"). Composite formatting is not supported. For a full explanation of these formatting patterns, consult the .NET Framework documentation on string formatting in general, custom date and time formats, and custom number formats. A good starting point is the topic, "Formatting Types."
culture
Optional nvarchar argument specifying a culture.
If the culture argument is not provided, the language of the current session is used. This language is set either implicitly, or explicitly by using the SET LANGUAGE statement. culture accepts any culture supported by the .NET Framework as an argument; it is not limited to the languages explicitly supported by SQL Server. If the culture argument is not valid, FORMAT raises an error.

binu-r added a commit to binu-r/elasticsearch that referenced this issue Apr 18, 2020
Implement FORMAT according to the SQL Server spec: https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-ver15#ExampleD by translating to the java.time patterns used in DATETIME_FORMAT.

Relates to elastic#54965
binu-r added a commit to binu-r/elasticsearch that referenced this issue Apr 20, 2020
Implement FORMAT according to the SQL Server spec: https://docs.microsoft.com/en-us/sql/t-sql/functions/format-transact-sql?view=sql-server-ver15#ExampleD by translating to the java.time patterns used in DATETIME_FORMAT.

Relates to elastic#54965
@binu-r
Copy link

@binu-r binu-r commented Apr 21, 2020

@matriv please review PR #55454

@rjernst rjernst added the Team:QL label May 4, 2020
@binu-r binu-r removed their assignment Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.