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

Determine "Validity" of an AST #1236

Open
apmoriarty opened this issue Jul 28, 2021 · 2 comments
Open

Determine "Validity" of an AST #1236

apmoriarty opened this issue Jul 28, 2021 · 2 comments

Comments

@apmoriarty
Copy link
Collaborator

apmoriarty commented Jul 28, 2021

Expand upon the work done in #880 to validate the query tree structure.

@jwomeara suggested we add a mechanism in which we could drop all visitors into a "verify" state, so that after a visitor is done executing we could immediately validate the resulting query tree based on a number of criteria. So far the criteria might include

  1. Proper parentage
  2. Minimal parens/reference expressions (simplifies logic in other visitors)
  3. Ensure reference expressions have parent reference nodes (some visitors trigger on a reference node)
  4. Ensure And/Or nodes do not have a single child node (see Add a method to JexlASTHelper which checks for AND/OR nodes with a single child #1233)

Additional ideas and comments are welcome.

@apmoriarty
Copy link
Collaborator Author

Expressions like ((F == 'v') || F2 == 'v2') should reduce to (F == 'v' || F2 == 'v2'). Or more formally "no single term child of an intersection or union should be wrapped".

@lbschanno
Copy link
Collaborator

lbschanno commented Sep 9, 2021

Just want to add a comment that #603 is a bug that directly affects the work here. To summarize, retrieving the source nodes for a marker node may re-parent the source node and invalidate the original query tree.

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

No branches or pull requests

2 participants