尝试将 SQL 脚本从 SQL Server T-SQL 转换为 GCP BigQuery SQL,并且需要维护 ansi nulls 设置以确保相同的结果。有没有办法让 Google BigQuery 在比较 null = null 时返回 true(即下面的“null = null is 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;