Skip to content
Open
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
2 changes: 1 addition & 1 deletion docs/sphinx/source/ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Mixed mode testing run against the following previous versions:
* Fix the NULL result of `field()` key expressions with fan-type `Concatenate` - [PR #4130](https://github.com/FoundationDB/fdb-record-layer/pull/4130)
<h4> New Features </h4>

* Implement the PartiQL “AT” construct for unnesting with ordinality - [PR #4112](https://github.com/FoundationDB/fdb-record-layer/pull/4112)
* Implement the SQL++ “AT” construct for unnesting with ordinality - [PR #4112](https://github.com/FoundationDB/fdb-record-layer/pull/4112)
* Support CARDINALITY() in indexes - [PR #4100](https://github.com/FoundationDB/fdb-record-layer/pull/4100)
<h4> Bug Fixes </h4>

Expand Down
6 changes: 3 additions & 3 deletions docs/sphinx/source/reference/Subqueries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ A subquery that references columns from the outer query:
Array Unnesting
---------------

FDB supports PartiQL-style array unnesting:
FDB supports SQL++-style array unnesting:

.. code-block:: sql

Expand Down Expand Up @@ -124,10 +124,10 @@ Use a correlated subquery as a derived table:

The subquery ``(SELECT * FROM r WHERE r.idr = a.x)`` is correlated because it references ``a.x`` from the outer query.

Array Unnesting with PartiQL
Array Unnesting with SQL++
-----------------------------

Unnest an array column using PartiQL syntax:
Unnest an array column using SQL++ syntax:

.. code-block:: sql

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
* </p>
* <dl>
* <dt><span class="strong"> Query Language</span></dt>
* <dd>

Check notice on line 37 in fdb-relational-api/src/main/java/com/apple/foundationdb/relational/api/RelationalStatement.java

View workflow job for this annotation

GitHub Actions / coverage

File coverage: 66.7% (2/3 lines) | Changed lines: N/A (no executable lines)
* The Query language used by Relational is a subset of the <a href="https://partiql.org">PartiQL Spec</a>.
* The Query language used by Relational is a subset of <a href="https://arxiv.org/pdf/1405.3631">SQL++</a>.
* </dd>
* <dt><span class="strong"> Direct Access</span></dt>
* <dd>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,22 +340,22 @@ void createIndexOnScalarArrayAndConcatDifferentOrder() throws Exception {
}

/**
* Scalar array unnesting via PartiQL syntax: STRING ARRAY, INDEX…AS syntax.
* Scalar array unnesting via SQL++ syntax: STRING ARRAY, INDEX…AS syntax.
*/
@Test
void createIndexOnScalarStringArrayPartiQL() throws Exception {
void createIndexOnScalarStringArraySqlPlusPlus() throws Exception {
final String stmt = "CREATE SCHEMA TEMPLATE test_template " +
"CREATE TABLE T(p BIGINT, items STRING ARRAY, PRIMARY KEY (p)) " +
"CREATE INDEX mv1 AS SELECT item FROM T AS t, t.items AS item ORDER BY item";
indexIs(stmt, field("ITEMS").nest(field(REPEATED_FIELD_NAME, KeyExpression.FanType.FanOut)), IndexTypes.VALUE);
}

/**
* Scalar array unnesting via PartiQL syntax: STRING ARRAY, VIEW + INDEX…ON syntax.
* Scalar array unnesting via SQL++ syntax: STRING ARRAY, VIEW + INDEX…ON syntax.
*/
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
@Test
void createIndexOnScalarStringArrayPartiQLUsingView() throws Exception {
void createIndexOnScalarStringArraySqlPlusPlusUsingView() throws Exception {
final String stmt = "CREATE SCHEMA TEMPLATE test_template " +
"CREATE TABLE T(p BIGINT, items STRING ARRAY, PRIMARY KEY (p)) " +
"CREATE VIEW v1 AS SELECT item FROM T AS t, t.items AS item " +
Expand All @@ -364,34 +364,34 @@ void createIndexOnScalarStringArrayPartiQLUsingView() throws Exception {
}

/**
* Scalar array unnesting via PartiQL syntax: INTEGER ARRAY (different scalar type).
* Scalar array unnesting via SQL++ syntax: INTEGER ARRAY (different scalar type).
*/
@Test
void createIndexOnScalarIntegerArrayPartiQL() throws Exception {
void createIndexOnScalarIntegerArraySqlPlusPlus() throws Exception {
final String stmt = "CREATE SCHEMA TEMPLATE test_template " +
"CREATE TABLE T(p BIGINT, nums INTEGER ARRAY, PRIMARY KEY (p)) " +
"CREATE INDEX mv1 AS SELECT num FROM T AS t, t.nums AS num ORDER BY num";
indexIs(stmt, field("NUMS").nest(field(REPEATED_FIELD_NAME, KeyExpression.FanType.FanOut)), IndexTypes.VALUE);
}

/**
* Scalar array unnesting via PartiQL syntax: array element + table column, ordered by (item, p).
* Scalar array unnesting via SQL++ syntax: array element + table column, ordered by (item, p).
*/
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
@Test
void createIndexOnScalarArrayPartiQLAndConcat() throws Exception {
void createIndexOnScalarArraySqlPlusPlusAndConcat() throws Exception {
final String stmt = "CREATE SCHEMA TEMPLATE test_template " +
"CREATE TABLE T(p BIGINT, items STRING ARRAY, PRIMARY KEY (p)) " +
"CREATE INDEX mv1 AS SELECT item, t.p FROM T AS t, t.items AS item ORDER BY item, t.p";
indexIs(stmt, concat(field("ITEMS").nest(field(REPEATED_FIELD_NAME, KeyExpression.FanType.FanOut)), field("P")), IndexTypes.VALUE);
}

/**
* Scalar array unnesting via PartiQL syntax: array element + table column, ordered by (p, item).
* Scalar array unnesting via SQL++ syntax: array element + table column, ordered by (p, item).
*/
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
@Test
void createIndexOnScalarArrayPartiQLAndConcatDifferentOrder() throws Exception {
void createIndexOnScalarArraySqlPlusPlusAndConcatDifferentOrder() throws Exception {
final String stmt = "CREATE SCHEMA TEMPLATE test_template " +
"CREATE TABLE T(p BIGINT, items STRING ARRAY, PRIMARY KEY (p)) " +
"CREATE INDEX mv1 AS SELECT t.p, item FROM T AS t, t.items AS item ORDER BY t.p, item";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ void getBytes() throws Exception {
}

@Test
void partiqlNestingWorks() throws Exception {
void sqlPlusPlusNestingWorks() throws Exception {
final String schema = "CREATE TYPE AS STRUCT A ( b B )" +
" CREATE TYPE AS STRUCT B ( c C )" +
" CREATE TYPE AS STRUCT C ( d D )" +
Expand Down Expand Up @@ -611,7 +611,7 @@ void partiqlNestingWorks() throws Exception {
}

@Test
void partiqlNestingWorksWithRepeatedLeaf() throws Exception {
void sqlPlusPlusNestingWorksWithRepeatedLeaf() throws Exception {
final String schema = "CREATE TYPE AS STRUCT A ( b B )" +
" CREATE TYPE AS STRUCT B ( c C )" +
" CREATE TYPE AS STRUCT C ( d D )" +
Expand Down Expand Up @@ -656,7 +656,7 @@ void partiqlNestingWorksWithRepeatedLeaf() throws Exception {
}

@Test
void partiqlAccessingNestedFieldWithInnerRepeatedFieldsFails() throws Exception {
void sqlPlusPlusAccessingNestedFieldWithInnerRepeatedFieldsFails() throws Exception {
final String schema = "CREATE TYPE AS STRUCT A ( b B )" +
" CREATE TYPE AS STRUCT B ( c C )" +
" CREATE TYPE AS STRUCT C ( d D )" +
Expand Down
4 changes: 2 additions & 2 deletions yaml-tests/src/test/resources/array-join-at.yamsql
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
options:
supported_version: 4.12.3.0
---
# Comprehensive integration tests for the PartiQL AT construct.
# Comprehensive integration tests for the SQL++ AT construct.
schema_template:
CREATE TABLE T1 ("id" BIGINT, "arr1" INTEGER ARRAY NULL, "arr1_nn" INTEGER ARRAY NOT NULL, PRIMARY KEY ("id"))
CREATE TABLE T2 ("id" BIGINT, "arr1" INTEGER ARRAY, "arr2" INTEGER ARRAY, PRIMARY KEY ("id"))
Expand Down Expand Up @@ -89,7 +89,7 @@ test_block:
{id: 2, val: 203, at: 3}]
-
# It is allowed to leave out the AS alias completely, keeping only the AT part. This way the elements themselves
# cannot be accessed, only their indexes. Although this is not possible with pure PartiQL or with the UNNEST()
# cannot be accessed, only their indexes. Although this is not possible with pure SQL++ or with the UNNEST()
# construct in standard SQL, we do not prohibit this case.
- query: SELECT "id", "at" FROM T1, T1."arr1" AT "at"
- explain: "SCAN([IS T1]) | FLATMAP q0 -> { EXPLODE q0.arr1 WITH ORDINALITY AS q1 RETURN (q0.id AS id, q1._1 AS at) }"
Expand Down
6 changes: 3 additions & 3 deletions yaml-tests/src/test/resources/arrays-unnesting.yamsql
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ test_block:
- query: SELECT "items" FROM "T1_indexed" ORDER BY "items"
- error: "0AF00" # "Cascades planner could not plan query"
-
# Unnesting the array using PartiQL-style unnesting.
# Unnesting the array using SQL++-style unnesting.
- query: SELECT "id", "item" FROM "T1_indexed" AS "row", "row"."items" AS "item"
- explain: "SCAN([IS T1_indexed]) | FLATMAP q0 -> { EXPLODE q0.items AS q1 RETURN (q0.id AS id, q1 AS item) }"
- unorderedResult: [
Expand All @@ -123,9 +123,9 @@ test_block:
{id: 3, item: 'f'}]
-
# Unnesting the array using a lateral/correlated subquery.
# Notice the difference to PartiQL-style unnesting, where "item" binds directly to an array item.
# Notice the difference to SQL++-style unnesting, where "item" binds directly to an array item.
# Here the subquery packs each array item into a tuple, produces a stream of tuples, and binds SQ to each tuple.
# The planner is able to produce the same EXPLODE plan as for PartiQL-style unnesting.
# The planner is able to produce the same EXPLODE plan as for SQL++-style unnesting.
- query: SELECT "id", SQ."item" FROM "T1_indexed" AS "row", (SELECT "item" FROM "row"."items" AS "item") AS SQ
- explain: "SCAN([IS T1_indexed]) | FLATMAP q0 -> { EXPLODE q0.items AS q1 RETURN (q0.id AS id, q1 AS item) }"
- unorderedResult: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test_block:
{x: 2, idr: 2, nr: [{f: 21}, {f: 22}, {f: 23}]},
{x: 3, idr: 3, nr: [{f: 31}, {f: 32}, {f: 33}]}]

# Array Unnesting with PartiQL
# Array Unnesting with SQL++
-
- query: SELECT idr FROM r, r.nr AS NEST WHERE NEST.f = 23
- result: [{idr: 2}]
Expand Down
4 changes: 2 additions & 2 deletions yaml-tests/src/test/resources/subquery-tests.yamsql
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ test_block:
- explain: "SCAN([IS A, EQUALS promote(@c14 AS INT)]) | MAP (_.X AS X) | DEFAULT NULL | FILTER _ NOT_NULL | FLATMAP q0 -> { SCAN([IS X]) AS q1 RETURN (q1.IDX AS IDX) }"
- result: [{4}, {5}, {6}]
-
# PartiQL resolution.
# SQL++ resolution.
- query: select idr from r, r.nr as NEST where NEST.f = 23;
- result: [{2}]
-
# PartiQL resolution, another flavour (TODO check whether this still use the IR index).
# SQL++ resolution, another flavour (TODO check whether this still use the IR index).
- query: select idr from r, (select * from r.nr) as NEST where NEST.f = 23;
- result: [{2}]
-
Expand Down
Loading