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: )
Advertisements
This entry was posted in Administration and tagged . Bookmark the permalink.

One Response to SQL Server 2016 Bug in R Integration?

  1. jxhyao says:

    Here is a reasonable explanation http://dba.stackexchange.com/questions/161564/bug-with-sp-execute-external-script, but I still feel this seems like a bug unless MS can confirm it is designed so. Please vote up for it if you think this is a bug at https://connect.microsoft.com/SQLServer/feedback/details/3119078

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s