Closed johnedquinn closed 3 months ago
Perhaps push all the other changes and hold back the FROM and UNPIVOT changes while we investigate the typing implications?
Totally. I've removed those cases and have pushed them to PR #113. This is now ready for final review.
Description
FROM RHS Coercion
The excerpt below comes from the PartiQL Specification and states that, in strict mode, the query will FAIL when the RHS of a FROM is a scalar. In permissive, it'll be coerced to a bag holding the scalar.
This is applicable to the following 11 tests:
dateTimePartsAsVariableNames
various types in from clause
rangeTwiceOverScalar
single source FROM with scalar
single source FROM with scalar and AT clause
single source FROM with tuple
single source FROM with tuple and AT clause
single source FROM with absent value null
single source FROM with absent value null and AT clause
single source FROM with absent value missing
single source FROM with absent value missing and AT clause
Negative Indexing
From the PartiQL Specification:
This is applicable to the following 2 tests:
ordinalAccessWithNegativeIndex
ordinalAccessWithNegativeIndexAndBindings
SFW Coercion
The excerpt below comes from the PartiQL Specification and states that SELECT queries shall be coerced.
This is applicable to the following 4 tests:
SELECT VALUE with nested aggregates : SELECT VALUE (SELECT SUM(outerFromSource.col1) AS the_sum FROM <<1>>) FROM simple_1_col_1_group as outerFromSource
selectListMultipleAggregatesNestedQuery
Expression with multiple subqueriees containing aggregates : CAST((SELECT COUNT(1) FROM products) AS LIST)[0]._1 / CAST((SELECT COUNT(1) FROM suppliers) AS LIST)[0]._1
Aggregates with subquery containing another aggregate : SELECT COUNT(1) + CAST((SELECT SUM(numInStock) FROM products) AS LIST)[0]._1 as a_number FROM products
Note: I had to rename some of these due to the inclusion of the queries in their names.
EXCEPT DISTINCT Bug
For more information, please see partiql/partiql-lang#75
This is applicable to the following 1 test:
outerExceptDistinct
.Tuple Path Navigation Failures
From the PartiQL Specification:
Notably, it seems that, in type checking mode, grouping does NOT coerce any type checking errors to NULL/MISSING. However, if a MISSING is encountered (not an error), then it will be coerced to
NULL
.Similarly, aggregate functions are modeled as scalar functions that take in BAGS and output scalars. It seems that a type check exception occurring within the arguments of an aggregate function will result in a query failure (it won't be caught) with type checking mode. In permissive, these failures are coerced to MISSING, and the aggregate functions handle them appropriately.
This is applicable to the following 58 tests:
selectValueStructConstructorWithMissing
SELECT supplierId_missings FROM products_sparse p GROUP BY p.supplierId_missings
SELECT p.supplierId_missings FROM products_sparse p GROUP BY p.supplierId_missings
SELECT VALUE { 'supplierId_missings' : p.supplierId_missings } FROM products_sparse p GROUP BY p.supplierId_missings
SELECT supplierId_mixed FROM products_sparse p GROUP BY p.supplierId_mixed
SELECT p.supplierId_mixed FROM products_sparse p GROUP BY p.supplierId_mixed
SELECT VALUE { 'supplierId_mixed' : p.supplierId_mixed } FROM products_sparse p GROUP BY p.supplierId_mixed
SELECT regionId, supplierId_missings FROM products_sparse p GROUP BY p.regionId, p.supplierId_missings
SELECT p.regionId, p.supplierId_missings FROM products_sparse p GROUP BY p.regionId, p.supplierId_missings
SELECT VALUE { 'regionId': p.regionId, 'supplierId_missings': p.supplierId_missings } FROM products_sparse p GROUP BY p.regionId, p.supplierId_missings
SELECT regionId, supplierId_mixed FROM products_sparse p GROUP BY p.regionId, p.supplierId_mixed
SELECT regionId, p.supplierId_mixed FROM products_sparse p GROUP BY p.regionId, p.supplierId_mixed
SELECT VALUE { 'regionId': p.regionId, 'supplierId_mixed': p.supplierId_mixed } FROM products_sparse p GROUP BY p.regionId, p.supplierId_mixed
SELECT COUNT(1) AS the_count, <ALL_AGGS>(p.price_missings) AS the_agg FROM products_sparse AS p
SELECT COUNT(1) AS the_count, <ALL_AGGS>(p.price_mixed) AS the_agg FROM products_sparse AS p
SELECT categoryId, COUNT(1) AS the_count, <ALL_AGGS>(p.price_missings) AS the_agg FROM products_sparse AS p GROUP BY categoryId
SELECT categoryId, COUNT(1) AS the_count, <ALL_AGGS>(p.price_mixed) AS the_agg FROM products_sparse AS p GROUP BY categoryId
SELECT p.categoryId, COUNT(1) AS the_count, <ALL_AGGS>( price_nulls) AS the_agg FROM products_sparse AS p GROUP BY p.categoryId
SELECT p.categoryId, COUNT(1) AS the_count, <ALL_AGGS>(p.price_mixed) AS the_agg FROM products_sparse AS p GROUP BY p.categoryId
undefinedUnqualifiedVariable_inSelect_withProjectionOption
selectListWithMissing
ANY with GROUP BY
ANY DISTINCT with GROUP BY
SOME with GROUP BY
SOME DISTINCT with GROUP BY
EVERY with GROUP BY
EVERY DISTINCT with GROUP BY
undefinedUnqualifiedVariableInSelectWithUndefinedVariableBehaviorMissing
array element evaluates to MISSING
bag element evaluates to MISSING
bag element evaluates to MISSING in bag constructor
cast and operations with missing argument
group by with absent values
group by with differenciated absent values
UNPIVOT Coercion
I fixed a handful of tests that do not handle the Unpivot mistyping scenarios. According to the PartiQL Specification:
AT Alias When Unordered
I fixed some tests that previously contradicted the following excerpt from the PartiQL Specification:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.