Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions spark/src/test/resources/sql-tests/expressions/math/round.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
-- specific language governing permissions and limitations
-- under the License.

-- Config: spark.comet.exec.scalaUDF.codegen.enabled=true

-- Integral and non-negative-scale decimal inputs round natively. Float and double inputs have no
-- native implementation (Spark rounds them through BigDecimal built from Double.toString), so they
-- route through the codegen dispatcher and must match Spark exactly.
Expand All @@ -41,10 +43,14 @@ SELECT d, round(d), round(d, 0), round(d, 2), round(d, -1) FROM test_round
query expect_dispatch(round)
SELECT f, round(f), round(f, 0), round(f, 2), round(f, -1) FROM test_round

-- Null scale makes the whole result null without evaluating the child.
query
-- Null scale short-circuits in the dispatcher for floating-point inputs.
query expect_dispatch(round)
SELECT round(d, NULL), round(f, NULL) FROM test_round

-- Compatible inputs use the native serializer's null-scale branch.
query expect_native(round)
SELECT round(dec, NULL), round(i, NULL), round(l, NULL) FROM test_round

-- Decimal and integral inputs stay on the native path.
query expect_native(round)
SELECT dec, round(dec), round(dec, 2), round(dec, -1) FROM test_round
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, Version 2.0 (the
-- "License"); you may not use this file except in compliance
-- with the License. You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing,
-- software distributed under the License is distributed on an
-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- KIND, either express or implied. See the License for the
-- specific language governing permissions and limitations
-- under the License.

-- Config: spark.comet.exec.scalaUDF.codegen.enabled=false

-- Disabling the dispatcher keeps supported inputs native and sends floating-point inputs to Spark.
statement
CREATE TABLE test_round_disabled(d double, f float, dec decimal(10,4), i int, l bigint) USING parquet

statement
INSERT INTO test_round_disabled VALUES
(2.5, 2.5, 2.5, 25, 25),
(-2.5, -2.5, -2.5, -25, -25),
(NULL, NULL, NULL, NULL, NULL)

query expect_native(round)
SELECT round(dec, 2), round(i, -1), round(l, -1) FROM test_round_disabled

query expect_fallback(round: spark.comet.exec.scalaUDF.codegen.enabled=false)
SELECT round(d, 2) FROM test_round_disabled

query expect_fallback(round: spark.comet.exec.scalaUDF.codegen.enabled=false)
SELECT round(f, 2) FROM test_round_disabled
Loading