Skip to content

Commit

Permalink
Spark: Add int long BigInteger cases for Decimal (ClickHouse#266)
Browse files Browse the repository at this point in the history
Co-authored-by: eye <eye.gu@aloudata.com>
  • Loading branch information
eye-gu and eye authored Aug 10, 2023
1 parent 4ea03f8 commit 821adcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class ClickHouseJsonReader(
Decimal(jsonNode.decimalValue, d.precision, d.scale)
case d: DecimalType if jsonNode.isFloat | jsonNode.isDouble =>
Decimal(BigDecimal(jsonNode.doubleValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType if jsonNode.isInt =>
Decimal(BigDecimal(jsonNode.intValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType if jsonNode.isLong =>
Decimal(BigDecimal(jsonNode.longValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType if jsonNode.isBigInteger =>
Decimal(BigDecimal(jsonNode.bigIntegerValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType =>
Decimal(BigDecimal(jsonNode.textValue, new MathContext(d.precision)), d.precision, d.scale)
case TimestampType =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ class ClickHouseJsonReader(
Decimal(jsonNode.decimalValue, d.precision, d.scale)
case d: DecimalType if jsonNode.isFloat | jsonNode.isDouble =>
Decimal(BigDecimal(jsonNode.doubleValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType if jsonNode.isInt =>
Decimal(BigDecimal(jsonNode.intValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType if jsonNode.isLong =>
Decimal(BigDecimal(jsonNode.longValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType if jsonNode.isBigInteger =>
Decimal(BigDecimal(jsonNode.bigIntegerValue, new MathContext(d.precision)), d.precision, d.scale)
case d: DecimalType =>
Decimal(BigDecimal(jsonNode.textValue, new MathContext(d.precision)), d.precision, d.scale)
case TimestampType =>
Expand Down

0 comments on commit 821adcc

Please sign in to comment.