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

filter acts as put #1696

Open
aborruso opened this issue Oct 21, 2024 · 6 comments
Open

filter acts as put #1696

aborruso opened this issue Oct 21, 2024 · 6 comments

Comments

@aborruso
Copy link
Contributor

Hi @johnkerl,
if write this wrong filter command

echo "a=0" | mlr filter '$a=10'

I get a=10.

I know the filter is wrong, I must use == and not =, however, I think that filter verb should never change the contents of cells.
Am I wrong?

Thank you

@johnkerl
Copy link
Owner

Correct, filter acts as put and the difference is just whether the final statement is used as a boolean to decide whether or not to forward the curent record

https://miller.readthedocs.io/en/6.13.0/reference-dsl/#differences-between-put-and-filter

@aborruso
Copy link
Contributor Author

Correct, filter acts as put and the difference is just whether the final statement is used as a boolean to decide whether or not to forward the curent record

Okay, so if I understand you, this should not happen and this is a bug. Am I wrong?

@johnkerl
Copy link
Owner

I guess I can assert that the final filter expression does evaluate to bool and abort the program if it doesn't -- ?

@aborruso
Copy link
Contributor Author

I guess I can assert that the final filter expression does evaluate to bool and abort the program if it doesn't -- ?

John, I am too basic a user and don't understand you all the time 😢

What I expected in a case like this was to have the same input content in the output, because the filter cannot filter anything out. Or for mlr to fail and exit, because the syntax is wrong.

Thank you

@johnkerl
Copy link
Owner

What I expected in a case like this was to have the same input content in the output, because the filter cannot filter anything out. Or for mlr to fail and exit, because the syntax is wrong.

I guess my question is, which of those two would you prefer? (My "I guess I can assert that the final filter expression does evaluate to bool and abort the program if it doesn't -- ?" is the same as your "Or for mlr to fail and exit, because the syntax is wrong".)

@aborruso
Copy link
Contributor Author

Ok, sorry @johnkerl , I understood you, thank you.

I would rather mlr come out and warn me that the syntax is wrong.

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