Skip to content

Commit d04d3dc

Browse files
committed
Changes INT/INTEGER to be an alias for INT4 (#1473)
1 parent 005dbce commit d04d3dc

File tree

5 files changed

+12
-6
lines changed

5 files changed

+12
-6
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Thank you to all who have contributed!
2828
### Added
2929

3030
### Changed
31+
- **Behavioral change**: The `INTEGER/INT` type is now an alias to the `INT4` type. Previously the INTEGER type was
32+
unconstrained which is not SQL-conformant and is causing issues in integrating with other systems. This release makes
33+
INTEGER an alias for INT4 which is the internal type name. In a later release, we will make INTEGER the default 32-bit
34+
integer with INT/INT4/INTEGER4 being aliases per other systems. This change only applies to
35+
org.partiql.parser.PartiQLParser, not the org.partiql.lang.syntax.PartiQLParser.
3136

3237
### Deprecated
3338

partiql-lang/src/test/kotlin/org/partiql/lang/syntax/PartiQLParserTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3998,6 +3998,7 @@ class PartiQLParserTest : PartiQLParserTestBase() {
39983998
)
39993999

40004000
@Test
4001+
@Ignore("This test is disabled while the new parser uses INT as an INT4 alias whereas the older parser does not.")
40014002
fun createTableWithConstraints() = assertExpression(
40024003
"""
40034004
CREATE TABLE Customer (

partiql-parser/src/main/kotlin/org/partiql/parser/internal/PartiQLParserDefault.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ import org.partiql.ast.typeDate
183183
import org.partiql.ast.typeDecimal
184184
import org.partiql.ast.typeFloat32
185185
import org.partiql.ast.typeFloat64
186-
import org.partiql.ast.typeInt
187186
import org.partiql.ast.typeInt2
188187
import org.partiql.ast.typeInt4
189188
import org.partiql.ast.typeInt8
@@ -2051,9 +2050,10 @@ internal class PartiQLParserDefault : PartiQLParser {
20512050
GeneratedParser.NULL -> typeNullType()
20522051
GeneratedParser.BOOL, GeneratedParser.BOOLEAN -> typeBool()
20532052
GeneratedParser.SMALLINT, GeneratedParser.INT2, GeneratedParser.INTEGER2 -> typeInt2()
2053+
// TODO, we have INT aliased to INT4 when it should be visa-versa.
20542054
GeneratedParser.INT4, GeneratedParser.INTEGER4 -> typeInt4()
2055+
GeneratedParser.INT, GeneratedParser.INTEGER -> typeInt4()
20552056
GeneratedParser.BIGINT, GeneratedParser.INT8, GeneratedParser.INTEGER8 -> typeInt8()
2056-
GeneratedParser.INT, GeneratedParser.INTEGER -> typeInt()
20572057
GeneratedParser.FLOAT -> typeFloat32()
20582058
GeneratedParser.DOUBLE -> typeFloat64()
20592059
GeneratedParser.REAL -> typeReal()

partiql-planner/src/test/kotlin/org/partiql/planner/internal/typer/PlanTyperTestsPorted.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ class PlanTyperTestsPorted {
494494
name = "DECIMAL AS INT",
495495
key = key("cast-03"),
496496
catalog = "pql",
497-
expected = StaticType.INT,
497+
expected = StaticType.INT4,
498498
),
499499
SuccessTestCase(
500500
name = "DECIMAL AS BIGINT",
@@ -2476,7 +2476,7 @@ class PlanTyperTestsPorted {
24762476
SuccessTestCase(
24772477
key = PartiQLTest.Key("basics", "case-when-11"),
24782478
catalog = "pql",
2479-
expected = unionOf(StaticType.INT, StaticType.MISSING),
2479+
expected = unionOf(StaticType.INT4, StaticType.MISSING),
24802480
),
24812481
SuccessTestCase(
24822482
key = PartiQLTest.Key("basics", "case-when-12"),
@@ -4273,7 +4273,7 @@ class PlanTyperTestsPorted {
42734273
query = "SELECT CAST(breed AS INT) AS cast_breed FROM pets",
42744274
expected = BagType(
42754275
StructType(
4276-
fields = mapOf("cast_breed" to StaticType.unionOf(StaticType.INT, StaticType.MISSING)),
4276+
fields = mapOf("cast_breed" to StaticType.unionOf(StaticType.INT4, StaticType.MISSING)),
42774277
contentClosed = true,
42784278
constraints = setOf(
42794279
TupleConstraint.Open(false),

partiql-planner/src/testFixtures/resources/inputs/basics/case.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ CASE t_item.t_string
8585
END;
8686

8787
--#[case-when-11]
88-
-- type: (int|missing)
88+
-- type: (int4|missing)
8989
COALESCE(CAST(t_item.t_string AS INT), 1);
9090

9191
-- -----------------------------

0 commit comments

Comments
 (0)