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

Merges main into v1 #1481

Merged
merged 15 commits into from
Jun 11, 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
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,30 @@ Thank you to all who have contributed!
### Added

### Changed
- **Behavioral change**: The planner now does NOT support the NullType and MissingType variants of StaticType. The logic
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
information in the "Changed" section. In relation to the deprecation of the above, the following APIs have also
been deprecated:
- `org.partiql.type.StaticType.MISSING`
- `org.partiql.type.StaticType.NULL`
- `org.partiql.type.StaticType.NULL_OR_MISSING`
- `org.partiql.type.StaticType.asNullable()`
- `org.partiql.type.StaticType.isNullable()`
- `org.partiql.type.StaticType.isMissable()`
- `org.partiql.type.StaticType.asOptional()`
- `org.partiql.type.AnyOfType()`
- `org.partiql.value.PartiQLValueType.NULL`
- `org.partiql.value.PartiQLValueType.MISSING`

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,47 +414,6 @@ class PartiQLEngineDefaultTest {

@JvmStatic
fun aggregationTestCases() = kotlin.collections.listOf(
SuccessTestCase(
input = """
SELECT
gk_0, SUM(t.c) AS t_c_sum
FROM <<
{ 'b': NULL, 'c': 1 },
{ 'b': MISSING, 'c': 2 },
{ 'b': 1, 'c': 1 },
{ 'b': 1, 'c': 2 },
{ 'b': 2, 'c': NULL },
{ 'b': 2, 'c': 2 },
{ 'b': 3, 'c': MISSING },
{ 'b': 3, 'c': 2 },
{ 'b': 4, 'c': MISSING },
{ 'b': 4, 'c': NULL }
>> AS t GROUP BY t.b AS gk_0;
""".trimIndent(),
expected = org.partiql.value.bagValue(
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(1),
"t_c_sum" to org.partiql.value.int32Value(3)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(2),
"t_c_sum" to org.partiql.value.int32Value(2)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(3),
"t_c_sum" to org.partiql.value.int32Value(2)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(4),
"t_c_sum" to org.partiql.value.int32Value(null)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.nullValue(),
"t_c_sum" to org.partiql.value.int32Value(3)
),
),
mode = org.partiql.eval.PartiQLEngine.Mode.PERMISSIVE
),
SuccessTestCase(
input = """
SELECT VALUE { 'sensor': sensor,
Expand Down Expand Up @@ -900,17 +859,6 @@ class PartiQLEngineDefaultTest {
mode = PartiQLEngine.Mode.STRICT
),
// PartiQL Specification Section 8
SuccessTestCase(
input = "MISSING AND TRUE;",
expected = boolValue(null),
),
// PartiQL Specification Section 8
SuccessTestCase(
input = "MISSING AND TRUE;",
expected = boolValue(null), // TODO: Is this right?
mode = PartiQLEngine.Mode.STRICT
),
// PartiQL Specification Section 8
SuccessTestCase(
input = "NULL IS MISSING;",
expected = boolValue(false),
Expand Down Expand Up @@ -1385,6 +1333,73 @@ class PartiQLEngineDefaultTest {
)
).assert()

@Test
@Disabled(
"""
We currently do not have support for consolidating collections containing MISSING/NULL. The current
result (value) is correct. However, the types are slightly wrong due to the SUM__ANY_ANY being resolved.
alancai98 marked this conversation as resolved.
Show resolved Hide resolved
"""
)
fun aggregationOnLiteralBagOfStructs() = SuccessTestCase(
input = """
SELECT
gk_0, SUM(t.c) AS t_c_sum
FROM <<
{ 'b': NULL, 'c': 1 },
{ 'b': MISSING, 'c': 2 },
{ 'b': 1, 'c': 1 },
{ 'b': 1, 'c': 2 },
{ 'b': 2, 'c': NULL },
{ 'b': 2, 'c': 2 },
{ 'b': 3, 'c': MISSING },
{ 'b': 3, 'c': 2 },
{ 'b': 4, 'c': MISSING },
{ 'b': 4, 'c': NULL }
>> AS t GROUP BY t.b AS gk_0;
""".trimIndent(),
expected = org.partiql.value.bagValue(
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(1),
"t_c_sum" to org.partiql.value.int32Value(3)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(2),
"t_c_sum" to org.partiql.value.int32Value(2)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(3),
"t_c_sum" to org.partiql.value.int32Value(2)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.int32Value(4),
"t_c_sum" to org.partiql.value.int32Value(null)
),
org.partiql.value.structValue(
"gk_0" to org.partiql.value.nullValue(),
"t_c_sum" to org.partiql.value.int32Value(3)
),
),
mode = org.partiql.eval.PartiQLEngine.Mode.PERMISSIVE
).assert()

// PartiQL Specification Section 8
@Test
@Disabled("Currently, .check(<PartiQLValue>) is failing for MISSING. This will be resolved by Datum.")
fun missingAndTruePermissive() =
SuccessTestCase(
input = "MISSING AND TRUE;",
expected = boolValue(null),
).assert()

// PartiQL Specification Section 8
@Test
@Disabled("Currently, .check(<PartiQLValue>) is failing for MISSING. This will be resolved by Datum.")
fun missingAndTrueStrict() = SuccessTestCase(
input = "MISSING AND TRUE;",
expected = boolValue(null), // TODO: Is this right?
mode = PartiQLEngine.Mode.STRICT
).assert()

@Test
@Disabled("Support for ORDER BY needs to be added for this to pass.")
// PartiQL Specification says that SQL's SELECT is coerced, but SELECT VALUE is not.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ import org.partiql.lang.util.checkThreadInterrupted
import org.partiql.lang.util.error
import org.partiql.lang.util.getPrecisionFromTimeString
import org.partiql.lang.util.unaryMinus
import org.partiql.parser.internal.antlr.PartiQLBaseVisitor
import org.partiql.parser.internal.antlr.PartiQLParser
import org.partiql.parser.internal.antlr.PartiQLParserBaseVisitor
import org.partiql.pig.runtime.SymbolPrimitive
import org.partiql.value.datetime.DateTimeException
import org.partiql.value.datetime.TimeZone
Expand All @@ -73,12 +73,12 @@ import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException

/**
* Extends ANTLR's generated [PartiQLBaseVisitor] to visit an ANTLR ParseTree and convert it into a PartiQL AST. This
* Extends ANTLR's generated [PartiQLParserBaseVisitor] to visit an ANTLR ParseTree and convert it into a PartiQL AST. This
* class uses the [PartiqlAst.PartiqlAstNode] to represent all nodes within the new AST.
*
* When the grammar in PartiQL.g4 is extended with a new rule, one needs to override corresponding visitor methods
* in this class, in order to extend the transformation from an ANTLR parse tree into a [PartqlAst] tree.
* (Trivial implementations of these methods are generated into [PartiQLBaseVisitor].)
* (Trivial implementations of these methods are generated into [PartiQLParserBaseVisitor].)
*
* For a rule of the form
* ```
Expand Down Expand Up @@ -119,7 +119,7 @@ internal class PartiQLPigVisitor(
val customTypes: List<CustomType> = listOf(),
private val parameterIndexes: Map<Int, Int> = mapOf(),
) :
PartiQLBaseVisitor<PartiqlAst.PartiqlAstNode>() {
PartiQLParserBaseVisitor<PartiqlAst.PartiqlAstNode>() {

companion object {
internal val TRIM_SPECIFICATION_KEYWORDS = setOf("both", "leading", "trailing")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.partiql.lang.ast.passes.inference
import junitparams.JUnitParamsRunner
import junitparams.Parameters
import org.junit.Assert.assertEquals
import org.junit.Ignore
import org.junit.Test
import org.junit.runner.RunWith
import org.partiql.types.DecimalType
Expand Down Expand Up @@ -85,6 +86,7 @@ class StaticTypeCastTests {

@Test
@Parameters
@Ignore("StaticType.ALL_TYPES no longer supports NULL/MISSING") // @Test comes from JUnit4, and therefore we must use @Ignore.
fun unionTypeCastTests(tc: TestCase) = runTest(tc)

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand All @@ -20,6 +21,7 @@ import org.partiql.types.StructType

class InferencerMultipleProblemsTests {
@ParameterizedTest
@Disabled
@MethodSource("parametersForMultipleInferenceProblemsTests")
fun multipleInferenceProblemsTests(tc: TestCase) = runTest(tc)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand Down Expand Up @@ -29,6 +30,7 @@ class InferencerNaryArithmeticTests {

@ParameterizedTest
@MethodSource("parametersForNAryArithmeticTests")
@Disabled
fun naryArithmeticInferenceTests(tc: InferencerTestUtil.TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand All @@ -26,6 +27,7 @@ import org.partiql.types.StaticType
class InferencerNaryBetweenTests {
@ParameterizedTest
@MethodSource("parametersForNAryBetweenTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun naryBetweenInferenceTests(tc: TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand Down Expand Up @@ -33,6 +34,7 @@ import org.partiql.types.StructType
class InferencerNaryComparisonAndEqualityTests {
@ParameterizedTest
@MethodSource("parametersForNAryComparisonAndEqualityTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun naryComparisonAndEqualityInferenceTests(tc: TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand All @@ -25,6 +26,7 @@ import org.partiql.types.StringType
class InferencerNaryConcatTests {
@ParameterizedTest
@MethodSource("parametersForNAryConcatTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun naryConcatInferenceTests(tc: TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand All @@ -22,6 +23,7 @@ class InferencerNaryLikeTests {

@ParameterizedTest
@MethodSource("parametersForNAryLikeTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun naryLikeInferenceTests(tc: TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand All @@ -25,6 +26,7 @@ import org.partiql.types.StaticType
class InferencerNaryLogicalTests {
@ParameterizedTest
@MethodSource("parametersForNAryLogicalTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun naryLogicalInferenceTests(tc: TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand Down Expand Up @@ -31,6 +32,7 @@ import org.partiql.types.StaticType
class InferencerNaryOpInTests {
@ParameterizedTest
@MethodSource("parametersForNAryOpInTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun nAryOpInTests(tc: TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.lang.eval.visitors.inferencer.InferencerTestUtil.TestCase
Expand All @@ -10,6 +11,7 @@ import org.partiql.types.StaticType
class InferencerTrimFunctionTests {
@ParameterizedTest
@MethodSource("parametersForTrimFunctionTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun trimFunctionTests(tc: TestCase) = runTest(tc)

companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.partiql.lang.eval.visitors.inferencer

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.MethodSource
import org.partiql.errors.Problem
Expand All @@ -15,6 +16,7 @@ import org.partiql.types.StaticType
class InferencerUnaryArithmeticOpTests {
@ParameterizedTest
@MethodSource("parametersForUnaryArithmeticOpTests")
@Disabled("StaticType.ALL_TYPES no longer supports NULL/MISSING")
fun unaryArithmeticInferenceTests(tc: InferencerTestUtil.TestCase) = InferencerTestUtil.runTest(tc)

companion object {
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
2 changes: 2 additions & 0 deletions partiql-parser/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ tasks.processResources {
from("src/main/antlr") {
include("**/*.g4")
}
// TODO remove in next major version release.
rename("PartiQLParser.g4", "PartiQL.g4")
Comment on lines +93 to +94
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self to remove the rename in the v1 branch.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. I'm going to keep it since we know that we plan on merging this to main to perform a release before V1. This should be removed once all of our deprecation notices are eventually deleted.

}

publish {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
grammar PartiQL;
parser grammar PartiQLParser;

options {
tokenVocab=PartiQLTokens;
Expand Down
Loading
Loading