From 84cac3304a2acb70f75961e40ecb48fefa92a542 Mon Sep 17 00:00:00 2001 From: wiedld Date: Mon, 18 Mar 2024 10:54:04 -0700 Subject: [PATCH] test(9678): reproducer of alias causing expr elimination to error --- .../test_files/common_subexpr_eliminate.slt | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 datafusion/sqllogictest/test_files/common_subexpr_eliminate.slt diff --git a/datafusion/sqllogictest/test_files/common_subexpr_eliminate.slt b/datafusion/sqllogictest/test_files/common_subexpr_eliminate.slt new file mode 100644 index 0000000000000..ddfe849625d63 --- /dev/null +++ b/datafusion/sqllogictest/test_files/common_subexpr_eliminate.slt @@ -0,0 +1,45 @@ +# 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. + +############# +## Common Subexpr Eliminate Tests +############# + +statement ok +CREATE TABLE doubles ( + f64 DOUBLE +) as VALUES + (10.1) +; + +# common subexpr with coalesce +query RRR rowsort +select f64, coalesce(1.0 / f64, 0.0), acos(coalesce(1.0 / f64, 0.0)) from doubles; +---- +10.1 0.09900990099 1.471623942989 + +# common subexpr with alias +query RRR rowsort +select f64, round(1.0 / f64) as i64_1, acos(round(1.0 / f64)) from doubles; +---- +10.1 0 1.570796326795 + +# common subexpr with coalesce and alias +query RRR rowsort +select f64, coalesce(1.0 / f64, 0.0) as f64_1, acos(coalesce(1.0 / f64, 0.0)) from doubles; +---- +10.1 0.09900990099 1.471623942989