comphead commented on code in PR #22174:
URL: https://github.com/apache/datafusion/pull/22174#discussion_r3243831020


##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -592,38 +592,39 @@ impl PartialOrd for ScalarValue {
         // any newly added enum variant will require editing this list
         // or else face a compile error
         match (self, other) {
-            (Decimal32(v1, p1, s1), Decimal32(v2, p2, s2)) => {
-                if p1.eq(p2) && s1.eq(s2) {
+            (Decimal32(v1, _, s1), Decimal32(v2, _, s2)) => {
+                if s1.eq(s2) {
+                    // Same scale means the underlying integer values share
+                    // a common interpretation regardless of declared
+                    // precision (arithmetic such as `add_checked` widens
+                    // precision by 1 but does not change the numeric
+                    // meaning).
                     v1.partial_cmp(v2)
                 } else {
-                    // Two decimal values can be compared if they have the 
same precision and scale.
                     None

Review Comment:
   Thanks @nuno-faria would you mind to clarify. if I understood the comments 
correctly I jotted a decimal compare query with diff scales and it worked
   
   ```
   > SELECT cast(1.50 as decimal(10, 2)) > cast(1 as decimal(10, 0));
   +-------------------------+
   | Float64(1.5) > Int64(1) |
   +-------------------------+
   | true                    |
   +-------------------------+
   1 row(s) fetched. 
   Elapsed 0.017 seconds.
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to