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)