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

[V1] Adds basic strategies to compiler (see #1625) #1644

Merged
merged 7 commits into from
Nov 5, 2024
Merged

[V1] Adds basic strategies to compiler (see #1625) #1644

merged 7 commits into from
Nov 5, 2024

Conversation

RCHowell
Copy link
Member

@RCHowell RCHowell commented Nov 5, 2024

Relevant Issues

#1625

Description

This PR defines a single node pattern along with the strategy API. This allows you to define a "strategy" or hook to insert custom implementations of certain nodes.

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.

Comment on lines +29 to +49
/**
* Get the i-th operator (pre-order) matched by the pattern.
*
* @param i 0-indexed
* @return Operator
*/
@NotNull
public Operator operator(int i) {
return operators[i];
}

/**
* Get the i-th input to this pattern.
*
* @param i 0-indexed
* @return Expr
*/
@NotNull
public List<Expr> children(int i) {
return children.get(i);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

self-review: naming?

Comment on lines +13 to +14
@NotNull
private final Pattern pattern;
Copy link
Member Author

Choose a reason for hiding this comment

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

self-review: since this is an abstract class, it might be worth making the field public and removing the getter.

Comment on lines +174 to +179
if (strategy.getPattern().matches(operator)) {
// compile children
val children = operator.getChildren().map { compileWithStrategies(it, ctx) }
val match = Match(operator, children)
return strategy.apply(match)
}
Copy link
Member Author

Choose a reason for hiding this comment

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

self-review: this shows how we can recurse to compile the children, then include those in the match object.

Comment on lines +10 to +17
/**
* Get i-th child (input) operator.
*
* @param index
*/
public fun getChild(index: Int) {
throw UnsupportedOperationException("getChild")
}
Copy link
Member Author

Choose a reason for hiding this comment

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

self-review: get i-th child is crucial to building the match structures but is unused now.

Comment on lines +714 to +722
/**
* @return a PartiQL row type
* @deprecated this API is experimental and is subject to modification/deletion without prior notice.
*/
@NotNull
static PType row(@NotNull Field... fields) {
return new PTypeRow(Arrays.asList(fields));
}

Copy link
Member Author

Choose a reason for hiding this comment

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

self-review: auto-formatting messed with some things. All I've done is added the row helper.

Copy link

github-actions bot commented Nov 5, 2024

CROSS-ENGINE-REPORT ❌

BASE (LEGACY-V0.14.8) TARGET (EVAL-0A305C4) +/-
% Passing 89.67% 94.39% 4.72% ✅
Passing 5287 5565 278 ✅
Failing 609 50 -559 ✅
Ignored 0 281 281 🔶
Total Tests 5896 5896 0 ✅

Testing Details

  • Base Commit: v0.14.8
  • Base Engine: LEGACY
  • Target Commit: 0a305c4
  • Target Engine: EVAL

Result Details

  • ❌ REGRESSION DETECTED. See Now Failing/Ignored Tests. ❌
  • Passing in both: 2643
  • Failing in both: 17
  • Ignored in both: 0
  • PASSING in BASE but now FAILING in TARGET: 3
  • PASSING in BASE but now IGNORED in TARGET: 108
  • FAILING in BASE but now PASSING in TARGET: 180
  • IGNORED in BASE but now PASSING in TARGET: 0

Now FAILING Tests ❌

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

Click here to see
  1. undefinedUnqualifiedVariableWithUndefinedVariableBehaviorMissing, compileOption: PERMISSIVE
  2. undefinedUnqualifiedVariableIsNullExprWithUndefinedVariableBehaviorMissing, compileOption: PERMISSIVE
  3. undefinedUnqualifiedVariableIsMissingExprWithUndefinedVariableBehaviorMissing, compileOption: PERMISSIVE

Now IGNORED Tests ❌

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

Now Passing Tests

180 test(s) were previously failing in BASE (LEGACY-V0.14.8) but now pass in TARGET (EVAL-0A305C4). 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-9D6D0E2) TARGET (EVAL-0A305C4) +/-
% Passing 94.39% 94.39% 0.00% ✅
Passing 5565 5565 0 ✅
Failing 50 50 0 ✅
Ignored 281 281 0 ✅
Total Tests 5896 5896 0 ✅

Testing Details

  • Base Commit: 9d6d0e2
  • Base Engine: EVAL
  • Target Commit: 0a305c4
  • Target Engine: EVAL

Result Details

  • Passing in both: 5565
  • Failing in both: 50
  • Ignored in both: 281
  • PASSING in BASE but now FAILING in TARGET: 0
  • PASSING in BASE but now IGNORED in TARGET: 0
  • FAILING in BASE but now PASSING in TARGET: 0
  • IGNORED in BASE but now PASSING in TARGET: 0

import java.util.List;

/**
* Match represents a subtree match to be sent to the
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
* Match represents a subtree match to be sent to the
* Match represents a subtree match to be sent to a strategy.

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.

LGTM

val input = "select * from [1,2] limit 100"
compile(input, strategy)
// assert the strategy was triggered
assertTrue(trigged, "the compiler did not apply the custom strategy")
Copy link
Member

Choose a reason for hiding this comment

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

Non-blocking nit.

Suggested change
assertTrue(trigged, "the compiler did not apply the custom strategy")
assertTrue(trigged, "the compiler applied the custom strategy")

@johnedquinn johnedquinn merged commit e2e7735 into v1 Nov 5, 2024
14 checks passed
@johnedquinn johnedquinn deleted the v1-udop branch November 5, 2024 01:34
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