有两个表,外部表a和视图表b。外部表中的数据通过polybase连接到hadoop。视图表是联合所有外部表a和其他外部表(类似于a)。
例如:
A:
--------------------
number | time
--------------------
0 |2018-09-10
1 |2018-09-10
2 |2018-09-10
--------------------
B:
--------------------
number | time
--------------------
0 |2018-09-10
1 |2018-09-10
2 |2018-09-10
3 |2018-09-11
--------------------
现在,我不知道为什么下面的sql会使结果不同?
我在这些sql中发现了不同的执行顺序。在情况1和2中,首先执行“选择5.0/number”。在情况3和4中,where子句首先执行。
案例1
DECLARE @date datetime ='2018-09-10';
select 5.0/number
from A
where time = @date and number > 0
Result:
Cannot execute the query "Remote Query" against OLE DB provider "SQLNCLI11" for linked server "(null)". [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Divide by zero error encountered.
案例2
DECLARE @date datetime ='2018-09-10';
select 5.0/temp.number
from
(
select number as number
from A
where time = @date and number > 0
)temp
Result:
Cannot execute the query "Remote Query" against OLE DB provider "SQLNCLI11" for linked server "(null)". [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Divide by zero error encountered.
案例3
select 5.0/number
from A
where time = '2018-09-10' and number > 0
Result:
5.0
2.5
案例4(来自b)
DECLARE @date datetime ='2018-09-10';
select 5.0/number
from B
where time = @date and number > 0
Result:
5.0
2.5
谢谢!!
1条答案
按热度按时间ctehm74n1#
这是否也会产生错误?