|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// with the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +suite("fold_constant_cast") { |
| 19 | + sql "set enable_nereids_planner=true" |
| 20 | + sql "set enable_fallback_to_original_planner=false" |
| 21 | + sql "set enable_fold_constant_by_be=false" |
| 22 | + // bug_fix |
| 23 | + testFoldConst("select concat(substr('2025-03-20',1,4)-1,'-01-01')") |
| 24 | + testFoldConst("select concat(substr('2025-03-20',1,4)-1.0,'-01-01')") |
| 25 | + testFoldConst("select concat(substr('2025-03-20',1,4)+1.0,'-01-01')") |
| 26 | + testFoldConst("select concat(substr('2025-03-20',1,4)-0.5,'-01-01')") |
| 27 | + testFoldConst("select cast(cast(2025.00 as double) as string)") |
| 28 | + testFoldConst("select cast(cast(2025.00 as float) as string)") |
| 29 | + testFoldConst("SELECT CAST(CAST(123 AS DOUBLE) AS STRING)") |
| 30 | + testFoldConst("SELECT CAST(CAST(123.456 AS DOUBLE) AS STRING)") |
| 31 | + testFoldConst("SELECT CAST(CAST(-123.456 AS DOUBLE) AS STRING)") |
| 32 | + testFoldConst("SELECT CAST(CAST(0.001 AS DOUBLE) AS STRING)") |
| 33 | + testFoldConst("SELECT CAST(CAST(-0.001 AS DOUBLE) AS STRING)") |
| 34 | + testFoldConst("SELECT CAST(CAST(1e+10 AS DOUBLE) AS STRING)") |
| 35 | + testFoldConst("SELECT CAST(CAST(1e-10 AS DOUBLE) AS STRING)") |
| 36 | + testFoldConst("SELECT CAST(CAST(-1e+10 AS DOUBLE) AS STRING)") |
| 37 | + testFoldConst("SELECT CAST(CAST(-1e-10 AS DOUBLE) AS STRING)") |
| 38 | + testFoldConst("SELECT CAST(CAST(123456789.123456789 AS DOUBLE) AS STRING)") |
| 39 | + testFoldConst("SELECT CAST(CAST(-123456789.123456789 AS DOUBLE) AS STRING)") |
| 40 | + testFoldConst("SELECT CAST(CAST(0 AS DOUBLE) AS STRING)") |
| 41 | + testFoldConst("SELECT CAST(CAST(0.1 AS DOUBLE) AS STRING)") |
| 42 | + testFoldConst("SELECT CAST(CAST(-0.1 AS DOUBLE) AS STRING)") |
| 43 | + testFoldConst("SELECT CAST(CAST(123 AS FLOAT) AS STRING)") |
| 44 | + testFoldConst("SELECT CAST(CAST(123.456 AS FLOAT) AS STRING)") |
| 45 | + testFoldConst("SELECT CAST(CAST(-123.456 AS FLOAT) AS STRING)") |
| 46 | + testFoldConst("SELECT CAST(CAST(0.001 AS FLOAT) AS STRING)") |
| 47 | + testFoldConst("SELECT CAST(CAST(-0.001 AS FLOAT) AS STRING)") |
| 48 | + testFoldConst("SELECT CAST(CAST(1e+10 AS FLOAT) AS STRING)") |
| 49 | +} |
0 commit comments