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

Add filter for valid fields. Fixes #4098 #4109

Merged
merged 7 commits into from Aug 3, 2018
Merged

Add filter for valid fields. Fixes #4098 #4109

merged 7 commits into from Aug 3, 2018

Conversation

domoritz
Copy link
Member

@domoritz domoritz commented Aug 2, 2018

No description provided.

@domoritz domoritz requested a review from kanitw August 2, 2018 18:55
src/predicate.ts Outdated
@@ -139,12 +141,20 @@ export interface FieldOneOfPredicate extends FieldPredicateBase {
oneOf: string[] | number[] | boolean[] | DateTime[];
}

export interface FieldValidPredicate extends FieldPredicateBase {
valid: true;
Copy link
Member

Choose a reason for hiding this comment

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

This should support false too. Users may want to analyze the pattern of data that have some fields missing.

Copy link
Member Author

Choose a reason for hiding this comment

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

You can always use not. I'd rather support fewer ways to do the same thing for now. We can change it later.

Copy link
Member

Choose a reason for hiding this comment

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

I disagree. Users wouldn't expect that it can't be false, so better fix it now since it's very easy and provides a way nicer syntax that nesting it under "not".


{% include table.html props="valid" source="FieldValidPredicate" %}

For example, `{"filter": {"field": "car_color", "valid": true}}` checks if the `car_color` field's value is not `null` and whether it is not `NaN`.
Copy link
Member

Choose a reason for hiding this comment

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

Adjust the language to make it clear which data items would be included.

@domoritz
Copy link
Member Author

domoritz commented Aug 2, 2018

Done

@domoritz
Copy link
Member Author

domoritz commented Aug 2, 2018

I added some tests

@domoritz
Copy link
Member Author

domoritz commented Aug 3, 2018

100% patch coverage

return 'indexof([' + predicateValuesExpr(predicate.oneOf, timeUnit).join(',') + '], ' + fieldExpr + ') !== -1';
return `indexof([${predicateValuesExpr(predicate.oneOf, timeUnit).join(',')}], ${fieldExpr}) !== -1`;
} else if (isFieldValidPredicate(predicate)) {
return predicate.valid ? `${fieldExpr}!==null&&!isNaN(${fieldExpr})` : `${fieldExpr}===null||isNaN(${fieldExpr})`;
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer having spaces for readability.

It might be worth submitting another PR to standardize other the filter expressions too.
(Currently, some do have spaces between operators, some do not.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's do this in a follow up. Issue: #4112

@kanitw kanitw merged commit 00af35f into master Aug 3, 2018
@kanitw kanitw deleted the dom/filter-valid branch August 3, 2018 03:53
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.

None yet

2 participants