-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[CALCITE-6219] Must Filter validation #3688
[CALCITE-6219] Must Filter validation #3688
Conversation
Added many tests and cleaned up Fix style, delete unused add return in case block Fix all checkstyle and add java docs Remove unused remove unused inport checkstyle spacing fix and forbiddenApi removal Update validateClause() checkstyleMain test fix Missing @OverRide annotation Add missing @OverRide Add missing Override annotation Change to static annotation
…ss all tests Next step is to remove AlwaysFilterValidatorImpl and fix the various TODO
Quality Gate passedIssues Measures |
A table can declare that some of its columns must be filtered by implementing `interface SemanticTable`. If such columns are not filtered in a WHERE or HAVING clause, the validator throws. There are several purposes of these columns, one of which is to prevent expensive full-table scans (for example, reading all Orders without restricting on orderDate). Implementation is via the method SqlValidatorNamespace.getMustFilterFields(). For a table namespace, that method returns the declared must-filter fields. For a query namespce, that method returns any must-filter fields that have not been filtered in that query; such fields become the responsibility of the enclosing query. If a field is must-filter and is not in the SELECT clause of a sub-query, that is also an error, because of course it is now impossible for the enclosing query to filter it. Close apache#3688 Co-authored-by: Julian Hyde <jhyde@apache.org>
A table can declare that some of its columns must be filtered by implementing `interface SemanticTable`. If such columns are not filtered in a WHERE or HAVING clause, the validator throws. There are several purposes of these columns, one of which is to prevent expensive full-table scans (for example, reading all Orders without restricting on orderDate). Implementation is via the method SqlValidatorNamespace.getMustFilterFields(). For a table namespace, that method returns the declared must-filter fields. For a query namespce, that method returns any must-filter fields that have not been filtered in that query; such fields become the responsibility of the enclosing query. If a field is must-filter and is not in the SELECT clause of a sub-query, that is also an error, because of course it is now impossible for the enclosing query to filter it. Close apache#3688 Co-authored-by: Julian Hyde <jhyde@apache.org>
|
||
if (validator.config().identifierExpansion()) { | ||
SqlValidatorTable table = resolvedNamespace.getTable(); | ||
if (table != 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.
It's hard to tell on github but could we remove a level of nesting if we change this to if (table == null) { break; }
?
@@ -245,6 +244,24 @@ private SqlValidatorNamespace resolveImpl(SqlIdentifier id) { | |||
return rowType; | |||
} | |||
|
|||
@Override public void validateAlwaysFilter(Set<String> alwaysFilterFields) { | |||
resolvedNamespace = resolveImpl(id); | |||
if (resolvedNamespace instanceof TableNamespace) { |
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.
similar comment for some of these checks, we could change it to check if something is NOT true, and if it isn't then we just return, otherwise continue.
A table can declare that some of its columns must be filtered by implementing `interface SemanticTable`. If such columns are not filtered in a WHERE or HAVING clause, the validator throws. There are several purposes of these columns, one of which is to prevent expensive full-table scans (for example, reading all Orders without restricting on orderDate). Implementation is via the method SqlValidatorNamespace.getMustFilterFields(). For a table namespace, that method returns the declared must-filter fields. For a query namespce, that method returns any must-filter fields that have not been filtered in that query; such fields become the responsibility of the enclosing query. If a field is must-filter and is not in the SELECT clause of a sub-query, that is also an error, because of course it is now impossible for the enclosing query to filter it. Close apache#3688 Co-authored-by: Julian Hyde <jhyde@apache.org>
No description provided.