为什么 Google Cloud Storage 会为我的数据类型抛出不受支持的精度和小数位值?
Why does Google Cloud Storage throw an unsupported precision and scale values for my data type?
我目前正在尝试将 parquet 文件从 Google Cloud Storage 上传到 BigQuery 中的 table。我一直收到错误 "Unsupported precision and scale values '(35,2)' for field 'X' of type 'FIXED_LEN_BYTE_ARRAY(DECIMAL(35,2))'. The maximum supported precision and scale is '(38,9)."
在我看来 (35,2) 应该符合 (38,9) 的精度和比例要求。为什么 Google Cloud 似乎不允许我的 parquet 文件中的这种数据类型?有什么解决方法吗?
由于十进制镶木地板类型支持的整数的最大数是29;但是,在您的情况下,小数数据的精度为 35,小数位数为 2,这意味着整数位数为 33。基于此,可用的解决方法是修改精度和小数位数值以与镶木地板文件匹配要求。
您可以查看Decimal annotation官方文档,其中包含以下有关使用这些parquet类型字段的说明:
Parquet types with the DECIMAL annotation may have at most a precision
of 38 (total number of digits) and at most a scale of 9 (digits to the
right of the decimal). The number of integer digits, which is the
precision minus the scale, may be at most 29. For example, DECIMAL(38,
9) is supported because the precision is 38 and the scale is 9. In
this example, the number of integer digits is 29. DECIMAL(38, 5) is
not supported because it has a precision of 38 and a scale of 5. In
this example, the number of integer digits is 33.
我目前正在尝试将 parquet 文件从 Google Cloud Storage 上传到 BigQuery 中的 table。我一直收到错误 "Unsupported precision and scale values '(35,2)' for field 'X' of type 'FIXED_LEN_BYTE_ARRAY(DECIMAL(35,2))'. The maximum supported precision and scale is '(38,9)."
在我看来 (35,2) 应该符合 (38,9) 的精度和比例要求。为什么 Google Cloud 似乎不允许我的 parquet 文件中的这种数据类型?有什么解决方法吗?
由于十进制镶木地板类型支持的整数的最大数是29;但是,在您的情况下,小数数据的精度为 35,小数位数为 2,这意味着整数位数为 33。基于此,可用的解决方法是修改精度和小数位数值以与镶木地板文件匹配要求。
您可以查看Decimal annotation官方文档,其中包含以下有关使用这些parquet类型字段的说明:
Parquet types with the DECIMAL annotation may have at most a precision of 38 (total number of digits) and at most a scale of 9 (digits to the right of the decimal). The number of integer digits, which is the precision minus the scale, may be at most 29. For example, DECIMAL(38, 9) is supported because the precision is 38 and the scale is 9. In this example, the number of integer digits is 29. DECIMAL(38, 5) is not supported because it has a precision of 38 and a scale of 5. In this example, the number of integer digits is 33.