You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// duckdb.sql("select sum(l_extendedprice) / 7.0 as avg_yearly from lineitem, part where p_partkey = l_partkey and p_brand = 'Brand#23' and p_container = 'MED BOX' and l_quantity < (select 0.2 * avg(l_quantity) from lineitem where l_partkey = p_partkey )")
1396
+
// ```
1397
+
// That is the same as DataFusion's output.
1398
+
#[ignore = "the expected result is 348406.02 whereas both DataFusion and DuckDB return 348406.05"]
1371
1399
#[tokio::test]
1372
1400
asyncfnq17() -> Result<()>{
1373
1401
verify_query(17).await
@@ -1534,6 +1562,72 @@ mod tests {
1534
1562
Ok(())
1535
1563
}
1536
1564
1565
+
// We read the expected results from CSV files so we need to normalize the
1566
+
// query results before we compare them with the expected results for the
1567
+
// following reasons:
1568
+
//
1569
+
// 1. Float numbers have only two digits after the decimal point in CSV so
1570
+
// we need to convert results to Decimal(15, 2) and then back to floats.
1571
+
//
1572
+
// 2. Decimal numbers are fixed as Decimal(15, 2) in CSV.
1573
+
//
1574
+
// 3. Strings may have trailing spaces and need to be trimmed.
1575
+
//
1576
+
// 4. Rename columns using the expected schema to make schema matching
1577
+
// because, for q18, we have aggregate field `sum(l_quantity)` that is
1578
+
// called `sum_l_quantity` in the expected results.
1579
+
asyncfnnormalize_for_verification(
1580
+
batches:Vec<RecordBatch>,
1581
+
expected_schema:Schema,
1582
+
) -> Result<Vec<RecordBatch>>{
1583
+
if batches.is_empty(){
1584
+
returnOk(vec![]);
1585
+
}
1586
+
let ctx = SessionContext::new();
1587
+
let schema = batches[0].schema();
1588
+
let df = ctx.read_batches(batches)?;
1589
+
let df = df.select(
1590
+
schema
1591
+
.fields()
1592
+
.iter()
1593
+
.zip(expected_schema.fields())
1594
+
.map(|(field, expected_field)| {
1595
+
matchField::data_type(field){
1596
+
// Normalize decimals to Decimal(15, 2)
1597
+
DataType::Decimal128(_, _) => {
1598
+
// We convert to float64 and then to decimal(15, 2).
1599
+
// Directly converting between Decimals caused test
0 commit comments