Skip to content

Add implementation of LET clause and LetTests #1745

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

Merged
merged 2 commits into from
Mar 11, 2025
Merged

Add implementation of LET clause and LetTests #1745

merged 2 commits into from
Mar 11, 2025

Conversation

lucaxchen
Copy link
Member

Relevant Issues

  • None

Description

  • In this pr, I added the implementation of LET clause. After merging this PR into the main branch, we suppose to support this kind of queries which have LET clause inside.
  SELECT t.x, t.y, t.z * 2 AS double_z
  FROM (
      SELECT A AS x, B AS y, new_val AS z
      FROM <<{ 'A': 1, 'B': 2, 'C': 3}>> 
      LET B + C AS new_val
  ) AS t;
  • The output wil be:
<<
    'x':1,
    'y':2,
     'new_val':10
>>

Other Information

License Information

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link

github-actions bot commented Mar 6, 2025

CROSS-ENGINE-REPORT ❌

BASE (LEGACY-V0.14.8) TARGET (EVAL-71C4A0B) +/-
% Passing 89.67% 94.96% 5.29% ✅
Passing 5287 5618 331 ✅
Failing 609 74 -535 ✅
Ignored 0 224 224 🔶
Total Tests 5896 5916 20 ✅

Testing Details

  • Base Commit: v0.14.8
  • Base Engine: LEGACY
  • Target Commit: 71c4a0b
  • Target Engine: EVAL

Result Details

  • ❌ REGRESSION DETECTED. See Now Failing/Ignored Tests. ❌
  • Passing in both: 2622
  • Failing in both: 18
  • Ignored in both: 0
  • PASSING in BASE but now FAILING in TARGET: 16
  • PASSING in BASE but now IGNORED in TARGET: 102
  • FAILING in BASE but now PASSING in TARGET: 179
  • IGNORED in BASE but now PASSING in TARGET: 0

Now FAILING Tests ❌

The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact.

Now IGNORED Tests ❌

The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact.

Now Passing Tests

179 test(s) were previously failing in BASE (LEGACY-V0.14.8) but now pass in TARGET (EVAL-71C4A0B). Before merging, confirm they are intended to pass.

The complete list can be found in GitHub CI summary, either from Step Summary or in the Artifact.

CROSS-COMMIT-REPORT ❌

BASE (EVAL-CCEFCFD) TARGET (EVAL-71C4A0B) +/-
% Passing 94.96% 94.96% 0.00% ✅
Passing 5618 5618 0 ✅
Failing 74 74 0 ✅
Ignored 224 224 0 ✅
Total Tests 5916 5916 0 ✅

Testing Details

  • Base Commit: ccefcfd
  • Base Engine: EVAL
  • Target Commit: 71c4a0b
  • Target Engine: EVAL

Result Details

  • ❌ REGRESSION DETECTED. See Now Failing/Ignored Tests. ❌
  • Passing in both: 5618
  • Failing in both: 74
  • Ignored in both: 224
  • PASSING in BASE but now FAILING in TARGET: 8
  • PASSING in BASE but now IGNORED in TARGET: 0
  • FAILING in BASE but now PASSING in TARGET: 8
  • IGNORED in BASE but now PASSING in TARGET: 0

Now FAILING Tests ❌

The following 8 test(s) were previously PASSING in BASE but are now FAILING in TARGET:

Click here to see
  1. repeated field on struct is ambiguous{identifier:"REPEATED",cn:9,bn:"REPEATED"}, compileOption: STRICT
  2. repeated field on struct is ambiguous{identifier:" "repeated" ",cn:10,bn:"repeated"}, compileOption: STRICT
  3. structs should be ordered by data types (DESC) (nulls first as default for desc), compileOption: PERMISSIVE
  4. structs should be ordered by data types (DESC) (nulls first as default for desc), compileOption: STRICT
  5. group by with where, compileOption: PERMISSIVE
  6. group by with where, compileOption: STRICT
  7. group by with group as and where, compileOption: PERMISSIVE
  8. group by with group as and where, compileOption: STRICT

Now Passing Tests

The following 8 test(s) were previously FAILING in BASE but are now PASSING in TARGET. Before merging, confirm they are intended to pass:

Click here to see
  1. structs should be ordered by data types (DESC) (nulls first as default for desc), compileOption: PERMISSIVE
  2. structs should be ordered by data types (DESC) (nulls first as default for desc), compileOption: STRICT
  3. group by with where, compileOption: PERMISSIVE
  4. group by with where, compileOption: STRICT
  5. group by with group as and where, compileOption: PERMISSIVE
  6. group by with group as and where, compileOption: STRICT
  7. repeated field on struct is ambiguous{identifier:"REPEATED",cn:9,bn:"REPEATED"}, compileOption: STRICT
  8. repeated field on struct is ambiguous{identifier:" "repeated" ",cn:10,bn:"repeated"}, compileOption: STRICT

Copy link
Member

@johnedquinn johnedquinn left a comment

Choose a reason for hiding this comment

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

This is great work. Clean code and comprehensive tests.

One test that we should add for making sure we don't break future functionality is for adding multiple let bindings. For example:

LET t.a + 5 AS b, t.a + 10 AS c, t.a + 15 AS d

Once we add a test(s) for this, this can be shipped. Nice work 👍

/**
* Concatenate bindings in LET clause with existing env bindings from input
*/
private fun convertLet(input: Rel, let: Let?): Rel {
Copy link
Member

Choose a reason for hiding this comment

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

👏

Copy link
Member Author

Choose a reason for hiding this comment

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

will add tests in amendment

@lucaxchen lucaxchen changed the title Add implementation of LET clause and test cases Add implementation of LET clause and LetTests Mar 10, 2025
Copy link
Member

@johnedquinn johnedquinn left a comment

Choose a reason for hiding this comment

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

Great work 👍

@lucaxchen lucaxchen merged commit 73d9f09 into main Mar 11, 2025
14 checks passed
@johnedquinn johnedquinn deleted the Let-dev branch March 11, 2025 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants