File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -195,11 +195,40 @@ impl ToDuckSQL for Expr {
195
195
{
196
196
format ! ( "{} {} {}" , a[ 0 ] , op, a[ 1 ] )
197
197
} else {
198
- unreachable ! ( )
198
+ return Err ( Error :: InvalidOperator ( op . to_string ( ) ) ) ;
199
199
}
200
200
}
201
201
}
202
202
}
203
203
} )
204
204
}
205
205
}
206
+
207
+ #[ cfg( test) ]
208
+ mod tests {
209
+ use super :: ToDuckSQL ;
210
+ use crate :: { Error , Expr } ;
211
+
212
+ #[ test]
213
+ fn unreachable_code ( ) {
214
+ // https://github.com/stac-utils/rustac-py/issues/135
215
+ let expr: Expr = serde_json:: from_value ( serde_json:: json!( {
216
+ "op" : "and" ,
217
+ "args" : [
218
+ {
219
+ "op" : "eq" ,
220
+ "args" : [ { "property" : "forecast:horizon" } , "PT48H" ]
221
+ } ,
222
+ {
223
+ "op" : "gte" ,
224
+ "args" : [ { "property" : "forecast:reference_time" } , "2025-05-15T00:00:00Z" ]
225
+ } ,
226
+ ] ,
227
+ } ) )
228
+ . unwrap ( ) ;
229
+ assert ! ( matches!(
230
+ expr. to_ducksql( ) . unwrap_err( ) ,
231
+ Error :: InvalidOperator ( _)
232
+ ) ) ;
233
+ }
234
+ }
Original file line number Diff line number Diff line change @@ -87,6 +87,10 @@ pub enum Error {
87
87
#[ error( "Operator {0} is not implemented for this type." ) ]
88
88
OpNotImplemented ( & ' static str ) ,
89
89
90
+ /// Invalid operator
91
+ #[ error( "{0} is not a valid operator." ) ]
92
+ InvalidOperator ( String ) ,
93
+
90
94
/// Expression not reduced to boolean
91
95
#[ error( "Could not reduce expression to boolean" ) ]
92
96
NonReduced ( ) ,
You can’t perform that action at this time.
0 commit comments