You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datafusion.apache.org by gi...@apache.org on 2026/10/05 13:50:05 UTC
(datafusion-comet) branch gh-readonly-queue/main/pr-6397-f0514294c9920a704e9c229e9c3e747c0c9c79fe created (now ba08acd815)
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a change to branch gh-readonly-queue/main/pr-6397-f0514294c9920a704e9c229e9c3e747c0c9c79fe
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git
at ba08acd815 perf: optimize IF column and literal selection (#6397)
This branch includes the following new commits:
new ba08acd815 perf: optimize IF column and literal selection (#6397)
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org
(datafusion-comet) 01/01: perf: optimize IF column and literal selection (#6397)
Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-6397-f0514294c9920a704e9c229e9c3e747c0c9c79fe
in repository https://gitbox.apache.org/repos/asf/datafusion-comet.git
commit ba08acd815d5fd15f75ce9f314715778b9161cf1
Author: KUAN-HAO HUANG <10...@users.noreply.github.com>
AuthorDate: Mon Oct 5 12:33:56 2026 +0000
perf: optimize IF column and literal selection (#6397)
---
.../sql-tests/expressions/conditional/if_expr.sql | 49 ++++++++++++++++++++++
1 file changed, 49 insertions(+)
diff --git a/spark/src/test/resources/sql-tests/expressions/conditional/if_expr.sql b/spark/src/test/resources/sql-tests/expressions/conditional/if_expr.sql
index 53b908ca79..fed6ed317f 100644
--- a/spark/src/test/resources/sql-tests/expressions/conditional/if_expr.sql
+++ b/spark/src/test/resources/sql-tests/expressions/conditional/if_expr.sql
@@ -15,6 +15,9 @@
-- specific language governing permissions and limitations
-- under the License.
+-- Config: spark.sql.ansi.enabled=true
+-- Config: spark.comet.batchSize=2
+
statement
CREATE TABLE test_if(cond boolean, a int, b int) USING parquet
@@ -30,3 +33,49 @@ SELECT IF(a > 0, 'positive', 'non-positive') FROM test_if
-- literal arguments
query
SELECT IF(true, 1, 2), IF(false, 1, 2), IF(NULL, 1, 2)
+
+-- Both column/literal directions, NULL conditions and unselected NULL values.
+query expect_native(if)
+SELECT IF(cond, a, 9), IF(cond, 9, a) FROM test_if
+
+-- NULL literals and computed branches preserve branch selection.
+query expect_native(if)
+SELECT IF(cond, a, NULL), IF(cond, NULL, b), IF(cond, a + 1, b - 1) FROM test_if
+
+-- Spark inserts branch casts when the result types differ.
+query expect_native(if)
+SELECT IF(cond, a, 9L), IF(cond, 9L, a) FROM test_if
+
+statement
+CREATE TABLE test_if_values(cond boolean, d double, s string) USING parquet
+
+statement
+INSERT INTO test_if_values VALUES (true, cast('NaN' AS DOUBLE), ''), (false, -0.0D, '中文'), (NULL, cast('Infinity' AS DOUBLE), NULL), (true, NULL, 'longer value'), (false, 7.0D, '')
+
+query expect_native(if)
+SELECT IF(cond, d, 0D), IF(cond, 0D, d), IF(isnan(d), 0D, d) FROM test_if_values
+
+query expect_native(if)
+SELECT IF(cond, s, 'replacement'), IF(cond, '中文', s) FROM test_if_values
+
+statement
+CREATE TABLE test_if_lazy(cond boolean, raw string) USING parquet
+
+statement
+INSERT INTO test_if_lazy VALUES (true, '7'), (false, 'bad'), (NULL, 'bad')
+
+-- Only selected rows may reach the fallible cast.
+query expect_native(if)
+SELECT IF(cond, cast(raw AS INT), 0) FROM test_if_lazy
+
+query expect_error(CAST_INVALID_INPUT)
+SELECT IF(cond, 0, cast(raw AS INT)) FROM test_if_lazy
+
+statement
+CREATE TABLE test_if_numeric(cond boolean, f float, l bigint) USING parquet
+
+statement
+INSERT INTO test_if_numeric VALUES (true, cast('NaN' AS FLOAT), -9223372036854775808L), (false, -0.0F, 9223372036854775807L), (NULL, cast('-Infinity' AS FLOAT), NULL), (true, NULL, 1L), (false, 7.0F, -1L)
+
+query expect_native(if)
+SELECT IF(cond, f, 0F), IF(cond, 0F, f), IF(cond, l, 0L), IF(cond, 0L, l) FROM test_if_numeric
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datafusion.apache.org
For additional commands, e-mail: commits-help@datafusion.apache.org