enable_numeric_rounding - Amazon Redshift

Amazon Redshift non supporterà più la creazione di nuove UDF Python a partire dal 1º novembre 2025. Se desideri utilizzare le UDF Python, creale prima di tale data. Le UDF Python esistenti continueranno a funzionare normalmente. Per ulteriori informazioni, consulta il post del blog.

enable_numeric_rounding

Valori (valore predefinito in grassetto)

attivato (true), disattivato (false)

Description

Specifica se utilizzare l'arrotondamento numerico. Se enable_numeric_rounding è on, Amazon Redshift arrotonda i valori NUMERIC quando li trasmette ad altri tipi numerici, come INTEGER o DECIMAL. Se enable_numeric_rounding è off, Amazon Redshift tronca i valori NUMERIC quando li trasmette ad altri tipi numerici. Per ulteriori informazioni sui tipi numerici, consulta Tipi numerici.

Esempio

--Create a table and insert the numeric value 1.5 into it. CREATE TABLE t (a numeric(10, 2)); INSERT INTO t VALUES (1.5); SET enable_numeric_rounding to ON; --Amazon Redshift now rounds NUMERIC values when casting to other numeric types. SELECT a::int FROM t; a --- 2 (1 row) SELECT a::decimal(10, 0) FROM t; a --- 2 (1 row) SELECT a::decimal(10, 5) FROM t; a --------- 1.50000 (1 row) SET enable_numeric_rounding to OFF; --Amazon Redshift now truncates NUMERIC values when casting to other numeric types. SELECT a::int FROM t; a --- 1 (1 row) SELECT a::decimal(10, 0) FROM t; a --- 1 (1 row) SELECT a::decimal(10, 5) FROM t; a --------- 1.50000 (1 row)