# Copyright Materialize, Inc. and contributors. All rights reserved. # # Use of this software is governed by the Business Source License # included in the LICENSE file at the root of this repository. # # As of the Change Date specified in that file, in accordance with # the Business Source License, use of this software will be governed # by the Apache License, Version 2.0. # use mode cockroach because it "respects the scale of a Decimal type and the precision of a floating point number" # even though mode standard would allow easier file comparisons with the other computation mode mode cockroach # ------------------------------- # very small numbers # ------------------------------- statement ok CREATE OR REPLACE VIEW v_using_constant_folding (real1, double1, numeric1) AS SELECT 1e-39::real, 1e-39::double, 1e-39::numeric; query RRR SELECT * FROM v_using_constant_folding UNION ALL SELECT SUM(real1), SUM(double1), SUM(numeric1) FROM v_using_constant_folding; ---- 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001 0.000000000000000000000000000000000000001 query T multiline EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM v_using_constant_folding; ---- Explained Query (fast path): Constant - (0.000000000000000000000000000000000000001, 0.000000000000000000000000000000000000001, 0.000000000000000000000000000000000000001) Target cluster: quickstart EOF # ------------------------------- # very big numbers # ------------------------------- statement ok CREATE OR REPLACE VIEW v_using_constant_folding (real1, double1, numeric1) AS SELECT 1e38::real, 1e38::double, 1e38::numeric; query RRR SELECT * FROM v_using_constant_folding UNION ALL SELECT SUM(real1), SUM(double1), SUM(numeric1) FROM v_using_constant_folding; ---- 100000000000000000000000000000000000000 100000000000000000000000000000000000000 100000000000000000000000000000000000000 100000000000000000000000000000000000000 100000000000000000000000000000000000000 100000000000000000000000000000000000000 query T multiline EXPLAIN OPTIMIZED PLAN WITH (humanized expressions) AS VERBOSE TEXT FOR SELECT * FROM v_using_constant_folding; ---- Explained Query (fast path): Constant - (100000000000000000000000000000000000000, 100000000000000000000000000000000000000, 100000000000000000000000000000000000000) Target cluster: quickstart EOF