Skip to content

Commit af34fa9

Browse files
committed
test: drop redundant Rust unit tests, add selective cast filter case to slt
1 parent 184843e commit af34fa9

2 files changed

Lines changed: 7 additions & 49 deletions

File tree

‎datafusion/physical-expr/src/intervals/utils.rs‎

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -197,52 +197,3 @@ fn interval_dt_to_duration_ms(dt: &IntervalDayTime) -> Result<i64> {
197197
)
198198
}
199199
}
200-
201-
#[cfg(test)]
202-
mod tests {
203-
use super::*;
204-
205-
use crate::expressions::{cast, col};
206-
207-
use arrow::datatypes::{Field, Schema};
208-
209-
fn int32_schema() -> SchemaRef {
210-
Arc::new(Schema::new(vec![Field::new("id", DataType::Int32, false)]))
211-
}
212-
213-
#[test]
214-
fn test_check_support_rejects_unsupported_cast_target() -> Result<()> {
215-
let schema = int32_schema();
216-
let id = col("id", schema.as_ref())?;
217-
218-
// Casting an interval-friendly column to a type interval arithmetic does
219-
// not understand must not be analyzed: string ordering and numeric
220-
// ordering are not interchangeable, so endpoint-wise casting can produce
221-
// a reversed interval.
222-
let to_utf8 = cast(Arc::clone(&id), schema.as_ref(), DataType::Utf8)?;
223-
assert!(!check_support(&to_utf8, &schema));
224-
225-
// The same holds when the unsupported type only appears in the middle of
226-
// a cast chain whose outermost type is supported.
227-
let round_trip = cast(to_utf8, schema.as_ref(), DataType::Int32)?;
228-
assert!(!check_support(&round_trip, &schema));
229-
230-
Ok(())
231-
}
232-
233-
#[test]
234-
fn test_check_support_allows_supported_cast_target() -> Result<()> {
235-
let schema = int32_schema();
236-
let id = col("id", schema.as_ref())?;
237-
238-
assert!(check_support(&id, &schema));
239-
240-
let to_int64 = cast(Arc::clone(&id), schema.as_ref(), DataType::Int64)?;
241-
assert!(check_support(&to_int64, &schema));
242-
243-
let to_float64 = cast(to_int64, schema.as_ref(), DataType::Float64)?;
244-
assert!(check_support(&to_float64, &schema));
245-
246-
Ok(())
247-
}
248-
}

‎datafusion/sqllogictest/test_files/cast.slt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,13 @@ SELECT id FROM cast_interval_text_ids WHERE CAST(id AS INT) > 1 ORDER BY id;
356356
10
357357
2
358358

359+
# Selective filtering through the cast must apply the numeric predicate after
360+
# casting, not string-ordered interval bounds derived from the statistics.
361+
query T
362+
SELECT id FROM cast_interval_text_ids WHERE CAST(id AS INT) > 5;
363+
----
364+
10
365+
359366
statement ok
360367
DROP VIEW cast_interval_text_ids;
361368

0 commit comments

Comments
 (0)