以指数形式加载的 16 精度的雪花浮点值

Snowflake Float value with 16 precision loaded as exponential

数据文件的值为:2014050600001253

Snowflake 中的浮动列加载了:2.01405060000125e+15

有没有办法阻止指数格式并保持值在 float 数据类型的文件中?

使用的文件格式:

CREATE or Replace FILE FORMAT test_fmt
   TYPE = 'CSV'
   COMPRESSION = 'GZIP'
   FILE_EXTENSION= 'txt'
   FIELD_DELIMITER = '|'
   NULL_IF = ('NULL','null','')
   FIELD_OPTIONALLY_ENCLOSED_BY = '"'
   DATE_FORMAT = 'MM/DD/YYYY'
   TIMESTAMP_FORMAT = 'MM/DD/YYYY HH12:MI:SS AM'
   EMPTY_FIELD_AS_NULL = TRUE;

Is there a way to prevent the exponential format and keep the value as it is in the file with float data type?

是的,有一些方法可以强制打印没有指数格式的值,但是你不能保持原样的值,因为Snowflake 使用 IEEE-754 double precision,在转换为双精度时,如此大的值将四舍五入为最接近的双精度可表示值。大多数情况下,结果将不再等于原始值。例如 20140506000001253 将打印为 20140506000001252,而 9014050600001253 也四舍五入为 9014050600001252

如果要存储如此巨大的 floating-point 值,或者如果值是小于 1038 的整数,则必须使用字符串,然后使用整数类型

Precision is approximately 15 digits. For example, for integers, the range is from -9007199254740991 to +9007199254740991 (-253 + 1 to +253 - 1). Floating-point values can range from approximately 10-308 to 10+308. (More extreme values between approximately 10-324 and 10-308 can be represented with less precision.) For more details, see the Wikipedia article on double-precision numbers.

Numeric Data Types - FLOAT , FLOAT4 , FLOAT8

你可以

2014050600001253(51 位值)可以精确表示为 64 位浮点类型。

“Snowflake中的浮动列加载为:2.01405060000125e+15”是错误的,值为2.014050600001253e+15。

Is there a way to prevent the exponential format and keep the value as it is in the file with float data type?

文件中的值是什么,无论您选择如何打印它。打印至少 17 位有效小数位以更好地了解其真实值。

更好的是,由于浮点值是用二进制有效编码的,因此使用 binary/hexadecimal 输出打印以避免小数伪像。