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

Refactor: Distinguish between FieldPredicate and SelectionFilter #3275

Merged
merged 1 commit into from
Jan 21, 2018

Conversation

kanitw
Copy link
Member

@kanitw kanitw commented Jan 17, 2018

(FieldPredicate can be useful in other scenario besides filter -- e.g., for condition in #3239 or for selecting data for annotation (@starry97's project)

cc: @starry97

@kanitw kanitw requested a review from domoritz January 19, 2018 23:00
@kanitw kanitw force-pushed the kw/field-predicate branch from 567910e to 1e74028 Compare January 19, 2018 23:00
### Selection Filter
## Selection Filter

For a selection filter object, a [`selection` name](#selectionfilter) must be provided.
Copy link
Member

Choose a reason for hiding this comment

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

This links to itself.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice catch!

@@ -30,13 +30,12 @@ Vega-Lite filter transforms must have the `filter` property.
For a [Vega Expression](https://vega.github.io/vega/docs/expressions/) string, each datum object can be referred using bound variable `datum`. For example, setting `filter` to `"datum.b2 > 60"` would make the output data includes only items that have values in the field `b2` over 60.


## Filter Object
## Field Predicate Object
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit inconsistent. Below, we call the filter "Selection Filter". I'd prefer to keep the name (it is also less confusing) and say that the "Filter Object" has to contain a "Filter Predicate". Alternatively, we could name it "Field Filter Object". The predicate is the expression that is used to filter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will change selection filter to selection predicate. We should not call them filters because they are also use for condition syntax in a follow-up PR. Field predicate is also more applicable in more places so we need to distinguish them. The old text is confusing anyway.

@kanitw kanitw force-pushed the kw/field-predicate branch 2 times, most recently from fe48c3e to 8cb65d6 Compare January 20, 2018 18:24
src/filter.ts Outdated
@@ -9,25 +9,30 @@ import {isArray, isString, logicalExpr} from './util';


export type Filter =
Copy link
Member Author

Choose a reason for hiding this comment

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

Actually Let me rename this whole thing to predicate

@kanitw kanitw force-pushed the kw/field-predicate branch from 8cb65d6 to b8fec23 Compare January 20, 2018 19:10
…edicate and SelectionFilter

Rationale: Predicate can be useful in other scenario besides filter -- e.g., for condition in #3239 or for selecting data for annotation (@starry97's project)
*/
filter: LogicalOperand<Filter>;
// TODO: https://github.com/vega/vega-lite/issues/2901
Copy link
Member

Choose a reason for hiding this comment

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

How much work is #2901?

Copy link
Member Author

@kanitw kanitw Jan 21, 2018

Choose a reason for hiding this comment

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

An hour or two -- in any case, it is NOT the scope of this PR. I'm just noting down something that was already missing. You're welcome to help contribute though.

name: Filter
link: "transform.html#filter"
"LogicalOperand<Predicate>":
link: "transform.html#predicate"
Copy link
Member

Choose a reason for hiding this comment

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

do you want to give this a better name?

Copy link
Member Author

@kanitw kanitw Jan 21, 2018

Choose a reason for hiding this comment

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

This is good since there is LogicalOperand<String> too

So having generic should allow us to write about it only once

Copy link
Member

Choose a reason for hiding this comment

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

I see. Go ahead and merge then.

@kanitw kanitw merged commit 88f546f into master Jan 21, 2018
@kanitw kanitw deleted the kw/field-predicate branch January 21, 2018 22:07
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.

2 participants