作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我注意到 docs for BigQuery Standard SQL Mathematical functions我们可以使用 IS_INF()
测试一个数字是否“无穷大”功能是这样的:
WITH demo_tbl AS (
SELECT 1 AS val UNION ALL
SELECT 100 AS val
)
SELECT
val,
IS_INF(val) as is_infinity
FROM demo_tbl
+---+-----+-------------+
| | val | is_infinity |
+---+-----+-------------+
| 0 | 1 | False |
| 1 | 100 | False |
+---+-----+-------------+
WITH demo_tbl AS (
SELECT 1 AS val UNION ALL
SELECT +inf AS val -- <-- THIS doesnt work
)
SELECT
val,
IS_INF(val) as is_infinity
FROM demo_tbl
+---+-----+-------------+
| | val | is_infinity |
+---+-----+-------------+
| 0 | 1 | False |
| 1 | inf | True |
+---+-----+-------------+
最佳答案
您可以使用 cast()
创建该值:
select is_inf(cast('Infinity' as float64))
select is_inf(cast('inf' as float64))
There is no literal representation of NaN or infinity, but the following case-insensitive strings can be explicitly cast to float:
- "NaN"
- "inf" or "+inf"
- "-inf"
关于sql - BigQuery 标准 SQL : Setting a value to positive or negative infinity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53692209/
我是一名优秀的程序员,十分优秀!