Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ Thank you to all who have contributed!
is that the null and missing values are part of *all* data types. Therefore, one must assume that the types returned by
the planner allow for NULL and MISSING values. Similarly, the testFixtures Ion-encoded test resources
representing the catalog do not use "null" or "missing".
- **Behavioral change**: The `INTEGER/INT` type is now an alias to the `INT4` type. Previously the INTEGER type was
unconstrained which is not SQL-conformant and is causing issues in integrating with other systems. This release makes
INTEGER an alias for INT4 which is the internal type name. In a later release, we will make INTEGER the default 32-bit
integer with INT/INT4/INTEGER4 being aliases per other systems. This change only applies to
org.partiql.parser.PartiQLParser, not the org.partiql.lang.syntax.PartiQLParser.

### Deprecated
- We have deprecated `org.partiql.type.NullType` and `org.partiql.type.MissingType`. Please see the corresponding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3998,6 +3998,7 @@ class PartiQLParserTest : PartiQLParserTestBase() {
)

@Test
@Ignore("This test is disabled while the new parser uses INT as an INT4 alias whereas the older parser does not.")
fun createTableWithConstraints() = assertExpression(
"""
CREATE TABLE Customer (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ import org.partiql.ast.typeDate
import org.partiql.ast.typeDecimal
import org.partiql.ast.typeFloat32
import org.partiql.ast.typeFloat64
import org.partiql.ast.typeInt
import org.partiql.ast.typeInt2
import org.partiql.ast.typeInt4
import org.partiql.ast.typeInt8
Expand Down Expand Up @@ -2051,9 +2050,10 @@ internal class PartiQLParserDefault : PartiQLParser {
GeneratedParser.NULL -> typeNullType()
GeneratedParser.BOOL, GeneratedParser.BOOLEAN -> typeBool()
GeneratedParser.SMALLINT, GeneratedParser.INT2, GeneratedParser.INTEGER2 -> typeInt2()
// TODO, we have INT aliased to INT4 when it should be visa-versa.
GeneratedParser.INT4, GeneratedParser.INTEGER4 -> typeInt4()
GeneratedParser.INT, GeneratedParser.INTEGER -> typeInt4()
GeneratedParser.BIGINT, GeneratedParser.INT8, GeneratedParser.INTEGER8 -> typeInt8()
GeneratedParser.INT, GeneratedParser.INTEGER -> typeInt()
GeneratedParser.FLOAT -> typeFloat32()
GeneratedParser.DOUBLE -> typeFloat64()
GeneratedParser.REAL -> typeReal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ class PlanTyperTestsPorted {
name = "DECIMAL AS INT",
key = key("cast-03"),
catalog = "pql",
expected = StaticType.INT,
expected = StaticType.INT4,
),
SuccessTestCase(
name = "DECIMAL AS BIGINT",
Expand Down Expand Up @@ -2459,7 +2459,7 @@ class PlanTyperTestsPorted {
SuccessTestCase(
key = PartiQLTest.Key("basics", "case-when-11"),
catalog = "pql",
expected = StaticType.INT,
expected = StaticType.INT4,
),
SuccessTestCase(
key = PartiQLTest.Key("basics", "case-when-12"),
Expand Down Expand Up @@ -4190,7 +4190,7 @@ class PlanTyperTestsPorted {
query = "SELECT CAST(breed AS INT) AS cast_breed FROM pets",
expected = BagType(
StructType(
fields = mapOf("cast_breed" to StaticType.INT),
fields = mapOf("cast_breed" to StaticType.INT4),
contentClosed = true,
constraints = setOf(
TupleConstraint.Open(false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ CASE t_item.t_string
END;

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

-- -----------------------------
Expand Down
Loading