Google bigquery BigQuery-UDF在视图中使用时返回左连接错误

Google bigquery BigQuery-UDF在视图中使用时返回左连接错误,google-bigquery,user-defined-functions,Google Bigquery,User Defined Functions,在计算输入之间的天数时,我面临BQ和UDF(在视图中使用UDF时)的以下问题 CREATE FUNCTION my_test_function(from_date TIMESTAMP, to_date TIMESTAMP) AS ( ( SELECT COUNT(date) AS count FROM my_test_table WHERE date >= CAST(from_date as date) and dat

在计算输入之间的天数时,我面临BQ和UDF(在视图中使用UDF时)的以下问题

CREATE FUNCTION my_test_function(from_date TIMESTAMP, to_date TIMESTAMP) AS (
    (
        SELECT COUNT(date) AS count FROM my_test_table                
        WHERE date >= CAST(from_date as date) and date < CAST(to_date as date)
    )
);
在查询编辑器中调用函数时,一切正常

在视图中使用它时,我得到了以下错误

LEFT OUTER JOIN cannot be used without a condition that is an equality of fields from both sides of the join.
看看执行计划-那里没有连接。只是输入和输出

输入

READ    
$1:date
FROM my_test_table
WHERE and(greater_or_equal($1, 18748), less($1, 18778))
AGGREGATE   
$20 := COUNT($1)
WRITE   
$20
TO __stage00_output
READ    
$20
FROM __stage00_output
AGGREGATE   
$10 := SUM_OF_COUNTS($20)
WRITE   
$10
TO __stage01_output
输出

READ    
$1:date
FROM my_test_table
WHERE and(greater_or_equal($1, 18748), less($1, 18778))
AGGREGATE   
$20 := COUNT($1)
WRITE   
$20
TO __stage00_output
READ    
$20
FROM __stage00_output
AGGREGATE   
$10 := SUM_OF_COUNTS($20)
WRITE   
$10
TO __stage01_output
在这里几乎找不到类似的问题,但它们都在UDF查询中使用联接

有什么想法吗

谢谢

编辑:

此处的函数调用:

with test_data as (
    select CAST('2021-05-01' as timestamp) from_date, CAST('2021-05-31' as timestamp) to_date,
    union all select CAST('2021-06-01' as timestamp) from_date, CAST('2021-06-20' as timestamp) to_date    
)

select     
*,    
my_test_function(from_date, to_date) as date_diff   
from 
    test_data

您是否尝试过在没有UDF函数的情况下失败的相同视图?这将有助于缩小问题范围请发布您的查询,包括函数的使用。。。否则很难诊断您的问题。您好,在帖子中添加了函数调用。@Alvaro-yep,没有UDF调用,它可以正常工作