Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google bigquery 如何在bigquery的自定义项中使用平方根函数_Google Bigquery - Fatal编程技术网

Google bigquery 如何在bigquery的自定义项中使用平方根函数

Google bigquery 如何在bigquery的自定义项中使用平方根函数,google-bigquery,Google Bigquery,为什么JS sqrt()函数不起作用 CREATE TEMPORARY FUNCTION sqt(x int64) RETURNS int64 LANGUAGE js AS """ return sqrt(x); """; with table1 as( select 25 as x union all select 100 as x union all select 625 as x ) select x,sqt(x)square_root from table1 错误:Ref

为什么JS sqrt()函数不起作用

CREATE TEMPORARY FUNCTION sqt(x int64)
RETURNS int64
LANGUAGE js AS """
  return sqrt(x);
""";

with table1 as(
select 25 as x union all 
select 100 as x union all 
select 625 as x 
)

select x,sqt(x)square_root from table1

错误:ReferenceError:sqt(INT64)第2行第2-3列没有定义sqrt,JavaScript函数是
Math.sqrt
。请尝试以下方法:

CREATE TEMPORARY FUNCTION sqt(x int64)
RETURNS int64
LANGUAGE js AS """
  return Math.sqrt(x);
""";

with table1 as(
select 25 as x union all 
select 100 as x union all 
select 625 as x 
)

select x,sqt(x)square_root from table1

请注意,
INT64
不是JavaScript UDF的官方支持类型(因为没有等效的JavaScript类型)。最好使用
FLOAT64

JavaScript函数是
Math.sqrt
。请尝试以下方法:

CREATE TEMPORARY FUNCTION sqt(x int64)
RETURNS int64
LANGUAGE js AS """
  return Math.sqrt(x);
""";

with table1 as(
select 25 as x union all 
select 100 as x union all 
select 625 as x 
)

select x,sqt(x)square_root from table1
请注意,
INT64
不是JavaScript UDF的官方支持类型(因为没有等效的JavaScript类型)。最好改用
FLOAT64