Skip to content

Commit eeb9b74

Browse files
author
infvg
committed
Temp test
1 parent 260e585 commit eeb9b74

1 file changed

Lines changed: 106 additions & 0 deletions

File tree

backends-velox/src-iceberg/test/scala/org/apache/gluten/execution/enhanced/VeloxIcebergSuite.scala

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717
package org.apache.gluten.execution.enhanced
1818

19+
import org.apache.gluten.config.VeloxConfig
1920
import org.apache.gluten.execution._
2021
import org.apache.gluten.tags.EnhancedFeaturesTest
2122

@@ -383,4 +384,109 @@ class VeloxIcebergSuite extends IcebergSuite {
383384
}
384385
}
385386
}
387+
388+
test("iceberg max aggregate") {
389+
withSQLConf(VeloxConfig.ENABLE_ENHANCED_FEATURES.key -> "true") {
390+
withTable("store_sales_test") {
391+
// Create a simple test table with decimal prices
392+
spark.sql("""
393+
|create table store_sales_test (
394+
| ss_item_sk int,
395+
| ss_sales_price decimal(7,2)
396+
|) using iceberg
397+
|""".stripMargin)
398+
399+
// Insert test data matching the issue description
400+
spark.sql("""
401+
|insert into store_sales_test values
402+
|(1, 200.00),
403+
|(2, 200.00),
404+
|(3, 200.00),
405+
|(4, 199.98),
406+
|(5, 199.96),
407+
|(6, 199.96),
408+
|(7, 199.92),
409+
|(8, 199.92),
410+
|(9, 199.92),
411+
|(10, 199.90)
412+
|""".stripMargin)
413+
414+
// Test 1: Verify ORDER BY DESC LIMIT works correctly
415+
val orderByResult = spark
416+
.sql(
417+
"select ss_sales_price from store_sales_test order by ss_sales_price desc limit 10"
418+
)
419+
.collect()
420+
421+
assert(orderByResult.length == 10, "Should return 10 rows")
422+
assert(
423+
orderByResult(0).getDecimal(0).doubleValue() == 200.00,
424+
"First value should be 200.00")
425+
426+
// Test 2: MAX aggregate without WHERE clause - THIS IS THE BUG
427+
// With enhancedFeatures=true, this returns NULL incorrectly
428+
val maxResult = spark
429+
.sql(
430+
"select max(ss_sales_price) from store_sales_test"
431+
)
432+
.collect()
433+
434+
assert(maxResult.length == 1, "Should return 1 row")
435+
assert(maxResult(0).get(0) != null, "MAX should not return NULL")
436+
assert(
437+
maxResult(0).getDecimal(0).doubleValue() == 200.00,
438+
s"MAX should return 200.00, but got ${maxResult(0).get(0)}"
439+
)
440+
441+
// Test 3: MAX aggregate with WHERE clause - this works correctly
442+
val maxWithWhereResult = spark
443+
.sql(
444+
"select max(ss_sales_price) from store_sales_test where ss_sales_price is not null"
445+
)
446+
.collect()
447+
448+
assert(maxWithWhereResult.length == 1, "Should return 1 row")
449+
assert(maxWithWhereResult(0).get(0) != null, "MAX with WHERE should not return NULL")
450+
assert(
451+
maxWithWhereResult(0).getDecimal(0).doubleValue() == 200.00,
452+
s"MAX with WHERE should return 200.00, but got ${maxWithWhereResult(0).get(0)}"
453+
)
454+
}
455+
}
456+
withSQLConf(VeloxConfig.ENABLE_ENHANCED_FEATURES.key -> "false") {
457+
withTable("store_sales_test_disabled") {
458+
// Create a simple test table with decimal prices
459+
spark.sql("""
460+
|create table store_sales_test_disabled (
461+
| ss_item_sk int,
462+
| ss_sales_price decimal(7,2)
463+
|) using iceberg
464+
|""".stripMargin)
465+
466+
// Insert test data
467+
spark.sql("""
468+
|insert into store_sales_test_disabled values
469+
|(1, 200.00),
470+
|(2, 199.98),
471+
|(3, 199.96)
472+
|""".stripMargin)
473+
474+
// With enhancedFeatures=false, MAX should work correctly
475+
val maxResult = spark
476+
.sql(
477+
"select max(ss_sales_price) from store_sales_test_disabled"
478+
)
479+
.collect()
480+
481+
assert(maxResult.length == 1, "Should return 1 row")
482+
assert(
483+
maxResult(0).get(0) != null,
484+
"MAX should not return NULL with enhancedFeatures=false")
485+
assert(
486+
maxResult(0).getDecimal(0).doubleValue() == 200.00,
487+
s"MAX should return 200.00, but got ${maxResult(0).get(0)}"
488+
)
489+
}
490+
}
491+
}
386492
}

0 commit comments

Comments
 (0)