@@ -395,6 +395,8 @@ suite("fold_constant_string_arithmatic") {
395395 testFoldConst(" select left('上海天津北京杭州', 5)" )
396396 testFoldConst(" select left('上海天津北京杭州', -5)" )
397397 testFoldConst(" select left('上海天津北京杭州', 0)" )
398+ testFoldConst(" select left('20250409'-10000, 6)" )
399+
398400
399401 // length
400402 testFoldConst(" select length('你')" )
@@ -1724,5 +1726,104 @@ suite("fold_constant_string_arithmatic") {
17241726 testFoldConst(" select split_by_string('a😁a😁a', '')" )
17251727 testFoldConst(" select character_length('a😁a😁a')" )
17261728 testFoldConst(" select replace_empty('a😁a😁a', '', '2')" )
1729+
1730+ // cast double to string like
1731+ testFoldConst(" select cast(cast(0 as double) as varchar(65533))" )
1732+ testFoldConst(" select cast(cast(0 as double) as string)" )
1733+ testFoldConst(" select cast(cast(0.0 as double) as varchar(65533))" )
1734+ testFoldConst(" select cast(cast(0.0 as double) as string)" )
1735+ testFoldConst(" select cast(cast(1 as double) as varchar(65533))" )
1736+ testFoldConst(" select cast(cast(1 as double) as string)" )
1737+ testFoldConst(" select cast(cast(1.0 as double) as varchar(65533))" )
1738+ testFoldConst(" select cast(cast(1.0 as double) as string)" )
1739+ testFoldConst(" select cast(cast(0.1 as double) as varchar(65533))" )
1740+ testFoldConst(" select cast(cast(0.1 as double) as string)" )
1741+ testFoldConst(" select cast(cast(1.1 as double) as varchar(65533))" )
1742+ testFoldConst(" select cast(cast(1.1 as double) as string)" )
1743+ testFoldConst(" select cast(cast(100000 as double) as string)" )
1744+ testFoldConst(" select cast(cast(1000000000000000 as double) as string)" )
1745+ testFoldConst(" select cast(cast(10000000000000000 as double) as string)" )
1746+ testFoldConst(" select cast(cast(100000000000000000 as double) as string)" )
1747+ testFoldConst(" select cast(cast(1000000000000000000 as double) as string)" )
1748+ testFoldConst(" select cast(cast(1.888 as double) as string)" )
1749+ testFoldConst(" select cast(cast(1.888777888777888 as double) as string)" )
1750+ testFoldConst(" select cast(cast(1.8887778887778887 as double) as string)" )
1751+ testFoldConst(" select cast(cast(1.888777888777888777 as double) as string)" )
1752+ testFoldConst(" select cast(cast(55556666.888777888777888777 as double) as string)" )
1753+ testFoldConst(" select cast(cast(555566667777.888777888777888777 as double) as string)" )
1754+ testFoldConst(" select cast(cast(5555666677778888.888777888777888777 as double) as string)" )
1755+ testFoldConst(" select cast(cast(55556666777788889.888777888777888777 as double) as string)" )
1756+ testFoldConst(" select cast(cast(55556666777788889999.888777888777888777 as double) as string)" )
1757+ testFoldConst(" select cast(cast(0.001 as double) as string)" )
1758+ testFoldConst(" select cast(cast(0.0001 as double) as string)" )
1759+ testFoldConst(" select cast(cast(0.00001 as double) as string)" )
1760+ testFoldConst(" select cast(cast(0.000001 as double) as string)" )
1761+ testFoldConst(" select cast(cast(0.0000001 as double) as string)" )
1762+ testFoldConst(" select cast(cast(0.00000001 as double) as string)" )
1763+ testFoldConst(" select cast(cast(0.00000001 as double) as string)" )
1764+ testFoldConst(" select cast(cast(0.000000000000001 as double) as string)" )
1765+ testFoldConst(" select cast(cast(0.0000000000000001 as double) as string)" )
1766+ testFoldConst(" select cast(cast(0.00000000000000001 as double) as string)" )
1767+ testFoldConst(" select cast(cast(0.000000000000000001 as double) as string)" )
1768+ testFoldConst(" select cast(cast(0.0000000000000000001 as double) as string)" )
1769+ testFoldConst(" select cast(cast(1e308 as double) as string)" )
1770+ testFoldConst(" select cast(cast(1e309 as double) as string)" )
1771+ testFoldConst(" select cast(cast(1e-308 as double) as string)" )
1772+ testFoldConst(" select cast(cast(1e-309 as double) as string)" )
1773+ testFoldConst(" select cast(cast(10000000000000001 as double) as string)" )
1774+ testFoldConst(" select cast(cast(10000000000000010 as double) as string)" )
1775+ testFoldConst(" select cast(cast(10000000000000100 as double) as string)" )
1776+
1777+ testFoldConst(" select cast(cast(-0 as double) as varchar(65533))" )
1778+ testFoldConst(" select cast(cast(-0 as double) as string)" )
1779+ testFoldConst(" select cast(cast(-0.0 as double) as varchar(65533))" )
1780+ testFoldConst(" select cast(cast(-0.0 as double) as string)" )
1781+ testFoldConst(" select cast(cast(-1 as double) as varchar(65533))" )
1782+ testFoldConst(" select cast(cast(-1 as double) as string)" )
1783+ testFoldConst(" select cast(cast(-1.0 as double) as varchar(65533))" )
1784+ testFoldConst(" select cast(cast(-1.0 as double) as string)" )
1785+ testFoldConst(" select cast(cast(-0.1 as double) as varchar(65533))" )
1786+ testFoldConst(" select cast(cast(-0.1 as double) as string)" )
1787+ testFoldConst(" select cast(cast(-1.1 as double) as varchar(65533))" )
1788+ testFoldConst(" select cast(cast(-1.1 as double) as string)" )
1789+ testFoldConst(" select cast(cast(-100000 as double) as string)" )
1790+ testFoldConst(" select cast(cast(-1000000000000000 as double) as string)" )
1791+ testFoldConst(" select cast(cast(-10000000000000000 as double) as string)" )
1792+ testFoldConst(" select cast(cast(-100000000000000000 as double) as string)" )
1793+ testFoldConst(" select cast(cast(-1000000000000000000 as double) as string)" )
1794+ testFoldConst(" select cast(cast(-1.888 as double) as string)" )
1795+ testFoldConst(" select cast(cast(-1.888777888777888 as double) as string)" )
1796+ testFoldConst(" select cast(cast(-1.8887778887778887 as double) as string)" )
1797+ testFoldConst(" select cast(cast(-1.888777888777888777 as double) as string)" )
1798+ testFoldConst(" select cast(cast(-55556666.888777888777888777 as double) as string)" )
1799+ testFoldConst(" select cast(cast(-555566667777.888777888777888777 as double) as string)" )
1800+ testFoldConst(" select cast(cast(-5555666677778888.888777888777888777 as double) as string)" )
1801+ testFoldConst(" select cast(cast(-55556666777788889.888777888777888777 as double) as string)" )
1802+ testFoldConst(" select cast(cast(-55556666777788889999.888777888777888777 as double) as string)" )
1803+ testFoldConst(" select cast(cast(-0.001 as double) as string)" )
1804+ testFoldConst(" select cast(cast(-0.0001 as double) as string)" )
1805+ testFoldConst(" select cast(cast(-0.00001 as double) as string)" )
1806+ testFoldConst(" select cast(cast(-0.000001 as double) as string)" )
1807+ testFoldConst(" select cast(cast(-0.0000001 as double) as string)" )
1808+ testFoldConst(" select cast(cast(-0.00000001 as double) as string)" )
1809+ testFoldConst(" select cast(cast(-0.00000001 as double) as string)" )
1810+ testFoldConst(" select cast(cast(-0.000000000000001 as double) as string)" )
1811+ testFoldConst(" select cast(cast(-0.0000000000000001 as double) as string)" )
1812+ testFoldConst(" select cast(cast(-0.00000000000000001 as double) as string)" )
1813+ testFoldConst(" select cast(cast(-0.000000000000000001 as double) as string)" )
1814+ testFoldConst(" select cast(cast(-0.0000000000000000001 as double) as string)" )
1815+ testFoldConst(" select cast(cast(-1e308 as double) as string)" )
1816+ testFoldConst(" select cast(cast(-1e309 as double) as string)" )
1817+ testFoldConst(" select cast(cast(-1e-308 as double) as string)" )
1818+ testFoldConst(" select cast(cast(-1e-309 as double) as string)" )
1819+ testFoldConst(" select cast(cast(-10000000000000001 as double) as string)" )
1820+ testFoldConst(" select cast(cast(-10000000000000010 as double) as string)" )
1821+ testFoldConst(" select cast(cast(-10000000000000100 as double) as string)" )
1822+ testFoldConst(" select cast(cast('nan' as double) as string)" )
1823+ testFoldConst(" select cast(cast('NaN' as double) as string)" )
1824+ testFoldConst(" select cast(cast('inf' as double) as string)" )
1825+ testFoldConst(" select cast(cast('-inf' as double) as string)" )
1826+ testFoldConst(" select cast(cast('Infinity' as double) as string)" )
1827+ testFoldConst(" select cast(cast('-Infinity' as double) as string)" )
17271828}
17281829
0 commit comments