[CALCITE-6219] 'Must-filter' columns

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/calcite#3688

Co-authored-by: Julian Hyde <jhyde@apache.org>
15 files changed
tree: 1e6920e2d17e9e0f41edb2d6a6e9dcee9505f880
  1. .github/
  2. .idea/
  3. babel/
  4. bom/
  5. buildSrc/
  6. cassandra/
  7. core/
  8. druid/
  9. elasticsearch/
  10. example/
  11. file/
  12. geode/
  13. gradle/
  14. innodb/
  15. kafka/
  16. linq4j/
  17. mongodb/
  18. pig/
  19. piglet/
  20. plus/
  21. redis/
  22. release/
  23. server/
  24. site/
  25. spark/
  26. splunk/
  27. src/
  28. testkit/
  29. ubenchmark/
  30. .asf.yaml
  31. .editorconfig
  32. .gitattributes
  33. .gitignore
  34. .mailmap
  35. .ratignore
  36. build.gradle.kts
  37. gradle.properties
  38. gradlew
  39. gradlew.bat
  40. Jenkinsfile
  41. LICENSE
  42. NOTICE
  43. README
  44. README.md
  45. settings.gradle.kts
  46. sqlline
  47. sqlline.bat
  48. sqlsh
  49. sqlsh.bat
README.md

Maven Central CI Status

Apache Calcite

Apache Calcite is a dynamic data management framework.

It contains many of the pieces that comprise a typical database management system but omits the storage primitives. It provides an industry standard SQL parser and validator, a customisable optimizer with pluggable rules and cost functions, logical and physical algebraic operators, various transformation algorithms from SQL to algebra (and the opposite), and many adapters for executing SQL queries over Cassandra, Druid, Elasticsearch, MongoDB, Kafka, and others, with minimal configuration.

For more details, see the home page.

The project uses JIRA for issue tracking. For further information, please see the JIRA accounts guide.