From 23faf2bbda69b61db6d4c33c3af480be76528bfe Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:04:30 +0000 Subject: [PATCH 01/16] [Windows / SQL Server 2005] baselines --- ...esceColumnSelection(SqlServer.2005.MS).sql | 77 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2005).sql | 77 +++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 SqlServer.2005.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005.MS).sql create mode 100644 SqlServer.2005/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005).sql diff --git a/SqlServer.2005.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005.MS).sql b/SqlServer.2005.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005.MS).sql new file mode 100644 index 000000000000..a03e2d709411 --- /dev/null +++ b/SqlServer.2005.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005.MS).sql @@ -0,0 +1,77 @@ +BeforeExecute +-- SqlServer.2005.MS SqlServer.2005 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + CASE + WHEN SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL + THEN NULL + ELSE SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + CASE + WHEN [it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5 + THEN CAST([it].[ColorId] AS NVarChar(11)) + ELSE REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)) + END + END as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY ( + SELECT [a_Color].[Name] AS [ColorName], [a_Style].[Name] AS [StyleName], Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0) AS [ColorId], CASE + WHEN [a_Color].[Name] = N'Red' THEN ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ) + ELSE 0 + END AS [Conditional] + UNION ALL + SELECT NULL, [a_Style].[Name], Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0), 0) [it] + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2005.MS SqlServer.2005 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2005.MS SqlServer.2005 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2005/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005).sql b/SqlServer.2005/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005).sql new file mode 100644 index 000000000000..7a38121bdd84 --- /dev/null +++ b/SqlServer.2005/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2005).sql @@ -0,0 +1,77 @@ +BeforeExecute +-- SqlServer.2005 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + CASE + WHEN SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL + THEN NULL + ELSE SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + CASE + WHEN [it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5 + THEN CAST([it].[ColorId] AS NVarChar(11)) + ELSE REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)) + END + END as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY ( + SELECT [a_Color].[Name] AS [ColorName], [a_Style].[Name] AS [StyleName], Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0) AS [ColorId], CASE + WHEN [a_Color].[Name] = N'Red' THEN ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ) + ELSE 0 + END AS [Conditional] + UNION ALL + SELECT NULL, [a_Style].[Name], Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0), 0) [it] + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2005 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2005 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From a50ba51d867eed5aadc0202c1f960c66f4760140 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:19:13 +0000 Subject: [PATCH 02/16] [Windows / SQL Server 2008] baselines --- ...esceColumnSelection(SqlServer.2008.MS).sql | 77 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2008).sql | 77 +++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 SqlServer.2008.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008.MS).sql create mode 100644 SqlServer.2008/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008).sql diff --git a/SqlServer.2008.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008.MS).sql b/SqlServer.2008.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008.MS).sql new file mode 100644 index 000000000000..217a489afa89 --- /dev/null +++ b/SqlServer.2008.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008.MS).sql @@ -0,0 +1,77 @@ +BeforeExecute +-- SqlServer.2008.MS SqlServer.2008 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + CASE + WHEN SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL + THEN NULL + ELSE SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + CASE + WHEN [it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5 + THEN CAST([it].[ColorId] AS NVarChar(11)) + ELSE REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)) + END + END as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0),CASE + WHEN [a_Color].[Name] = N'Red' THEN ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ) + ELSE 0 + END), + (NULL,[a_Style].[Name],Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2008.MS SqlServer.2008 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2008.MS SqlServer.2008 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2008/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008).sql b/SqlServer.2008/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008).sql new file mode 100644 index 000000000000..28f70831beb4 --- /dev/null +++ b/SqlServer.2008/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2008).sql @@ -0,0 +1,77 @@ +BeforeExecute +-- SqlServer.2008 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + CASE + WHEN SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL + THEN NULL + ELSE SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + CASE + WHEN [it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5 + THEN CAST([it].[ColorId] AS NVarChar(11)) + ELSE REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)) + END + END as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0),CASE + WHEN [a_Color].[Name] = N'Red' THEN ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ) + ELSE 0 + END), + (NULL,[a_Style].[Name],Coalesce(CASE + WHEN [a_Color].[Id] IS NULL THEN NULL + ELSE [t2].[ColorId] + END, 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2008 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2008 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From 31d77f61eb4496e3bf1981d697092f027c82cb8a Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:25:42 +0000 Subject: [PATCH 03/16] [Windows / SQL Server 2012] baselines --- ...esceColumnSelection(SqlServer.2012.MS).sql | 60 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2012).sql | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 SqlServer.2012.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012.MS).sql create mode 100644 SqlServer.2012/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012).sql diff --git a/SqlServer.2012.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012.MS).sql b/SqlServer.2012.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012.MS).sql new file mode 100644 index 000000000000..07377b7751d1 --- /dev/null +++ b/SqlServer.2012.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2012.MS SqlServer.2012 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL, NULL, SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2012.MS SqlServer.2012 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2012.MS SqlServer.2012 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2012/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012).sql b/SqlServer.2012/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012).sql new file mode 100644 index 000000000000..4fc3f01b676c --- /dev/null +++ b/SqlServer.2012/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2012).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2012 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL, NULL, SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2012 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2012 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From f9877bb896cae102b3ff602c620201390a5cb519 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:30:37 +0000 Subject: [PATCH 04/16] [Windows / SQL Server 2016] baselines --- ...esceColumnSelection(SqlServer.2016.MS).sql | 60 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2016).sql | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 SqlServer.2016.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016.MS).sql create mode 100644 SqlServer.2016/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016).sql diff --git a/SqlServer.2016.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016.MS).sql b/SqlServer.2016.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016.MS).sql new file mode 100644 index 000000000000..6132ad8cbb57 --- /dev/null +++ b/SqlServer.2016.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2016.MS SqlServer.2016 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL, NULL, SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2016.MS SqlServer.2016 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2016.MS SqlServer.2016 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2016/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016).sql b/SqlServer.2016/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016).sql new file mode 100644 index 000000000000..8fa28e447ae5 --- /dev/null +++ b/SqlServer.2016/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2016).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2016 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL, NULL, SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2016 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2016 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From dd63f3432ef575767e8380d466d5633ccfae8a5a Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:32:58 +0000 Subject: [PATCH 05/16] [Windows / SQL Server 2014] baselines --- ...esceColumnSelection(SqlServer.2014.MS).sql | 60 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2014).sql | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 SqlServer.2014.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014.MS).sql create mode 100644 SqlServer.2014/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014).sql diff --git a/SqlServer.2014.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014.MS).sql b/SqlServer.2014.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014.MS).sql new file mode 100644 index 000000000000..4f8080dccde9 --- /dev/null +++ b/SqlServer.2014.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2014.MS SqlServer.2014 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL, NULL, SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2014.MS SqlServer.2014 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2014.MS SqlServer.2014 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2014/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014).sql b/SqlServer.2014/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014).sql new file mode 100644 index 000000000000..f83cbb1ec7e0 --- /dev/null +++ b/SqlServer.2014/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2014).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2014 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) IS NULL, NULL, SUBSTRING((ISNULL((N',' + N''), '') + ISNULL((N',' + [it].[StyleName]), '')), LEN(CONVERT(NVARCHAR(MAX), N',') + N'!'), 8000) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2014 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2014 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From 8f2c3cc712499cb4c06214458c74b20237c79831 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:40:44 +0000 Subject: [PATCH 06/16] [Windows / SQL Server 2017] baselines --- ...esceColumnSelection(SqlServer.2017.MS).sql | 60 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2017).sql | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 SqlServer.2017.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017.MS).sql create mode 100644 SqlServer.2017/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017).sql diff --git a/SqlServer.2017.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017.MS).sql b/SqlServer.2017.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017.MS).sql new file mode 100644 index 000000000000..3499aa548088 --- /dev/null +++ b/SqlServer.2017.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2017.MS SqlServer.2017 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2017.MS SqlServer.2017 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2017.MS SqlServer.2017 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2017/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017).sql b/SqlServer.2017/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017).sql new file mode 100644 index 000000000000..a18e01bb147d --- /dev/null +++ b/SqlServer.2017/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2017).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2017 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2017 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2017 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From d8d1fa7b406d4b5484971f3c6faee8ab395781f1 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:47:55 +0000 Subject: [PATCH 07/16] [Windows / SQL Server 2019] baselines --- ...esceColumnSelection(SqlServer.2019.MS).sql | 60 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2019).sql | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 SqlServer.2019.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019.MS).sql create mode 100644 SqlServer.2019/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019).sql diff --git a/SqlServer.2019.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019.MS).sql b/SqlServer.2019.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019.MS).sql new file mode 100644 index 000000000000..b14dcc814bbb --- /dev/null +++ b/SqlServer.2019.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2019.MS SqlServer.2019 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2019.MS SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2019.MS SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2019/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019).sql b/SqlServer.2019/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019).sql new file mode 100644 index 000000000000..cd831de6124d --- /dev/null +++ b/SqlServer.2019/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2019).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2019 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From b8e339c0e7be9304afc7a5c1d1530b31e2758650 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:49:04 +0000 Subject: [PATCH 08/16] [Windows / SQL Server 2022] baselines --- ...esceColumnSelection(SqlServer.2022.MS).sql | 60 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2022).sql | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 SqlServer.2022.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022.MS).sql create mode 100644 SqlServer.2022/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022).sql diff --git a/SqlServer.2022.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022.MS).sql b/SqlServer.2022.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022.MS).sql new file mode 100644 index 000000000000..8b2aa907e5eb --- /dev/null +++ b/SqlServer.2022.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2022.MS SqlServer.2022 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2022.MS SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2022.MS SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2022/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022).sql b/SqlServer.2022/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022).sql new file mode 100644 index 000000000000..6a1c1121c430 --- /dev/null +++ b/SqlServer.2022/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2022).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2022 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From 002d3f5c51b315d92e11ec2f881acaf76c3ca3a9 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:56:30 +0000 Subject: [PATCH 09/16] [Linux / PostgreSQL 13] baselines --- ...CoalesceColumnSelection(PostgreSQL.13).sql | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 PostgreSQL.13/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.13).sql diff --git a/PostgreSQL.13/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.13).sql b/PostgreSQL.13/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.13).sql new file mode 100644 index 000000000000..d9c286aaf3f6 --- /dev/null +++ b/PostgreSQL.13/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.13).sql @@ -0,0 +1,76 @@ +BeforeExecute +-- PostgreSQL.13 PostgreSQL.9.5 PostgreSQL + +SELECT + t3."ColorName", + t3."StyleName", + t3."Conditional", + t3."StrValue" +FROM + ( + SELECT + CASE + WHEN CONCAT_WS(',', '', it."StyleName") IS NULL THEN NULL + ELSE CONCAT_WS(',', '', it."StyleName") || ':' || CASE + WHEN it."ColorId" IS NULL OR Length(it."ColorId"::text) >= 4 + THEN it."ColorId"::text + ELSE LPAD(it."ColorId"::text, 4, '0') + END + END as "StrValue", + it."ColorName", + it."StyleName", + it."Conditional" + FROM + "SomeItem" t2 + LEFT JOIN "SomeColor" "a_Color" ON t2."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t2."StyleId" = "a_Style"."Id" + LEFT JOIN LATERAL (VALUES + ("a_Color"."Name","a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),CASE + WHEN "a_Color"."Name" = 'Red' THEN ( + SELECT + COUNT(*) as "COUNT_1" + FROM + "SomeItem" t1 + ) + ELSE 0 + END), + (NULL,"a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),0) + ) it("ColorName", "StyleName", "ColorId", "Conditional") ON 1=1 + WHERE + it."ColorName" = 'Red' + ) t3 +ORDER BY + t3."StrValue" + +BeforeExecute +-- PostgreSQL.13 PostgreSQL.9.5 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId", + "a_Color"."Id", + "a_Color"."Name", + "a_Style"."Id", + "a_Style"."Name" +FROM + "SomeItem" t1 + LEFT JOIN "SomeColor" "a_Color" ON t1."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t1."StyleId" = "a_Style"."Id" + +BeforeExecute +-- PostgreSQL.13 PostgreSQL.9.5 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId" +FROM + "SomeItem" t1 + From 3f6c142fac43da2c4c27bf435842c941790b2174 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 17:59:34 +0000 Subject: [PATCH 10/16] [Linux / PostgreSQL 14] baselines --- ...CoalesceColumnSelection(PostgreSQL.14).sql | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 PostgreSQL.14/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.14).sql diff --git a/PostgreSQL.14/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.14).sql b/PostgreSQL.14/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.14).sql new file mode 100644 index 000000000000..4c0635549708 --- /dev/null +++ b/PostgreSQL.14/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.14).sql @@ -0,0 +1,76 @@ +BeforeExecute +-- PostgreSQL.14 PostgreSQL.9.5 PostgreSQL + +SELECT + t3."ColorName", + t3."StyleName", + t3."Conditional", + t3."StrValue" +FROM + ( + SELECT + CASE + WHEN CONCAT_WS(',', '', it."StyleName") IS NULL THEN NULL + ELSE CONCAT_WS(',', '', it."StyleName") || ':' || CASE + WHEN it."ColorId" IS NULL OR Length(it."ColorId"::text) >= 4 + THEN it."ColorId"::text + ELSE LPAD(it."ColorId"::text, 4, '0') + END + END as "StrValue", + it."ColorName", + it."StyleName", + it."Conditional" + FROM + "SomeItem" t2 + LEFT JOIN "SomeColor" "a_Color" ON t2."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t2."StyleId" = "a_Style"."Id" + LEFT JOIN LATERAL (VALUES + ("a_Color"."Name","a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),CASE + WHEN "a_Color"."Name" = 'Red' THEN ( + SELECT + COUNT(*) as "COUNT_1" + FROM + "SomeItem" t1 + ) + ELSE 0 + END), + (NULL,"a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),0) + ) it("ColorName", "StyleName", "ColorId", "Conditional") ON 1=1 + WHERE + it."ColorName" = 'Red' + ) t3 +ORDER BY + t3."StrValue" + +BeforeExecute +-- PostgreSQL.14 PostgreSQL.9.5 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId", + "a_Color"."Id", + "a_Color"."Name", + "a_Style"."Id", + "a_Style"."Name" +FROM + "SomeItem" t1 + LEFT JOIN "SomeColor" "a_Color" ON t1."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t1."StyleId" = "a_Style"."Id" + +BeforeExecute +-- PostgreSQL.14 PostgreSQL.9.5 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId" +FROM + "SomeItem" t1 + From 5c6ef3601964143b94ce17c51224f9950ac6d6d4 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 18:03:16 +0000 Subject: [PATCH 11/16] [Windows / SQL Server 2025] baselines --- ...esceColumnSelection(SqlServer.2025.MS).sql | 60 +++++++++++++++++++ ...oalesceColumnSelection(SqlServer.2025).sql | 60 +++++++++++++++++++ 2 files changed, 120 insertions(+) create mode 100644 SqlServer.2025.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025.MS).sql create mode 100644 SqlServer.2025/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025).sql diff --git a/SqlServer.2025.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025.MS).sql b/SqlServer.2025.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025.MS).sql new file mode 100644 index 000000000000..6ec22505a2c8 --- /dev/null +++ b/SqlServer.2025.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2025.MS SqlServer.2025 SqlServer.2022 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2025.MS SqlServer.2025 SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2025.MS SqlServer.2025 SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.2025/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025).sql b/SqlServer.2025/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025).sql new file mode 100644 index 000000000000..2c6930a98e62 --- /dev/null +++ b/SqlServer.2025/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.2025).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.2025 SqlServer.2022 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.2025 SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.2025 SqlServer.2022 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + From c110c013d8d63c4281c8c651c19a7279545f5538 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 18:03:32 +0000 Subject: [PATCH 12/16] [Linux / PostgreSQL 15] baselines --- ...CoalesceColumnSelection(PostgreSQL.15).sql | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 PostgreSQL.15/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.15).sql diff --git a/PostgreSQL.15/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.15).sql b/PostgreSQL.15/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.15).sql new file mode 100644 index 000000000000..858cf7fd60d2 --- /dev/null +++ b/PostgreSQL.15/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.15).sql @@ -0,0 +1,76 @@ +BeforeExecute +-- PostgreSQL.15 PostgreSQL + +SELECT + t3."ColorName", + t3."StyleName", + t3."Conditional", + t3."StrValue" +FROM + ( + SELECT + CASE + WHEN CONCAT_WS(',', '', it."StyleName") IS NULL THEN NULL + ELSE CONCAT_WS(',', '', it."StyleName") || ':' || CASE + WHEN it."ColorId" IS NULL OR Length(it."ColorId"::text) >= 4 + THEN it."ColorId"::text + ELSE LPAD(it."ColorId"::text, 4, '0') + END + END as "StrValue", + it."ColorName", + it."StyleName", + it."Conditional" + FROM + "SomeItem" t2 + LEFT JOIN "SomeColor" "a_Color" ON t2."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t2."StyleId" = "a_Style"."Id" + LEFT JOIN LATERAL (VALUES + ("a_Color"."Name","a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),CASE + WHEN "a_Color"."Name" = 'Red' THEN ( + SELECT + COUNT(*) as "COUNT_1" + FROM + "SomeItem" t1 + ) + ELSE 0 + END), + (NULL,"a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),0) + ) it("ColorName", "StyleName", "ColorId", "Conditional") ON 1=1 + WHERE + it."ColorName" = 'Red' + ) t3 +ORDER BY + t3."StrValue" + +BeforeExecute +-- PostgreSQL.15 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId", + "a_Color"."Id", + "a_Color"."Name", + "a_Style"."Id", + "a_Style"."Name" +FROM + "SomeItem" t1 + LEFT JOIN "SomeColor" "a_Color" ON t1."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t1."StyleId" = "a_Style"."Id" + +BeforeExecute +-- PostgreSQL.15 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId" +FROM + "SomeItem" t1 + From 3ca7121d4a8bf5cec0bec6ed4c4e5b0894a4cb6a Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 18:06:21 +0000 Subject: [PATCH 13/16] [Linux / PostgreSQL 17] baselines --- ...CoalesceColumnSelection(PostgreSQL.17).sql | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 PostgreSQL.17/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.17).sql diff --git a/PostgreSQL.17/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.17).sql b/PostgreSQL.17/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.17).sql new file mode 100644 index 000000000000..b203c4ac1214 --- /dev/null +++ b/PostgreSQL.17/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.17).sql @@ -0,0 +1,76 @@ +BeforeExecute +-- PostgreSQL.17 PostgreSQL.15 PostgreSQL + +SELECT + t3."ColorName", + t3."StyleName", + t3."Conditional", + t3."StrValue" +FROM + ( + SELECT + CASE + WHEN CONCAT_WS(',', '', it."StyleName") IS NULL THEN NULL + ELSE CONCAT_WS(',', '', it."StyleName") || ':' || CASE + WHEN it."ColorId" IS NULL OR Length(it."ColorId"::text) >= 4 + THEN it."ColorId"::text + ELSE LPAD(it."ColorId"::text, 4, '0') + END + END as "StrValue", + it."ColorName", + it."StyleName", + it."Conditional" + FROM + "SomeItem" t2 + LEFT JOIN "SomeColor" "a_Color" ON t2."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t2."StyleId" = "a_Style"."Id" + LEFT JOIN LATERAL (VALUES + ("a_Color"."Name","a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),CASE + WHEN "a_Color"."Name" = 'Red' THEN ( + SELECT + COUNT(*) as "COUNT_1" + FROM + "SomeItem" t1 + ) + ELSE 0 + END), + (NULL,"a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),0) + ) it("ColorName", "StyleName", "ColorId", "Conditional") ON 1=1 + WHERE + it."ColorName" = 'Red' + ) t3 +ORDER BY + t3."StrValue" + +BeforeExecute +-- PostgreSQL.17 PostgreSQL.15 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId", + "a_Color"."Id", + "a_Color"."Name", + "a_Style"."Id", + "a_Style"."Name" +FROM + "SomeItem" t1 + LEFT JOIN "SomeColor" "a_Color" ON t1."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t1."StyleId" = "a_Style"."Id" + +BeforeExecute +-- PostgreSQL.17 PostgreSQL.15 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId" +FROM + "SomeItem" t1 + From 8865c5d034808255d34001fbd4fc7891c46e22e2 Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 18:06:22 +0000 Subject: [PATCH 14/16] [Linux / PostgreSQL 16] baselines --- ...CoalesceColumnSelection(PostgreSQL.16).sql | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 PostgreSQL.16/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.16).sql diff --git a/PostgreSQL.16/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.16).sql b/PostgreSQL.16/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.16).sql new file mode 100644 index 000000000000..96733d8b03ae --- /dev/null +++ b/PostgreSQL.16/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.16).sql @@ -0,0 +1,76 @@ +BeforeExecute +-- PostgreSQL.16 PostgreSQL.15 PostgreSQL + +SELECT + t3."ColorName", + t3."StyleName", + t3."Conditional", + t3."StrValue" +FROM + ( + SELECT + CASE + WHEN CONCAT_WS(',', '', it."StyleName") IS NULL THEN NULL + ELSE CONCAT_WS(',', '', it."StyleName") || ':' || CASE + WHEN it."ColorId" IS NULL OR Length(it."ColorId"::text) >= 4 + THEN it."ColorId"::text + ELSE LPAD(it."ColorId"::text, 4, '0') + END + END as "StrValue", + it."ColorName", + it."StyleName", + it."Conditional" + FROM + "SomeItem" t2 + LEFT JOIN "SomeColor" "a_Color" ON t2."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t2."StyleId" = "a_Style"."Id" + LEFT JOIN LATERAL (VALUES + ("a_Color"."Name","a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),CASE + WHEN "a_Color"."Name" = 'Red' THEN ( + SELECT + COUNT(*) as "COUNT_1" + FROM + "SomeItem" t1 + ) + ELSE 0 + END), + (NULL,"a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),0) + ) it("ColorName", "StyleName", "ColorId", "Conditional") ON 1=1 + WHERE + it."ColorName" = 'Red' + ) t3 +ORDER BY + t3."StrValue" + +BeforeExecute +-- PostgreSQL.16 PostgreSQL.15 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId", + "a_Color"."Id", + "a_Color"."Name", + "a_Style"."Id", + "a_Style"."Name" +FROM + "SomeItem" t1 + LEFT JOIN "SomeColor" "a_Color" ON t1."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t1."StyleId" = "a_Style"."Id" + +BeforeExecute +-- PostgreSQL.16 PostgreSQL.15 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId" +FROM + "SomeItem" t1 + From 9b0a625e9e318588eaaac0a41a859c98f290e81e Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 18:07:07 +0000 Subject: [PATCH 15/16] [Linux / PostgreSQL 18] baselines --- ...CoalesceColumnSelection(PostgreSQL.18).sql | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 PostgreSQL.18/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.18).sql diff --git a/PostgreSQL.18/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.18).sql b/PostgreSQL.18/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.18).sql new file mode 100644 index 000000000000..c7f7ac13935a --- /dev/null +++ b/PostgreSQL.18/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(PostgreSQL.18).sql @@ -0,0 +1,76 @@ +BeforeExecute +-- PostgreSQL.18 PostgreSQL + +SELECT + t3."ColorName", + t3."StyleName", + t3."Conditional", + t3."StrValue" +FROM + ( + SELECT + CASE + WHEN CONCAT_WS(',', '', it."StyleName") IS NULL THEN NULL + ELSE CONCAT_WS(',', '', it."StyleName") || ':' || CASE + WHEN it."ColorId" IS NULL OR Length(it."ColorId"::text) >= 4 + THEN it."ColorId"::text + ELSE LPAD(it."ColorId"::text, 4, '0') + END + END as "StrValue", + it."ColorName", + it."StyleName", + it."Conditional" + FROM + "SomeItem" t2 + LEFT JOIN "SomeColor" "a_Color" ON t2."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t2."StyleId" = "a_Style"."Id" + LEFT JOIN LATERAL (VALUES + ("a_Color"."Name","a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),CASE + WHEN "a_Color"."Name" = 'Red' THEN ( + SELECT + COUNT(*) as "COUNT_1" + FROM + "SomeItem" t1 + ) + ELSE 0 + END), + (NULL,"a_Style"."Name",Coalesce(CASE + WHEN "a_Color"."Id" IS NULL THEN NULL + ELSE t2."ColorId" + END, 0),0) + ) it("ColorName", "StyleName", "ColorId", "Conditional") ON 1=1 + WHERE + it."ColorName" = 'Red' + ) t3 +ORDER BY + t3."StrValue" + +BeforeExecute +-- PostgreSQL.18 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId", + "a_Color"."Id", + "a_Color"."Name", + "a_Style"."Id", + "a_Style"."Name" +FROM + "SomeItem" t1 + LEFT JOIN "SomeColor" "a_Color" ON t1."ColorId" = "a_Color"."Id" + LEFT JOIN "SomeStyle" "a_Style" ON t1."StyleId" = "a_Style"."Id" + +BeforeExecute +-- PostgreSQL.18 PostgreSQL + +SELECT + t1."Id", + t1."ColorId", + t1."StyleId" +FROM + "SomeItem" t1 + From 52d9448bf358321ab878b237077dc30546955adf Mon Sep 17 00:00:00 2001 From: Azure Pipelines Bot Date: Mon, 18 Aug 2025 18:23:21 +0000 Subject: [PATCH 16/16] [Windows / SQL Server EXTRAS] baselines --- ...olumnSelection(SqlServer.Contained.MS).sql | 60 +++++++++++++++++++ ...ceColumnSelection(SqlServer.Contained).sql | 60 +++++++++++++++++++ ...alesceColumnSelection(SqlServer.SA.MS).sql | 60 +++++++++++++++++++ ....CoalesceColumnSelection(SqlServer.SA).sql | 60 +++++++++++++++++++ 4 files changed, 240 insertions(+) create mode 100644 SqlServer.Contained.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained.MS).sql create mode 100644 SqlServer.Contained/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained).sql create mode 100644 SqlServer.SA.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA.MS).sql create mode 100644 SqlServer.SA/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA).sql diff --git a/SqlServer.Contained.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained.MS).sql b/SqlServer.Contained.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained.MS).sql new file mode 100644 index 000000000000..68bd9332294f --- /dev/null +++ b/SqlServer.Contained.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.Contained.MS SqlServer.2019 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.Contained.MS SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.Contained.MS SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.Contained/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained).sql b/SqlServer.Contained/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained).sql new file mode 100644 index 000000000000..3c44cf8c8a7f --- /dev/null +++ b/SqlServer.Contained/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.Contained).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.Contained SqlServer.2019 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.Contained SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.Contained SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.SA.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA.MS).sql b/SqlServer.SA.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA.MS).sql new file mode 100644 index 000000000000..8b4935e0d5d3 --- /dev/null +++ b/SqlServer.SA.MS/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA.MS).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.SA.MS SqlServer.2019 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.SA.MS SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.SA.MS SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] + diff --git a/SqlServer.SA/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA).sql b/SqlServer.SA/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA).sql new file mode 100644 index 000000000000..205a8796a828 --- /dev/null +++ b/SqlServer.SA/Tests/Linq/EnumerableInQuery/Tests.Linq.EnumerableInQuery.CoalesceColumnSelection(SqlServer.SA).sql @@ -0,0 +1,60 @@ +BeforeExecute +-- SqlServer.SA SqlServer.2019 + +SELECT + [t3].[ColorName], + [t3].[StyleName], + [t3].[Conditional], + [t3].[StrValue] +FROM + ( + SELECT + IIF(CONCAT_WS(N',', N'', [it].[StyleName]) IS NULL, NULL, CONCAT_WS(N',', N'', [it].[StyleName]) + N':' + IIF([it].[ColorId] IS NULL OR LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') >= 5, CAST([it].[ColorId] AS NVarChar(11)), REPLICATE(N'0', 4 - (LEN(CAST([it].[ColorId] AS NVarChar(11)) + N'.') - 1)) + CAST([it].[ColorId] AS NVarChar(11)))) as [StrValue], + [it].[ColorName], + [it].[StyleName], + [it].[Conditional] + FROM + [SomeItem] [t2] + LEFT JOIN [SomeColor] [a_Color] ON [t2].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t2].[StyleId] = [a_Style].[Id] + OUTER APPLY (VALUES + ([a_Color].[Name],[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),IIF([a_Color].[Name] = N'Red', ( + SELECT + COUNT(*) as [COUNT_1] + FROM + [SomeItem] [t1] + ), 0)), + (NULL,[a_Style].[Name],Coalesce(IIF([a_Color].[Id] IS NULL, NULL, [t2].[ColorId]), 0),0) + ) [it]([ColorName], [StyleName], [ColorId], [Conditional]) + WHERE + [it].[ColorName] = N'Red' + ) [t3] +ORDER BY + [t3].[StrValue] + +BeforeExecute +-- SqlServer.SA SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId], + [a_Color].[Id], + [a_Color].[Name], + [a_Style].[Id], + [a_Style].[Name] +FROM + [SomeItem] [t1] + LEFT JOIN [SomeColor] [a_Color] ON [t1].[ColorId] = [a_Color].[Id] + LEFT JOIN [SomeStyle] [a_Style] ON [t1].[StyleId] = [a_Style].[Id] + +BeforeExecute +-- SqlServer.SA SqlServer.2019 + +SELECT + [t1].[Id], + [t1].[ColorId], + [t1].[StyleId] +FROM + [SomeItem] [t1] +