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

Add typeof function. #867

Merged
merged 6 commits into from
Oct 20, 2022
Merged

Conversation

Yury-Fridlyand
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand commented Sep 29, 2022

Signed-off-by: Yury-Fridlyand yuryf@bitquilltech.com

Description

TYPEOF function is useful for debugging to check types of other functions. Extremely useful for testing and debugging upcoming PRs with datetime functions.
Not added to documentation, because it is not supposed for an end user.
See team review discussion in Bit-Quill#123.

Usage

opensearchsql> SELECT typeof(DATETIME('1961-04-12 09:07:00')), typeof(CAST('1961-04-12 09:07:00' AS TIMESTAMP)), typeof(CAST('09:07:00' AS TIME)), typeof(CAST('1961-04-12' AS DATE));
Output longer than terminal width
Do you want to display data vertically for better visual effect? [y/N]: y
fetched rows / total rows = 1/1
-[ RECORD 1 ]-------------------------
typeof(DATETIME('1961-04-12 09:07:00')           | DATETIME
typeof(CAST('1961-04-12 09:07:00' AS TIMESTAMP)) | TIMESTAMP
typeof(CAST('09:07:00' AS TIME))                 | TIME
typeof(CAST('1961-04-12' AS DATE))               | DATE

UPD

TYPEOF function perfectly works with SQL types. It works with some OpenSearch (OpenSearchDataType) types, which could be implicitly casted to SQL ones. Unfortunately, function can't accept OpenSearch types, so some information lost.
IP, GEO_POINT, BINARY and NESTED types cause crash.
https://github.com/Bit-Quill/opensearch-project-sql/blob/d02e16f147a9f3e6afa065f701efa7ece70d310b/opensearch/src/main/java/org/opensearch/sql/opensearch/data/type/OpenSearchDataType.java#L49-L53

Check List

  • New functionality includes testing.
    • All tests pass, including unit test, integration test and doctest
  • New functionality has been documented.
    • New functionality has javadoc added
    • New functionality has user manual doc added
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
MaxKsyunz
MaxKsyunz previously approved these changes Sep 29, 2022
@dai-chen dai-chen added enhancement New feature or request SQL PPL Piped processing language labels Sep 29, 2022
* Move function definition in ANTLR grammar into a separate group;
* Move SQL integration tests outside of legacy block;
* Extend integration tests.

Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand marked this pull request as draft October 5, 2022 03:40
…ssion`. It is able to recognize `OpenSearchDataType` as well.

Co-authored-by: MaxKsyunz <maxk@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand marked this pull request as ready for review October 5, 2022 21:45
acarbonetto
acarbonetto previously approved these changes Oct 12, 2022
dai-chen
dai-chen previously approved these changes Oct 13, 2022
Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

Just a minor comment. Thanks for the changes!

Btw, do we want to add this to user manual like PGSQL? Doc: https://www.postgresql.org/docs/current/functions-info.html

Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
Signed-off-by: Yury-Fridlyand <yuryf@bitquilltech.com>
@Yury-Fridlyand Yury-Fridlyand dismissed stale reviews from dai-chen and acarbonetto via b4dc828 October 19, 2022 18:28
@Yury-Fridlyand
Copy link
Collaborator Author

Just a minor comment. Thanks for the changes!

Btw, do we want to add this to user manual like PGSQL? Doc: https://www.postgresql.org/docs/current/functions-info.html

Added in b4dc828.

@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.10%. Comparing base (3ca6450) to head (b4dc828).
Report is 540 commits behind head on 2.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                2.x     #867      +/-   ##
============================================
- Coverage     97.85%   95.10%   -2.75%     
- Complexity     2989     3075      +86     
============================================
  Files           281      304      +23     
  Lines          7357     8258     +901     
  Branches        467      609     +142     
============================================
+ Hits           7199     7854     +655     
- Misses          157      350     +193     
- Partials          1       54      +53     
Flag Coverage Δ
query-workbench 62.76% <ø> (?)
sql-engine 97.90% <100.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@dai-chen dai-chen left a comment

Choose a reason for hiding this comment

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

Thanks for the changes!

@dai-chen dai-chen merged commit 1f2e881 into opensearch-project:2.x Oct 20, 2022
@Yury-Fridlyand Yury-Fridlyand deleted the integ-add-typeof branch November 16, 2022 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request PPL Piped processing language SQL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants