partiql / partiql-lang-kotlin

PartiQL libraries and tools in Kotlin.
https://partiql.org/
Apache License 2.0
536 stars 60 forks source link

Adds support for parameterized decimal cast #1483

Closed RCHowell closed 3 weeks ago

RCHowell commented 3 weeks ago

Relevant Issues

974

Description

Today the planner only has a cast_decimal(v) function which is used in coercions but does not support parameters. This PR adds cast_decimal(v, p, s) along with using the parameters in typing judgements.

CAST(v AS DECIMAL)      -- arbitrary precision/scale decimal
CAST(v AS DECIMAL(P))   -- decimal with precision = P and scale = 0
CAST(v AS DECIMAL(P,S)) -- decimal with precision = P and scale = S
-- | AST                        | Plan
--------------------------------|----------------------
CAST(v AS DECIMAL)           -- | cast_decimal(v)
CAST(v AS DECIMAL(P))        -- | cast_decimal(v, P, 0)
CAST(v AS DECIMAL(P,S))      -- | cast_decimal(v, P, S)

Other Information

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.