You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "Mryange (via GitHub)" <gi...@apache.org> on 2023/06/15 11:32:10 UTC

[GitHub] [doris] Mryange opened a new pull request, #20863: [fix](datetime) Fix the error in date calculation that includes constants

Mryange opened a new pull request, #20863:
URL: https://github.com/apache/doris/pull/20863

   ## Proposed changes
   
   before
   
   ```
   mysql> select hours_add('2023-03-30 22:23:45.23452',8);
   +-------------------------------------+
   | hours_add('2023-03-30 22:23:45', 8) |
   +-------------------------------------+
   | 2023-03-31 06:23:45                 |
   +-------------------------------------+
   1 row in set (0.00 sec)
   
   mysql> select date_add('2023-03-30 22:23:45.23452',8);
   +------------------------------------+
   | date_add('2023-03-30 22:23:45', 8) |
   +------------------------------------+
   | 2023-04-07 22:23:45                |
   +------------------------------------+
   1 row in set (0.00 sec)
   ```
   <img width="928" alt="image" src="https://github.com/apache/doris/assets/59914473/d9088658-fadf-4894-9398-b47e2b050f92">
   
   
   after
   
   ```
   mysql [test]>select hours_add('2023-03-30 22:23:45.23452',8);
   +-------------------------------------------+
   | hours_add('2023-03-30 22:23:45.23452', 8) |
   +-------------------------------------------+
   | 2023-03-31 06:23:45.23452                 |
   +-------------------------------------------+
   1 row in set (0.01 sec)
   
   mysql [test]>select date_add('2023-03-30 22:23:45.23452',8);
   +------------------------------------------+
   | date_add('2023-03-30 22:23:45.23452', 8) |
   +------------------------------------------+
   | 2023-04-07 22:23:45.23452                |
   +------------------------------------------+
   1 row in set (0.00 sec)
   
   mysql [test]>set enable_nereids_planner=true;
   Query OK, 0 rows affected (0.00 sec)
   
   mysql [test]>set enable_fallback_to_original_planner=false;
   Query OK, 0 rows affected (0.00 sec)
   
   mysql [test]>select hours_add('2023-03-30 22:23:45.23452',8);
   +-------------------------------------------+
   | hours_add('2023-03-30 22:23:45.23452', 8) |
   +-------------------------------------------+
   | 2023-03-31 06:23:45.23452                 |
   +-------------------------------------------+
   1 row in set (0.03 sec)
   
   mysql [test]>select date_add('2023-03-30 22:23:45.23452',8);
   +------------------------------------------+
   | days_add('2023-03-30 22:23:45.23452', 8) |
   +------------------------------------------+
   | 2023-04-07 22:23:45.23452                |
   +------------------------------------------+
   1 row in set (0.00 sec)
   ```
   
   
   
   <!--Describe your changes.-->
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at [dev@doris.apache.org](mailto:dev@doris.apache.org) by explaining why you chose the solution you did and what alternatives you considered, etc...
   
   


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1596434492

   run p1


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on a diff in pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on code in PR #20863:
URL: https://github.com/apache/doris/pull/20863#discussion_r1233461748


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateTimeV2Type.java:
##########
@@ -78,6 +78,17 @@ public static DateTimeV2Type forType(DataType dataType) {
         return MAX;
     }
 
+    /**
+     * return proper type of datetimev2 for VarcharLiteral
+     * may be we need to check for validity?
+     */
+    public static DateTimeV2Type forTypeFromVarcharLiteral(String s) {

Review Comment:
   It has already been determined StringLikeLiteral, so it is unnecessary to check again.



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1595946949

   we need to copy all your describe in Proposed changes to git commit msg, so please replace all screenshot in commit msg with text, thx


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1594163425

   PR approved by anyone and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1594034386

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1592872003

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] github-actions[bot] commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1597379108

   PR approved by at least one committer and no changes requested.


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1596030846

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow merged pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

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


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1596396611

   run p1


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] morrySnow commented on a diff in pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "morrySnow (via GitHub)" <gi...@apache.org>.
morrySnow commented on code in PR #20863:
URL: https://github.com/apache/doris/pull/20863#discussion_r1233187919


##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/ComputeSignatureHelper.java:
##########
@@ -123,7 +124,13 @@ private static FunctionSignature defaultDateTimeV2PrecisionPromotion(
                 continue;
             }
             if (finalType == null) {
-                finalType = DateTimeV2Type.forType(arguments.get(i).getDataType());
+                if (arguments.get(i) instanceof VarcharLiteral) {

Review Comment:
   maybe u need use StringLikeLiteral



##########
fe/fe-core/src/main/java/org/apache/doris/nereids/types/DateTimeV2Type.java:
##########
@@ -78,6 +78,17 @@ public static DateTimeV2Type forType(DataType dataType) {
         return MAX;
     }
 
+    /**
+     * return proper type of datetimev2 for VarcharLiteral
+     * may be we need to check for validity?
+     */
+    public static DateTimeV2Type forTypeFromVarcharLiteral(String s) {

Review Comment:
   ```suggestion
       public static DateTimeV2Type forExpression(Expression e) {
           if (e instanceof StringLikeLiteral) {
               ....
           } else {
               return forType(e.getDataType());
           }
   ```



-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] sohardforaname commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "sohardforaname (via GitHub)" <gi...@apache.org>.
sohardforaname commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1594163003

   @morrySnow PTAL


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1593976611

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1593149866

   run buildall


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1596109151

   run p0


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org


[GitHub] [doris] Mryange commented on pull request #20863: [fix](datetime) Fix the error in date calculation that includes constants

Posted by "Mryange (via GitHub)" <gi...@apache.org>.
Mryange commented on PR #20863:
URL: https://github.com/apache/doris/pull/20863#issuecomment-1596333321

   run p0


-- 
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: commits-unsubscribe@doris.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org