You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "jackwener (via GitHub)" <gi...@apache.org> on 2023/04/11 09:54:57 UTC

[GitHub] [arrow-datafusion] jackwener opened a new pull request, #5960: fix: support data/timestamp minus

jackwener opened a new pull request, #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #5931 .
   
   # Rationale for this change
   
   support data/timestamp minus in type coercion.
   
   # What changes are included in this PR?
   
   Add test in slt.
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5960: fix: support data/timestamp minus

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960#discussion_r1162979516


##########
datafusion/core/tests/sqllogictests/test_files/dates.slt:
##########
@@ -88,3 +88,19 @@ h
 statement error DataFusion error: Error during planning: Timestamp\(Nanosecond, Some\("\+00:00"\)\) \+ Utf8 can't be evaluated because there isn't a common type to coerce the types to
 select i_item_desc from test
 where d3_date > now() + '5 days';
+
+# DATE minus DATE

Review Comment:
   Great, btw we already have `array_typeof.slt` which also covers some casts 



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] jackwener merged pull request #5960: fix: support `date - timestamp` and `timestamp - date`

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener merged PR #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] jackwener commented on pull request #5960: fix: support data/timestamp minus

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on PR #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960#issuecomment-1503389887

   cc @alamb @berkaysynnada 


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] comphead commented on a diff in pull request #5960: fix: support data/timestamp minus

Posted by "comphead (via GitHub)" <gi...@apache.org>.
comphead commented on code in PR #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960#discussion_r1162980537


##########
datafusion/core/tests/sqllogictests/test_files/timestamps.slt:
##########
@@ -660,6 +660,12 @@ statement error DataFusion error: Error during planning: Timestamp\(Nanosecond,
 SELECT ts1 + ts2
 FROM foo;
 
+# Timestamp - Timestamp
+query ?

Review Comment:
   Please add negative test if older date - newer date



##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -239,8 +238,7 @@ pub fn temporal_add_sub_coercion(
             if (is_date(lhs) || is_timestamp(lhs))
                 && (is_date(rhs) || is_timestamp(rhs)) =>
         {
-            // TODO: support Minus
-            None
+            temporal_coercion(lhs, rhs)

Review Comment:
   if the comment about error still relevant? 
   for `temporal_coercion` if it does the actual substract? 
   



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #5960: fix: support `date - timestamp` and `timestamp - date`

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960#discussion_r1163302309


##########
datafusion/core/tests/sqllogictests/test_files/timestamps.slt:
##########
@@ -660,6 +660,19 @@ statement error DataFusion error: Error during planning: Timestamp\(Nanosecond,
 SELECT ts1 + ts2
 FROM foo;
 
+# Timestamp - Timestamp
+query ?
+SELECT '2000-01-01T00:00:00'::timestamp - '2000-01-01T00:00:00'::timestamp;
+----
+0 years 0 mons 0 days 0 hours 0 mins 0.000000000 secs
+
+# large timestamp - small timestamp
+# Todo: Does it need to be fixed for negative values?.

Review Comment:
   I think negative values is correct and a valid interval. The intervals are signed according to the arrow spec:
   
   https://github.com/apache/arrow/blob/776ea3f4f3d665f38fc370d0f284760eafa7de45/format/Schema.fbs#L363-L384



##########
datafusion/expr/src/type_coercion/binary.rs:
##########
@@ -754,51 +751,6 @@ fn temporal_coercion(lhs_type: &DataType, rhs_type: &DataType) -> Option<DataTyp
     }
 }
 
-/// Coercion rule for numerical types: The type that both lhs and rhs

Review Comment:
   it is always nice to see a bug fixed by deleting code. Thank you @jackwener  👏 



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] jackwener commented on pull request #5960: fix: support `date - timestamp` and `timestamp - date`

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on PR #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960#issuecomment-1504469546

   Thanks everyone❤️


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] jackwener commented on a diff in pull request #5960: fix: support data/timestamp minus

Posted by "jackwener (via GitHub)" <gi...@apache.org>.
jackwener commented on code in PR #5960:
URL: https://github.com/apache/arrow-datafusion/pull/5960#discussion_r1162852864


##########
datafusion/core/tests/sqllogictests/test_files/dates.slt:
##########
@@ -88,3 +88,19 @@ h
 statement error DataFusion error: Error during planning: Timestamp\(Nanosecond, Some\("\+00:00"\)\) \+ Utf8 can't be evaluated because there isn't a common type to coerce the types to
 select i_item_desc from test
 where d3_date > now() + '5 days';
+
+# DATE minus DATE

Review Comment:
   I have a idea, maybe we can add a type_coercion.slt.
   I prepare to add it in next PR.



-- 
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: github-unsubscribe@arrow.apache.org

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