partiql / partiql-lang-kotlin

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

Changes INT/INTEGER to be an alias for INT4 #1473

Closed RCHowell closed 1 month ago

RCHowell commented 1 month ago

Relevant Issues

1471

Description

Details are in the linked issue. Effectively this PR makes INT an alias for INT4. Today, the typing and handling of the 32-bit integer is covered by INT4, but we have (for historical reasons) had INT as the Ion unbounded integer. This has created a situation in which INT != INT4 and INT has no precision whereas BIGINT does; therefore BIGINT < INT.

The other systems we integrate with all have INT = INT4 because SQL dictates you must have a bound precision for the INTEGER type and pretty much every implementation uses 32-bit precision.

Update

SMALLINT    -> 16-bit
INT         -> 32-bit
BIGINT      -> 64-bit

Now, this PR is a somewhat sly half-measure by making INT an alias to INT4 so that I don't have to change any planning/typing logic. John is working on updates to typing logic now, so I've simply made a tiny parser change. For version 1.0 we will flip this and make INT4 an alias for INT.

For the unbounded integer in other systems, we use DECIMAL(38,0) as this is typically the maximum size (e.g. Presto, Snowflake, SQL Server, Impala) but some allow higher precision (postgres).

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.