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

Fix head command and match the whole query to the grammar #52

Merged
merged 8 commits into from
Aug 9, 2024

Conversation

51-code
Copy link
Contributor

@51-code 51-code commented Jul 31, 2024

Fixes issues #8 and #39.

This PR introduces two changes:

  • Head command's grammar has been changed in preparation for implementing it in PTH-10. This is in the same PR as the following change, because the tests depend on it.
  • The grammar now requires the whole query to be grammatically correct. Currently it stops parsing silently in some cases without an exception thrown.

So firstly the head command:

  • Fixed the command not returning from it's mode after a PIPE ("|") token. (This is the issue head does not parse correctly #8)
  • Grammar changes: it is now possible to write the parameters on either side of the integer or the eval statement. Limit is not allowed together with the integer anymore. The integer was moved to its own grammar rule for a more convenient parse tree.
  • If there are multiple parameters given, it is now left for PTH-10 to throw an exception in these cases. There is no good way of allowing parameters in any order, but just once.

Explanation on the grammar requiring the whole query to be written correctly:
I have added an EOF (end-of-file) token in the end of the root grammar rule. This means that now the whole query has to be grammatically correct, not just a subset like before. This oversight introduced many bugs where the parser doesn't throw any exceptions in certain cases that are explained in #39. A query would only parse until some point, leaving the rest of the query, perhaps whole commands, ineffective from the user's point of view.

This change made a whole bunch of tests fail, as many queries in the tests already had the bug. I have written these queries correctly, or if they queries were correct, I disabled the tests and made an issue about the grammar problems the respective commands have.

@51-code 51-code added bug Something isn't working feature Existing feature labels Jul 31, 2024
@51-code
Copy link
Contributor Author

51-code commented Aug 5, 2024

Noticed that it wasn't possible to use just the head command without any parameters after my changes. Changed this back to how it was meant to be and made a test for that as well.

Copy link
Contributor

@eemhu eemhu left a comment

Choose a reason for hiding this comment

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

LGTM, see if you can change the exception to specific one as mentioned before

@kortemik
Copy link
Member

kortemik commented Aug 5, 2024

is there a metaissue for re-enabling the broken tests that were disabled in this commit? why there are changes to test payload files? if tests are broken, they should be disabled, if input is incorrect, it should be mentioned that they were not correct and be corrected.

@51-code
Copy link
Contributor Author

51-code commented Aug 5, 2024

There has been issues opened about all the disabled tests individually, would it be okay if I edited those issues to inform which tests should be enabled after solving them? Or just a new issue for all of the disabled issues together?

For the latter question: I went through the broken tests (the tests that were throwing an exception with the root rule change). Some of the tests were simply broken because of incorrect test payloads and I fixed those. If the payload was correct, I disabled the test (this would mean that the grammar itself is broken). Should I mention theses incorrect payloads in the code, or where? A general note about that was in the bottom of the PR message.

@kortemik
Copy link
Member

kortemik commented Aug 5, 2024

Please add the note about incorrect payload and link to pr into the individually created issues. Please create a meta-issue and link these issues into the meta-issue.

@51-code
Copy link
Contributor Author

51-code commented Aug 6, 2024

Please add the note about incorrect payload and link to pr into the individually created issues. Please create a meta-issue and link these issues into the meta-issue.

Disabled tests have now been listen in each issue separately. A note has been added for test payload changes as well. Meta issue about re-enabling the issues has been created and the issues in question has been listed in it.

Furthermore, I changed two payloads back to how they were: tickets71_A and tickets_71. These were in fact grammatically correct. I created a new test for these and disabled that as it still fails with the current grammar.

I have not made notes about the changes in payloads delta.txt and chart4.txt. These do not have any open issues because the payloads were grammatically incorrect, which lead to their corresponding tests failing. So, the grammar is fine and has no issues, but the test payload was wrong, giving a false negative.

@kortemik
Copy link
Member

kortemik commented Aug 6, 2024

approved!

@kortemik kortemik merged commit cd379e2 into teragrep:main Aug 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature Existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants