From 5bcde139e68a769d74ec24e8c9a7f92fac61bf32 Mon Sep 17 00:00:00 2001 From: Arash Maymandi <27716912+am357@users.noreply.github.com> Date: Wed, 20 Mar 2024 13:35:21 -0700 Subject: [PATCH] Add EXCLUDE test for derivedColumn from subquery (#1394) Adds a unit-test for excluding a column that is as a result of a new projection from a subquery. More details: ``` PartiQL> SELECT tbl2.* EXCLUDE tbl2.dervidedColumn FROM (SELECT tbl1.*, tbl1.a.b + 2 AS dervidedColumn FROM <<{'a': {'b': 2}, 'foo': 'bar', 'foo2': 'bar2'}>> AS tbl1) AS tbl2; ===' << { 'a': { 'b': 2 }, 'foo': 'bar', 'foo2': 'bar2' } >> --- OK! PartiQL> SELECT tbl2.* FROM (SELECT tbl1.*, tbl1.a.b + 2 AS dervidedColumn FROM <<{'a': {'b': 2}, 'foo': 'bar', 'foo2': 'bar2'}>> AS tbl1) AS tbl2; ===' << { 'a': { 'b': 2 }, 'foo': 'bar', 'foo2': 'bar2', 'dervidedColumn': 4 } >> --- OK! ``` --- .../partiql/lang/eval/EvaluatingCompilerExcludeTests.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/partiql-lang/src/test/kotlin/org/partiql/lang/eval/EvaluatingCompilerExcludeTests.kt b/partiql-lang/src/test/kotlin/org/partiql/lang/eval/EvaluatingCompilerExcludeTests.kt index 3ab41e136..4f1e1d883 100644 --- a/partiql-lang/src/test/kotlin/org/partiql/lang/eval/EvaluatingCompilerExcludeTests.kt +++ b/partiql-lang/src/test/kotlin/org/partiql/lang/eval/EvaluatingCompilerExcludeTests.kt @@ -22,6 +22,14 @@ class EvaluatingCompilerExcludeTests : EvaluatorTestBase() { "SELECT t.* EXCLUDE t.a FROM <<{'a': {'b': 2}, 'foo': 'bar', 'foo2': 'bar2'}>> AS t", """<<{'foo': 'bar', 'foo2': 'bar2'}>>""" ), + EvaluatorTestCase( + """ + SELECT tbl2.* EXCLUDE tbl2.derivedColumn FROM + (SELECT tbl1.*, tbl1.a.b + 2 AS derivedColumn FROM + <<{'a': {'b': 2}, 'foo': 'bar', 'foo2': 'bar2'}>> AS tbl1) + AS tbl2""", + " <<{'a': {'b': 2}, 'foo': 'bar', 'foo2': 'bar2'}>>" + ), EvaluatorTestCase( // EXCLUDE tuple attr using bracket syntax; same output as above "SELECT t.* EXCLUDE t['a'] FROM <<{'a': {'b': 2}, 'foo': 'bar', 'foo2': 'bar2'}>> AS t", """<<{'foo': 'bar', 'foo2': 'bar2'}>>"""