Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

[util] Explicitly test for BigDecimals in real-number? (#65202)

Oleksandr Yakushev6d1d618fffc9
diff --git a/src/metabase/util.cljc b/src/metabase/util.cljc
index 41167022fe3..4803f448c91 100644
--- a/src/metabase/util.cljc
+++ b/src/metabase/util.cljc
@@ -440,9 +440,12 @@
(defn real-number?
"Is `x` a real number (i.e. not a `NaN` or an `Infinity`)?"
[x]
- (and (number? x)
- (not (NaN? x))
- (not (infinite? x))))
+ ;; Check for BigDec explicitly. BigDec cannot be nan or infinite, but using those predicates on bigdec with higher
+ ;; precision may allocate.
+ (or #?(:clj (decimal? x) :default false)
+ (and (number? x)
+ (not (NaN? x))
+ (not (infinite? x)))))
(defn remove-diacritical-marks
"Return a version of `s` with diacritical marks removed."