Call: 469-635-6200
Name *
Phone No. *
Email
Question
Security Code *
Refresh
 
Submit
Name *
Email *
Phone
Question *
Security Code *
Refresh
 
Submit

Get more from your data

Scalability Experts Blog

ArcCos/Acos in PDW (workaround)

 

ArcCos/Acos in PDW (workaround)


Should you find the need to use ArcCos/Acos in PDW, you will find that the function is not currently supported.   A work around will be to use the following formula:

case @cos when 1 then 0 when -1 then 3.14159265358979 else Atan(-@cos / Sqrt(1 - @cos * @cos)) + 2 * Atan(1) end



Here is code to test on PDW:

DECLARE @cos float

SET @cos = -1

select Top 1 'The ACOS or the number is: ' + convert(varchar, case @cos when 1 then 0 when -1 then 3.14159265358979 else Atan(-@cos / Sqrt(1 - @cos * @cos)) + 2 * Atan(1) end) from sys.databases

set @cos = .5

select top 1 'The ACOS or the number is: ' + convert(varchar, case @cos when 1 then 0 when -1 then 3.14159265358979 else Atan(-@cos / Sqrt(1 - @cos * @cos)) + 2 * Atan(1) end) from sys.databases

set @cos = 1

select top 1 'The ACOS or the number is: ' + convert(varchar, case @cos when 1 then 0 when -1 then 3.14159265358979 else Atan(-@cos / Sqrt(1 - @cos * @cos)) + 2 * Atan(1) end) from sys.databases



Here is code to test on SQL Server:

DECLARE @cos float;

SET @cos = -1;

select 'The ACOS for the number is: ' + convert(varchar, case @cos when 1 then 0 when -1 then 3.14159265358979 else Atan(-@cos / Sqrt(1 - @cos * @cos)) + 2 * Atan(1) end)

Select 'SQL Severs ACOS for the number is ' + CONVERT(varchar, ACOS(@cos));

SET @cos = .5;

select 'The ACOS for the number is: ' + convert(varchar, case @cos when 1 then 0 when -1 then 3.14159265358979 else Atan(-@cos / Sqrt(1 - @cos * @cos)) + 2 * Atan(1) end)

Select 'SQL Severs ACOS for the number is ' + CONVERT(varchar, ACOS(@cos));

SET @cos = 1;

select 'The ACOS for the number is: ' + convert(varchar, case @cos when 1 then 0 when -1 then 3.14159265358979 else Atan(-@cos / Sqrt(1 - @cos * @cos)) + 2 * Atan(1) end)

Select 'SQL Severs ACOS for the number is ' + CONVERT(varchar, ACOS(@cos));



To learn more about Scalability Experts expertise and capabilities visit our Parallel Data Warehouse Solution Page.

 

comments powered by Disqus