SQL Server 2019启动板R脚本``权限被拒绝''错误

时间:2019-09-23 13:18:03

标签: r sql-server

(由KarMau编辑):Here解释了为什么我的客户端登录名无法访问c:\ temp:“ Launchpad将主叫用户的身份映射到工作人员帐户。 。每个工人帐户都被限制在其自己的文件夹中,并且无法访问其自身级别以上的文件夹中的文件。”

在教程“ Lesson 1: Explore and visualize the data”之后,出现错误。在

mainDir <- ''C:\\temp\\plots''  
dir.create(mainDir, recursive = TRUE, showWarnings = FALSE) 

被抛出Permission denied

我正在Windows 10上运行SQL Server 2019 Preview。在寻找解决方案一段时间后,我发现了R命令getwd(),该命令将我带到C:\\Data\\SQLServer\\MSSQL15.SQLEXPRESS\\MSSQL\\ExtensibilityData\\Appcontainer1,这是我的SQL Server数据文件夹的文件夹。 只有在那里,我的代码才能成功创建文件。我重复一遍:仅在子文件夹Appcontainer1中。有一个仅由SID S-1-15标识的未知用户...

对不起,但我至少需要10个信誉才能发布图像... please look here

我的问题:

  1. SQL Server 2019是否在沙箱中运行R代码?

  2. 还有其他解决方案来解决此问题吗?

完整的T-SQL脚本:

    CREATE PROCEDURE [dbo].[RPlotHist]  
    AS  
    BEGIN  
      SET NOCOUNT ON;  
      DECLARE @query nvarchar(max) =  
      N'SELECT cast(tipped as int) as tipped, tip_amount, fare_amount FROM [dbo].[nyctaxi_sample]'  
      EXECUTE sp_execute_external_script @language = N'R',  
      @script = N'  
       # Set output directory for files and check for existing files with same names   
        mainDir <- ''C:\\temp\\plots''  
        dir.create(mainDir, recursive = TRUE, showWarnings = FALSE)  
        setwd(mainDir);  
        print("Creating output plot files:", quote=FALSE)

        # Open a jpeg file and output histogram of tipped variable in that file.  
        dest_filename = tempfile(pattern = ''rHistogram_Tipped_'', tmpdir = mainDir)  
        dest_filename = paste(dest_filename, ''.jpg'',sep="")  
        print(dest_filename, quote=FALSE);  
        jpeg(filename=dest_filename);  
        hist(InputDataSet$tipped, col = ''lightgreen'', xlab=''Tipped'',   
            ylab = ''Counts'', main = ''Histogram, Tipped'');  
         dev.off();  

        # Open a pdf file and output histograms of tip amount and fare amount.   
        # Outputs two plots in one row  
        dest_filename = tempfile(pattern = ''rHistograms_Tip_and_Fare_Amount_'', tmpdir = mainDir)  
        dest_filename = paste(dest_filename, ''.pdf'',sep="")  
        print(dest_filename, quote=FALSE);  
        pdf(file=dest_filename, height=4, width=7);  
        par(mfrow=c(1,2));  
        hist(InputDataSet$tip_amount, col = ''lightgreen'',   
            xlab=''Tip amount ($)'',   
            ylab = ''Counts'',   
            main = ''Histogram, Tip amount'', xlim = c(0,40), 100);  
        hist(InputDataSet$fare_amount, col = ''lightgreen'',   
            xlab=''Fare amount ($)'',   
            ylab = ''Counts'',   
            main = ''Histogram,   
            Fare amount'',   
            xlim = c(0,100), 100);  
       dev.off();  

        # Open a pdf file and output an xyplot of tip amount vs. fare amount using lattice;  
        # Only 10,000 sampled observations are plotted here, otherwise file is large.  
        dest_filename = tempfile(pattern = ''rXYPlots_Tip_vs_Fare_Amount_'', tmpdir = mainDir)  
        dest_filename = paste(dest_filename, ''.pdf'',sep="")  
        print(dest_filename, quote=FALSE);  
        pdf(file=dest_filename, height=4, width=4);  
        plot(tip_amount ~ fare_amount,   
            data = InputDataSet[sample(nrow(InputDataSet), 10000), ],   
            ylim = c(0,50),   
            xlim = c(0,150),   
            cex=.5,   
            pch=19,   
            col=''darkgreen'',    
            main = ''Tip amount by Fare amount'',   
            xlab=''Fare Amount ($)'',   
            ylab = ''Tip Amount ($)'');   
        dev.off();',  
     @input_data_1 = @query  
     END

1 个答案:

答案 0 :(得分:0)

MSSQL Server通常作为Windows上的服务在特殊用户下运行,该用户可能对C:\\temp\\plots的访问受到限制。要更改用户,请在Windows 10上打开“服务”应用,找到SQL Server服务。右键单击属性,在“登录”选项卡上,将帐户更改为可以访问该位置的人。

相关问题