-
Notifications
You must be signed in to change notification settings - Fork 522
Implement row filtering on client side #10829
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
Conversation
Web viewer built successfully. If applicable, you should also test it:
Note: This comment is updated whenever you push a commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't say I follow everything happening here, but… looks good :)
Is there a way we can add a test for this without too much hassle?
@@ -190,6 +191,49 @@ impl DataframeQueryTableProvider { | |||
chunk_request, | |||
}) | |||
} | |||
|
|||
fn column_to_selector(column: &Column) -> Option<ComponentColumnSelector> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit/style: we usually prefer selector_from_column
(see CODE_STYLE.md
).
Mostly for consistency with matrices, but also writing it let selector = selector_from_column(column);
means the names in the function title is next to the types of the input/output variables (instead of being swizzled)
ComponentColumnSelector::from_str(column.name()).ok() | ||
} | ||
|
||
fn compute_column_is_not_null_filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use a docstring to explain that what this checks for, especially since the function name can be read two ways (does it return true for the filter foo == 42
since that is not a null filter?)
ComponentColumnSelector::from_str(column.name()).ok() | ||
} | ||
|
||
fn compute_column_is_not_null_filter( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this would read slightly better?
fn compute_column_is_not_null_filter( | |
fn compute_column_is_neq_null_filter( |
match expr { | ||
Expr::IsNotNull(inner) => { | ||
if let Expr::Column(col) = inner.as_ref() { | ||
return Ok(Self::column_to_selector(col)); | ||
} | ||
} | ||
Expr::Not(inner) => { | ||
if let Expr::IsNull(col_expr) = inner.as_ref() { | ||
if let Expr::Column(col) = col_expr.as_ref() { | ||
return Ok(Self::column_to_selector(col)); | ||
} | ||
} | ||
} | ||
Expr::BinaryExpr(binary) => { | ||
if binary.op == Operator::NotEq { | ||
if let (Expr::Column(col), Expr::Literal(sv)) | ||
| (Expr::Literal(sv), Expr::Column(col)) = | ||
(binary.left.as_ref(), binary.right.as_ref()) | ||
{ | ||
if sv.is_null() { | ||
return Ok(Self::column_to_selector(col)); | ||
} | ||
} | ||
} | ||
} | ||
_ => {} | ||
} | ||
|
||
Ok(None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this would read nicer with a helper function
match expr { | |
Expr::IsNotNull(inner) => { | |
if let Expr::Column(col) = inner.as_ref() { | |
return Ok(Self::column_to_selector(col)); | |
} | |
} | |
Expr::Not(inner) => { | |
if let Expr::IsNull(col_expr) = inner.as_ref() { | |
if let Expr::Column(col) = col_expr.as_ref() { | |
return Ok(Self::column_to_selector(col)); | |
} | |
} | |
} | |
Expr::BinaryExpr(binary) => { | |
if binary.op == Operator::NotEq { | |
if let (Expr::Column(col), Expr::Literal(sv)) | |
| (Expr::Literal(sv), Expr::Column(col)) = | |
(binary.left.as_ref(), binary.right.as_ref()) | |
{ | |
if sv.is_null() { | |
return Ok(Self::column_to_selector(col)); | |
} | |
} | |
} | |
} | |
_ => {} | |
} | |
Ok(None) | |
if is_neq_null(expr) { | |
Ok(Self::column_to_selector(col)) | |
} else { | |
Ok(None) | |
} |
That would also allow us to unit-test is_neq_null
if let Expr::IsNull(col_expr) = inner.as_ref() { | ||
if let Expr::Column(col) = col_expr.as_ref() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use let-chaining
if binary.op == Operator::NotEq { | ||
if let (Expr::Column(col), Expr::Literal(sv)) | ||
| (Expr::Literal(sv), Expr::Column(col)) = | ||
(binary.left.as_ref(), binary.right.as_ref()) | ||
{ | ||
if sv.is_null() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can use let-chaining
ddf569b
to
f172a07
Compare
Related
Closes https://github.com/rerun-io/dataplatform/issues/851
What
This PR identifies when the push down filters provided to the table provider are checking for a component that is not null. If so it pushes this filter down into the chunk store query. This reduces the amount of data coming out of the cpu worker thread and passed into the rest of the datafusion engine.
These are equivalent