InputParameter: SQL 저장 프로시저 클래스 생성기의 입력 매개 변수

InputParameter: SQL Server 저장 프로시저에 포함할 R 함수의 입력 매개 변수에 관한 정보를 캡처하는 InputParameter 개체를 생성합니다. 이 개체는 저장 프로시저의 입력 매개 변수가 됩니다. 입력 매개 변수의 지원되는 R 형식은 POSIXct, numeric, character, integer, logical, raw입니다.

사용

  InputParameter(name, type, defaultValue = NULL, defaultQuery = NULL,
  value = NULL, enableOutput = FALSE)

인수

name

입력 매개 변수 개체의 이름인 문자열입니다.

type

입력 매개 변수 개체의 R 형식을 나타내는 문자열입니다.

defaultValue

매개 변수의 기본값입니다. “raw”에 대해서는 지원되지 않습니다.

defaultQuery

저장 프로시저 실행 시 다른 쿼리가 제공되지 않는 경우 데이터를 검색할 기본 쿼리를 지정하는 문자열입니다.

value

다음에 저장 프로시저를 실행할 때 매개 변수에 사용할 값입니다.

enableOutput

입출력 매개 변수로 설정

InputParameter 개체


 ## Not run:

 # See ?StoredProcedure for creating the `cleandata` table.
 # and ?executeStoredProcedure for creating the `rdata` table. 

 # score1 makes a batch prediction given clean data(indata),
 # model object(model_param), and the new name of the variable
 # that is being predicted
 score1 <- function(indata, model_param, predVarName) {
 indata[,"DayOfWeek"] <- factor(indata[,"DayOfWeek"], levels=c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"))
 # The connection string
 conStr <- paste("Driver={ODBC Driver 13 for SQL Server};Server=.;Database=RevoTestDB;",
                 "Trusted_Connection=Yes;", sep = "")
 # The compute context
 computeContext <- RxInSqlServer(numTasks=4, connectionString=conStr)
 mm <- rxReadObject(as.raw(model_param))
 # Predict
 result <- rxPredict(modelObject = mm,
                     data = indata,
                     outData = NULL,
                     predVarNames = predVarName,
                     extraVarsToWrite = c("ArrDelay"),
                     writeModelVars = TRUE,
                     overwrite = TRUE)
}
# connections string
conStr <- paste0("Driver={ODBC Driver 13 for SQL Server};Server=.;Database=RevoTestDB;",
                "Trusted_Connection=Yes;")
# create InpuData Object for an input parameter that is a data frame
id <- InputData(name = "indata", defaultQuery = "SELECT * from cleanData")
# InputParameter for the model_param input variable
model <- InputParameter("model_param", "raw",
                       defaultQuery =
                         "select top 1 value from rdata where [key] = 'linmod.v1'")
# InputParameter for the predVarName variable
name <- InputParameter("predVarName", "character", value = "ArrDelayEstimate")
sp_df_df <- StoredProcedure(score1, "sTest", id, model, name,
                       filePath = ".")
## End(Not run)