@@ -79,6 +79,11 @@ impl VTable for Literal {
7979 stat : Stat ,
8080 _catalog : & dyn StatsCatalog ,
8181 ) -> Option < Expression > {
82+ // NOTE(ngates): we return incorrect `1` values for counts here since we don't have
83+ // row-count information. We could resolve this in the future by introducing a `count()`
84+ // expression that evaluates to the row count of the provided scope. But since this is
85+ // only currently used for pruning, it doesn't change the outcome.
86+
8287 match stat {
8388 Stat :: Min | Stat :: Max => Some ( lit ( expr. data ( ) . clone ( ) ) ) ,
8489 Stat :: IsConstant => Some ( lit ( true ) ) ,
@@ -91,23 +96,19 @@ impl VTable for Literal {
9196 }
9297
9398 match_each_float_ptype ! ( value. ptype( ) , |T | {
94- match value. typed_value:: <T >( ) {
95- None => Some ( lit( 0u64 ) ) ,
96- Some ( value ) if value . is_nan ( ) => Some ( lit ( 1u64 ) ) ,
97- _ => Some ( lit( 0u64 ) ) ,
99+ if value. typed_value:: <T >( ) . is_some_and ( |v| v . is_nan ( ) ) {
100+ Some ( lit( 1u64 ) )
101+ } else {
102+ Some ( lit( 0u64 ) )
98103 }
99104 } )
100105 }
101106 Stat :: NullCount => {
102- if expr. data ( ) . is_valid ( ) {
103- return Some ( lit ( 0u64 ) ) ;
107+ if expr. data ( ) . is_null ( ) {
108+ Some ( lit ( 1u64 ) )
109+ } else {
110+ Some ( lit ( 0u64 ) )
104111 }
105- // TODO(ngates): this is really annoying. Stats (at least those used for pruning)
106- // should represent bounds over the value of a single row. By referencing a
107- // "count" we have no way to return a stats expression that would allow is_null
108- // pruning. In practice, this might not be that important since most functionality
109- // should be absorbed by some form of constant folding.
110- None
111112 }
112113 Stat :: IsSorted | Stat :: IsStrictSorted | Stat :: Sum | Stat :: UncompressedSizeInBytes => {
113114 None
0 commit comments