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

[GitHub] [arrow] zeroshade commented on a diff in pull request #35165: GH-35164: [Go] Additional methods for decimal data types

zeroshade commented on code in PR #35165:
URL: https://github.com/apache/arrow/pull/35165#discussion_r1168779905


##########
go/arrow/decimal128/decimal128.go:
##########
@@ -332,10 +332,12 @@ func (n Num) BigInt() *big.Int {
 	return toBigIntPositive(n)
 }
 
+// Greater returns true if the value represented by n is > other
 func (n Num) Greater(other Num) bool {
-	return other.Less(n)
+	return n.hi > other.hi || (n.hi == other.hi && n.lo > other.lo)

Review Comment:
   why this change? Was this producing incorrect results? 
   
   `n > other` should be equivalent to `other < n`



##########
go/arrow/decimal256/decimal256.go:
##########
@@ -365,14 +365,25 @@ func (n Num) BigInt() *big.Int {
 	return toBigIntPositive(n)
 }
 
+// Greater returns true if the value represented by n is > other
 func (n Num) Greater(other Num) bool {
-	return other.Less(n)
+	switch {
+	case n.arr[3] != other.arr[3]:
+		return int64(n.arr[3]) > int64(other.arr[3])
+	case n.arr[2] != other.arr[2]:
+		return n.arr[2] > other.arr[2]
+	case n.arr[1] != other.arr[1]:
+		return n.arr[1] > other.arr[1]
+	}
+	return n.arr[0] > other.arr[0]
 }

Review Comment:
   same questions as for decimal128, why this change? they should be equivalent (and should get inlined by the compiler)



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