|
16 | 16 | */ |
17 | 17 | package org.apache.gluten.execution.enhanced |
18 | 18 |
|
| 19 | +import org.apache.gluten.config.VeloxConfig |
19 | 20 | import org.apache.gluten.execution._ |
20 | 21 | import org.apache.gluten.tags.EnhancedFeaturesTest |
21 | 22 |
|
@@ -383,4 +384,139 @@ class VeloxIcebergSuite extends IcebergSuite { |
383 | 384 | } |
384 | 385 | } |
385 | 386 | } |
| 387 | + test("iceberg max aggregate with nulls enhanced true") { |
| 388 | + withSQLConf(VeloxConfig.ENABLE_ENHANCED_FEATURES.key -> "true") { |
| 389 | + withTable("store_sales_test_nulls_enhanced_true") { |
| 390 | + spark.sql(""" |
| 391 | + |create table store_sales_test_nulls_enhanced_true ( |
| 392 | + | ss_item_sk int, |
| 393 | + | ss_sales_price decimal(7,2) |
| 394 | + |) using iceberg |
| 395 | + |""".stripMargin) |
| 396 | + |
| 397 | + spark.sql(""" |
| 398 | + |insert into store_sales_test_nulls_enhanced_true values |
| 399 | + |(1, 200.00), |
| 400 | + |(2, 200.00), |
| 401 | + |(3, null), |
| 402 | + |(4, 199.98), |
| 403 | + |(5, 199.96) |
| 404 | + |""".stripMargin) |
| 405 | + |
| 406 | + val result = spark |
| 407 | + .sql("select max(ss_sales_price) from store_sales_test_nulls_enhanced_true") |
| 408 | + .collect() |
| 409 | + |
| 410 | + assert(result.length == 1, "Should return 1 row") |
| 411 | + assert(result(0).get(0) != null, "MAX should not return NULL") |
| 412 | + assert( |
| 413 | + result(0).getDecimal(0).doubleValue() == 200.00, |
| 414 | + s"MAX should return 200.00, but got ${result(0).get(0)}" |
| 415 | + ) |
| 416 | + } |
| 417 | + } |
| 418 | + } |
| 419 | + |
| 420 | + test("iceberg max aggregate without nulls enhanced true") { |
| 421 | + withSQLConf(VeloxConfig.ENABLE_ENHANCED_FEATURES.key -> "true") { |
| 422 | + withTable("store_sales_test_no_nulls_enhanced_true") { |
| 423 | + spark.sql(""" |
| 424 | + |create table store_sales_test_no_nulls_enhanced_true ( |
| 425 | + | ss_item_sk int, |
| 426 | + | ss_sales_price decimal(7,2) |
| 427 | + |) using iceberg |
| 428 | + |""".stripMargin) |
| 429 | + |
| 430 | + spark.sql(""" |
| 431 | + |insert into store_sales_test_no_nulls_enhanced_true values |
| 432 | + |(1, 200.00), |
| 433 | + |(2, 200.00), |
| 434 | + |(3, 200.00), |
| 435 | + |(4, 199.98), |
| 436 | + |(5, 199.96), |
| 437 | + |(6, 199.96), |
| 438 | + |(7, 199.92), |
| 439 | + |(8, 199.92), |
| 440 | + |(9, 199.92), |
| 441 | + |(10, 199.90), |
| 442 | + |(11, null) |
| 443 | + |""".stripMargin) |
| 444 | + |
| 445 | + val result = spark |
| 446 | + .sql("select max(ss_sales_price) from store_sales_test_no_nulls_enhanced_true where ss_sales_price is not null") |
| 447 | + .collect() |
| 448 | + |
| 449 | + assert(result.length == 1, "Should return 1 row") |
| 450 | + assert(result(0).get(0) != null, "MAX should not return NULL") |
| 451 | + assert( |
| 452 | + result(0).getDecimal(0).doubleValue() == 200.00, |
| 453 | + s"MAX should return 200.00, but got ${result(0).get(0)}" |
| 454 | + ) |
| 455 | + } |
| 456 | + } |
| 457 | + } |
| 458 | + |
| 459 | + test("iceberg max aggregate with nulls enhanced false") { |
| 460 | + withSQLConf(VeloxConfig.ENABLE_ENHANCED_FEATURES.key -> "false") { |
| 461 | + withTable("store_sales_test_nulls_enhanced_false") { |
| 462 | + spark.sql(""" |
| 463 | + |create table store_sales_test_nulls_enhanced_false ( |
| 464 | + | ss_item_sk int, |
| 465 | + | ss_sales_price decimal(7,2) |
| 466 | + |) using iceberg |
| 467 | + |""".stripMargin) |
| 468 | + |
| 469 | + spark.sql(""" |
| 470 | + |insert into store_sales_test_nulls_enhanced_false values |
| 471 | + |(1, 200.00), |
| 472 | + |(2, 199.98), |
| 473 | + |(3, null), |
| 474 | + |(4, 199.96) |
| 475 | + |""".stripMargin) |
| 476 | + |
| 477 | + val result = spark |
| 478 | + .sql("select max(ss_sales_price) from store_sales_test_nulls_enhanced_false") |
| 479 | + .collect() |
| 480 | + |
| 481 | + assert(result.length == 1, "Should return 1 row") |
| 482 | + assert(result(0).get(0) != null, "MAX should not return NULL") |
| 483 | + assert( |
| 484 | + result(0).getDecimal(0).doubleValue() == 200.00, |
| 485 | + s"MAX should return 200.00, but got ${result(0).get(0)}" |
| 486 | + ) |
| 487 | + } |
| 488 | + } |
| 489 | + } |
| 490 | + |
| 491 | + test("iceberg max aggregate without nulls enhanced false") { |
| 492 | + withSQLConf(VeloxConfig.ENABLE_ENHANCED_FEATURES.key -> "false") { |
| 493 | + withTable("store_sales_test_no_nulls_enhanced_false") { |
| 494 | + spark.sql(""" |
| 495 | + |create table store_sales_test_no_nulls_enhanced_false ( |
| 496 | + | ss_item_sk int, |
| 497 | + | ss_sales_price decimal(7,2) |
| 498 | + |) using iceberg |
| 499 | + |""".stripMargin) |
| 500 | + |
| 501 | + spark.sql(""" |
| 502 | + |insert into store_sales_test_no_nulls_enhanced_false values |
| 503 | + |(1, 200.00), |
| 504 | + |(2, 199.98), |
| 505 | + |(3, 199.96), |
| 506 | + |(4, null) |
| 507 | + |""".stripMargin) |
| 508 | + |
| 509 | + val result = spark |
| 510 | + .sql("select max(ss_sales_price) from store_sales_test_no_nulls_enhanced_false where ss_sales_price is not null") |
| 511 | + .collect() |
| 512 | + |
| 513 | + assert(result.length == 1, "Should return 1 row") |
| 514 | + assert(result(0).get(0) != null, "MAX should not return NULL") |
| 515 | + assert( |
| 516 | + result(0).getDecimal(0).doubleValue() == 200.00, |
| 517 | + s"MAX should return 200.00, but got ${result(0).get(0)}" |
| 518 | + ) |
| 519 | + } |
| 520 | + } |
| 521 | + } |
386 | 522 | } |
0 commit comments