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

Merging #867 (b4dc828) into 2.x (3ca6450) will decrease coverage by 2.74%.
The diff coverage is 100.00%.

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

Impacted Files Coverage Δ
...c/main/java/org/opensearch/sql/expression/DSL.java 100.00% <100.00%> (ø)
...search/sql/expression/config/ExpressionConfig.java 100.00% <100.00%> (ø)
...h/sql/expression/function/BuiltinFunctionName.java 100.00% <100.00%> (ø)
...nsearch/sql/expression/system/SystemFunctions.java 100.00% <100.00%> (ø)
...main/java/org/opensearch/sql/utils/ParseUtils.java 100.00% <0.00%> (ø)
...ain/java/org/opensearch/sql/analysis/Analyzer.java 100.00% <0.00%> (ø)
...java/org/opensearch/sql/ppl/parser/AstBuilder.java 100.00% <0.00%> (ø)
...org/opensearch/sql/analysis/HighlightAnalyzer.java 100.00% <0.00%> (ø)
...opensearch/sql/expression/HighlightExpression.java 100.00% <0.00%> (ø)
... and 33 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? 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.

None yet

5 participants