You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2026/03/19 05:17:42 UTC
(spark-connect-swift) branch main updated: [SPARK-56072] Use `Decimal` constructor instead of `pow`
This is an automated email from the ASF dual-hosted git repository.
dongjoon pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/spark-connect-swift.git
The following commit(s) were added to refs/heads/main by this push:
new f9b4f32 [SPARK-56072] Use `Decimal` constructor instead of `pow`
f9b4f32 is described below
commit f9b4f32784c854ca3fdccd123adcf34462990fcc
Author: Dongjoon Hyun <do...@apache.org>
AuthorDate: Wed Mar 18 22:17:35 2026 -0700
[SPARK-56072] Use `Decimal` constructor instead of `pow`
### What changes were proposed in this pull request?
This PR replaces `pow` function usage with `Decimal` constructor's `exponent` parameter in `Decimal128Array`.
### Why are the changes needed?
Using `Decimal`'s built-in `exponent` parameter is more idiomatic and efficient than using `pow` followed by division. This eliminates an unnecessary division operation by directly constructing the scaled `Decimal` value.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Pass the existing CI.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: `Gemini 3.1 Pro (High)` on `Antigravity`.
Closes #320 from dongjoon-hyun/SPARK-56072.
Authored-by: Dongjoon Hyun <do...@apache.org>
Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
Sources/SparkConnect/ArrowArray.swift | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Sources/SparkConnect/ArrowArray.swift b/Sources/SparkConnect/ArrowArray.swift
index 0f9a0b8..ef9e1d6 100644
--- a/Sources/SparkConnect/ArrowArray.swift
+++ b/Sources/SparkConnect/ArrowArray.swift
@@ -269,7 +269,7 @@ public class Decimal128Array: FixedArray<Decimal> {
let byteOffset = self.arrowData.stride * Int(index)
let value = self.arrowData.buffers[1].rawPointer.advanced(by: byteOffset).load(
as: UInt64.self)
- return Decimal(value) / pow(10, Int(scale))
+ return Decimal(sign: .plus, exponent: -Int(scale), significand: Decimal(value))
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org