SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

SQL Server 2016 Bug in R Integration?

 

I am studying the latest R integration with SQL Server 2016, and I believe I encounter a bug when using sp_execute_external_script. So here is the re-play of the bug;

If I run the following code, I will get an error.

 

-- this will return an error

exec sp_execute_external_script @language=N'R'
, @script = N' result <- as.data.frame(c(i, j));'
, @params = N'@i varchar(100), @j varchar(100)'
, @i = 'hello'
, @j = 'world'
, @output_data_1_name = N'result' -- the position of this param caused problem
with result sets ((test varchar(100)));

/* -- the following error will occur
Msg 8144, Level 16, State 2, Line 12
Procedure or function  has too many arguments specified.
*/

However, if I put @output_data_1_name in front of @params , everything works fine.

-- this will work fine 
exec sp_execute_external_script @language=N'R'
, @script = N' result <- as.data.frame(c(i, j));'
, @output_data_1_name = N'result'  -- correct position !
, @params = N'@i varchar(100), @j varchar(100)'
, @i = 'hello'
, @j = 'world'
with result sets ((test varchar(100)));

/* -- this will return the expected result

test
----
hello
world
*/

So in short, it seems a named parameter’s position may cause the stored procedure to fail?

My environment is SQL Server 2016 Developer Edition with the latest SP1 + CU1, as shown below

select @@version

-- returns
---------------------------------------------------------------------------------------------------------
Microsoft SQL Server 2016 (SP1-CU1) (KB3208177) - 13.0.4411.0 (X64) 
	Jan  6 2017 14:24:37 
	Copyright (c) Microsoft Corporation
	Developer Edition (64-bit) on Windows 10 Pro 6.3 <X64> (Build 14393: )

Comments

Leave a comment on the original post [dbaphilosophy.wordpress.com, opens in a new window]

Loading comments...