看起来像Azure SQL Server数据仓库中的错误?

时间:2017-01-27 19:42:52

标签: sql sql-server azure azure-sql-database data-warehouse

以下是我在Microsoft Azure SQL数据仓库 - 10.0.8529.1上运行的脚本。我在本地SQL Server 2014上尝试过,一切都按预期工作。

select @@version

-- Returns 1 rows, as expected
select
    cast(null as varchar(8000)) as col1
where 
    1=0
union all
select top 1
    'TEST'
from
    bl

-- Returns 60 rows (WHY?????)
select
    cast(null as varchar(max)) as col1
where 
    1=0
union all
select top 1
    'TEST'
from
    bl

以下是结果:

----------------
Microsoft Azure SQL Data Warehouse - 10.0.8529.1 Jan 16 2017 09:40:27 Copyright (c) Microsoft Corporation

col1
----------------
TEST

1 row

col1
----------------
TEST
TEST
.
.
.
.
.
.TEST

60 rows

第一个查询的解释计划如下:

<?xml version="1.0" encoding="utf-8"?>
<dsql_query
    number_nodes="4"
    number_distributions="60"
    number_distributions_per_node="15">
    <sql>select
    cast(null as varchar(8000)) as col1
where 
    1=0
union all
select top 1
    'TEST'
from
    bl</sql>
    <dsql_operations
        total_cost="0"
        total_number_operations="1">
        <dsql_operation
            operation_type="RETURN">
            <location
                distribution="AllDistributions" />
            <select>SELECT [T1_1].[col] AS [col]
FROM   (SELECT TOP (CAST ((1) AS BIGINT)) CAST (N'TEST' COLLATE SQL_Latin1_General_CP1_CI_AS AS VARCHAR (4)) COLLATE SQL_Latin1_General_CP1_CI_AS AS [col]
        FROM   [dev-pmoldw].[STARNET].[BL] AS T2_1) AS T1_1</select>
        </dsql_operation>
    </dsql_operations>
</dsql_query>

varchar(max)查询的解释计划如下:

<?xml version="1.0" encoding="utf-8"?>
<dsql_query
    number_nodes="4"
    number_distributions="60"
    number_distributions_per_node="15">
    <sql>select
    cast(null as varchar(max)) as col1
where 
    1=0
union all
select top 1
    'TEST'
from
    bl</sql>
    <dsql_operations
        total_cost="0"
        total_number_operations="1">
        <dsql_operation
            operation_type="RETURN">
            <location
                distribution="AllDistributions" />
            <select>SELECT [T1_1].[col] AS [col]
FROM   (SELECT TOP (CAST ((1) AS BIGINT)) CONVERT (VARCHAR (MAX), CAST (N'TEST' COLLATE SQL_Latin1_General_CP1_CI_AS AS VARCHAR (4)) COLLATE SQL_Latin1_General_CP1_CI_AS, 0) COLLATE SQL_Latin1_General_CP1_CI_AS AS [col]
        FROM   [dev-pmoldw].[STARNET].[BL] AS T2_1) AS T1_1</select>
        </dsql_operation>
    </dsql_operations>
</dsql_query>

(编辑:在此报告https://connect.microsoft.com/SQLServer/Feedback/Details/3120055

0 个答案:

没有答案