miller icon indicating copy to clipboard operation
miller copied to clipboard

filter acts as put

Open aborruso opened this issue 1 year ago • 6 comments

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

aborruso avatar Oct 21 '24 15:10 aborruso

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

johnkerl avatar Oct 21 '24 16:10 johnkerl

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?

aborruso avatar Oct 21 '24 16:10 aborruso

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

johnkerl avatar Oct 21 '24 16:10 johnkerl

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

aborruso avatar Oct 21 '24 16:10 aborruso

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".)

johnkerl avatar Oct 21 '24 16:10 johnkerl

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

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

aborruso avatar Oct 21 '24 16:10 aborruso