试图将SQL脚本从SQL Server T-SQL转换为GCP BigQuery SQL,需要维护ansi null设置以确保相同的结果。当比较null=null时,有没有办法让Google BigQuery返回true(即下面的"null=null为true"(?
T-SQL和BigQuery显示不同输出的示例:
--GCP BigQuery test:
begin
declare null1 string;
declare null2 string;
select case when null1 = null2 then 'null = null is true'
else 'null = null is false'
end as bqsqlnulltest;
end
-- T-SQL (SQL Server) test:
set ansi_nulls off;
declare @null1 varchar(30);
declare @null2 varchar(30);
select case when @null1 = @null2 then 'null = null is true'
else 'null = null is false'
end as tsqlnulltest;
我不确定这是否适合您的查询。但是你可以使用这个结构:
where (x = y) is not false
或者在您的情况下:
where (null1 = null2) is not false