Skip to content

Add support for BigDecimal as a Pinot data type #8418

@nizarhejazi

Description

@nizarhejazi

Pinot currently support storing BigDecimal as byte[], and a couple inbuilt scalar functions for converting a string to BigDecimal bytes and converting BigDecimal bytes to strings:

byte[] bigDecimalToBytes(String number)
String bytesToBigDecimal(byte[] bytes)

There is also support for sum aggregation with precision and scale: SUMPRECISION(expression, precision, scale).

Pinot supports BigDecimal with an arbitrary precision integer unscaled value, and a 16-bit integer scale (instead of 32-bit integer scale supported by java.math.BigDecimal class). Data types are defined inside an enum (enum ObjectType) which makes BigDecimal not configurable.

There is a need to support BigDecimal data type in Pinot so clients (e.g. Presto, Trino, etc.) can map Pinot's BigDecimal to the equivalent supported data type.

Please note that Presto/Trino supports a fixed precision decimal number (up to 38 digits). One possible way to map Pinot's representation of BigDecimal to Trino is similar to how Trino handles Postgres decimal type:

  • The scale of the resulting type is controlled via the decimal-default-scale configuration property or the decimal-rounding-mode session property.
  • The precision is always 38.

The ask is to support BigDecimal in:

  • SELECT statement.
  • DISTINCT statement.
  • ORDER BY statement.
  • GROUP BY statement.
  • HAVING statement.
  • CASE statement.
  • CAST transform.
  • Groovy transform.
  • Identifier transform.
  • Literal transform.
  • Lookup transform.
  • JsonPathEvaluator (w/ custom ObjectMapper and JsonNodeFactory).
  • JsonExtractScalar transform.
  • Addition, Subtraction, Multiplication, and Division.
  • abs(), ceil(), and floor() math functions.
  • Greatest, and Least transforms.
  • EQUAL, NOT_EQUAL, IN, NOT_IN, RANGE predicates.
  • NoDictionary based EQUAL, NOT_EQUAL and IN predicates.
  • Binary operators (=, !=, >=, >, <=, <).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions