You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "kanha-gupta (via GitHub)" <gi...@apache.org> on 2023/03/09 15:53:31 UTC

[GitHub] [shardingsphere] kanha-gupta opened a new pull request, #24532: support for CAST Function

kanha-gupta opened a new pull request, #24532:
URL: https://github.com/apache/shardingsphere/pull/24532

   Fixes #24398 .
   
   Changes proposed in this pull request:
    Added support for this in ANTLR :
   [CAST(timestamp_value AT TIME ZONE timezone_specifier AS DATETIME[(precision)])]
   (https://dev.mysql.com/doc/refman/8.0/en/cast-functions.html#function_cast)
   
   
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] kanha-gupta commented on pull request #24532: support for CAST Function

Posted by "kanha-gupta (via GitHub)" <gi...@apache.org>.
kanha-gupta commented on PR #24532:
URL: https://github.com/apache/shardingsphere/pull/24532#issuecomment-1466741814

   @RaigorJiang @strongduanmu Hello !
   Please review it :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] codecov-commenter commented on pull request #24532: support for CAST Function

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #24532:
URL: https://github.com/apache/shardingsphere/pull/24532#issuecomment-1467774911

   ## [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#24532](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0475b20) into [master](https://codecov.io/gh/apache/shardingsphere/commit/134a24a80df9ef1ec959ea217db8cfd6a6f4cc2f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (134a24a) will **decrease** coverage by `0.21%`.
   > The diff coverage is `62.77%`.
   
   > :exclamation: Current head 0475b20 differs from pull request most recent head e948300. Consider uploading reports for the commit e948300 to get more accurate results
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #24532      +/-   ##
   ============================================
   - Coverage     50.22%   50.01%   -0.21%     
   - Complexity     1588     1597       +9     
   ============================================
     Files          3270     3330      +60     
     Lines         53705    54455     +750     
     Branches       9884    10014     +130     
   ============================================
   + Hits          26971    27235     +264     
   - Misses        24323    24792     +469     
   - Partials       2411     2428      +17     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...shardingsphere/agent/core/ShardingSphereAgent.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YWdlbnQvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9TaGFyZGluZ1NwaGVyZUFnZW50LmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...ore/advisor/config/AdvisorConfigurationLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YWdlbnQvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9hZHZpc29yL2NvbmZpZy9BZHZpc29yQ29uZmlndXJhdGlvbkxvYWRlci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...gin/tracing/core/advice/TracingRootSpanAdvice.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YWdlbnQvcGx1Z2lucy90cmFjaW5nL2NvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2FnZW50L3BsdWdpbi90cmFjaW5nL2NvcmUvYWR2aWNlL1RyYWNpbmdSb290U3BhbkFkdmljZS5qYXZh) | `0.00% <ø> (ø)` | |
   | [...re/agent/plugin/tracing/TracingAgentExtension.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YWdlbnQvcGx1Z2lucy90cmFjaW5nL3Rlc3Qvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2FnZW50L3BsdWdpbi90cmFjaW5nL1RyYWNpbmdBZ2VudEV4dGVuc2lvbi5qYXZh) | `0.00% <ø> (ø)` | |
   | [...ser/core/kernel/KernelDistSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGlzdHNxbC9wYXJzZXIvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2Rpc3RzcWwvcGFyc2VyL2NvcmUva2VybmVsL0tlcm5lbERpc3RTUUxTdGF0ZW1lbnRWaXNpdG9yLmphdmE=) | `5.15% <0.00%> (-0.06%)` | :arrow_down: |
   | [...ent/ral/queryable/ExportStorageNodesStatement.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZGlzdHNxbC9zdGF0ZW1lbnQvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2Rpc3RzcWwvcGFyc2VyL3N0YXRlbWVudC9yYWwvcXVlcnlhYmxlL0V4cG9ydFN0b3JhZ2VOb2Rlc1N0YXRlbWVudC5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...ator/EncryptPredicateRightValueTokenGenerator.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvZW5jcnlwdC9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9lbmNyeXB0L3Jld3JpdGUvdG9rZW4vZ2VuZXJhdG9yL0VuY3J5cHRQcmVkaWNhdGVSaWdodFZhbHVlVG9rZW5HZW5lcmF0b3IuamF2YQ==) | `44.89% <0.00%> (-6.27%)` | :arrow_down: |
   | [...etadata/data/ShardingStatisticsTableCollector.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvc2hhcmRpbmcvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc2hhcmRpbmcvbWV0YWRhdGEvZGF0YS9TaGFyZGluZ1N0YXRpc3RpY3NUYWJsZUNvbGxlY3Rvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...rewrite/condition/impl/EncryptBinaryCondition.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvZW5jcnlwdC9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9lbmNyeXB0L3Jld3JpdGUvY29uZGl0aW9uL2ltcGwvRW5jcnlwdEJpbmFyeUNvbmRpdGlvbi5qYXZh) | `44.11% <9.09%> (-16.76%)` | :arrow_down: |
   | [...s/prometheus/PrometheusPluginLifecycleService.java](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YWdlbnQvcGx1Z2lucy9tZXRyaWNzL3R5cGUvcHJvbWV0aGV1cy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvcGx1Z2luL21ldHJpY3MvcHJvbWV0aGV1cy9Qcm9tZXRoZXVzUGx1Z2luTGlmZWN5Y2xlU2VydmljZS5qYXZh) | `64.51% <50.00%> (-7.49%)` | :arrow_down: |
   | ... and [20 more](https://codecov.io/gh/apache/shardingsphere/pull/24532?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ... and [201 files with indirect coverage changes](https://codecov.io/gh/apache/shardingsphere/pull/24532/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #24532: support for CAST Function

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu commented on code in PR #24532:
URL: https://github.com/apache/shardingsphere/pull/24532#discussion_r1134743494


##########
sql-parser/dialect/mysql/src/main/antlr4/imports/mysql/BaseRule.g4:
##########
@@ -1002,8 +1002,9 @@ repairType
     
 castFunction
     : CAST LP_ expr AS dataType RP_
+    | CAST LP_ expr AT TIME ZONE expr AS dataType RP_
     ;
-    

Review Comment:
   Please keep the indent.
   



##########
sql-parser/dialect/mysql/src/main/java/org/apache/shardingsphere/sql/parser/mysql/visitor/statement/impl/MySQLStatementSQLVisitor.java:
##########
@@ -887,13 +887,14 @@ public final ASTNode visitWindowFunction(final WindowFunctionContext ctx) {
     
     @Override
     public final ASTNode visitCastFunction(final CastFunctionContext ctx) {
-        calculateParameterCount(Collections.singleton(ctx.expr()));
+        calculateParameterCount(ctx.expr());
         FunctionSegment result = new FunctionSegment(ctx.getStart().getStartIndex(), ctx.getStop().getStopIndex(), ctx.CAST().getText(), getOriginalText(ctx));
-        ASTNode exprSegment = visit(ctx.expr());
-        if (exprSegment instanceof ColumnSegment) {
-            result.getParameters().add((ColumnSegment) exprSegment);
-        } else if (exprSegment instanceof LiteralExpressionSegment) {
-            result.getParameters().add((LiteralExpressionSegment) exprSegment);
+        for (ExprContext each : ctx.expr()) {
+            if (visit(each) instanceof ColumnSegment) {

Review Comment:
   Please extract `visit(each)` to a local param.



##########
test/it/parser/src/main/resources/sql/unsupported/unsupported.xml:
##########
@@ -24,7 +24,6 @@
     <sql-case id="assert_dist_SQL_show_rule_parse_conflict" value="SHOW REPLICA_QUERY RULE FROM schema_name" />
     <sql-case id="with_select" value="WITH cte AS (SELECT 0 /*! ) */ SELECT * FROM cte a, cte b;" db-types="MySQL" />
     <sql-case id="with_select_comment" value="WITH cte AS /*! ( */ SELECT 0) SELECT * FROM cte a, cte b;" db-types="MySQL" />
-    <sql-case id="select_cast" value="SELECT cast( NULL AT TIME ZONE 'UTC' AS DATETIME );" db-types="MySQL" />

Review Comment:
   Please add sql parse test case for MySQL `cast` function.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu merged pull request #24532: support for CAST Function

Posted by "strongduanmu (via GitHub)" <gi...@apache.org>.
strongduanmu merged PR #24532:
URL: https://github.com/apache/shardingsphere/pull/24532


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] kanha-gupta closed pull request #24532: support for CAST Function

Posted by "kanha-gupta (via GitHub)" <gi...@apache.org>.
kanha-gupta closed pull request #24532: support for CAST Function
URL: https://github.com/apache/shardingsphere/pull/24532


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] kanha-gupta commented on pull request #24532: support for CAST Function

Posted by "kanha-gupta (via GitHub)" <gi...@apache.org>.
kanha-gupta commented on PR #24532:
URL: https://github.com/apache/shardingsphere/pull/24532#issuecomment-1462305640

   @RaigorJiang Hey, please review :) 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] kanha-gupta commented on pull request #24532: support for CAST Function

Posted by "kanha-gupta (via GitHub)" <gi...@apache.org>.
kanha-gupta commented on PR #24532:
URL: https://github.com/apache/shardingsphere/pull/24532#issuecomment-1467751798

   @strongduanmu Thank you for reviewing.
   I have made changes, Please have a look.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] RaigorJiang commented on pull request #24532: support for CAST Function

Posted by "RaigorJiang (via GitHub)" <gi...@apache.org>.
RaigorJiang commented on PR #24532:
URL: https://github.com/apache/shardingsphere/pull/24532#issuecomment-1467861998

   > @RaigorJiang @strongduanmu Thank you for reviewing. I have made changes, Please have a look.
   
   LGTM.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org