Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Query: Improve extensibility of null semantics processor (#20854)
Resolves #20204 For table sources, there is no concept of nullability - `Visit(TableExpressionBase)` which works as dispatcher. - `Visit(SelectExpression)` as a special case to avoid casting and allow easy overriding. - No additional methods for individual table sources. For SQL expressions, - `Visit(SqlExpression, out bool nullable)` which defaults allowOptimizedExpansion to false. - `Visit(SqlExpression, allowOptimizedExpansion, out bool nullable)` which works as dispatcher. - Individual Visit* methods to change bahavior of any particular SqlExpression. Notes: - Each individual SQLExpression processes it's children with appropriately set allowOptimizedExpansion flag. It collects nullable flag for all children and return nullable for itself through out parameter. - NonNullableColumns are being used only in 2 places and both usages are different. Rather than crystal balling an API to expose it, we should just keep it private till a provider asks for it then we can discuss with provider writer what information is needed and how would they like it. Making it private does not cause any bug, may just miss an optimization in SQL. - Added AddNonNullableColumn API for providers to add aditional column to the list. - The processor does not derive from ExpressionVisitor anymore. It has ExpressionVisitor like dispatch system and API. - Since it is not deriving from SqlExpressionVisitor there is no longer abstract method to force implementing for new SqlExpression type. Hence unknown expression type throws exception. Making it pass through could cause incorrect result as we don't visit custom expression's components. - Added `VisitCustomSqlExpression` method to allow providers to add logic for custom functions without having to deal with non-nullable column reset. - Added DoNotCache method rather than exposing _canCache. - Changed API about returning tuple for caching to an out parameter.
- Loading branch information