Netherlands: Software

Introductie van Micorosoft SQL Server 2016

Issue link:

Contents of this Issue


Page 127 of 212

115 C H A P T E R 6 | More analytics wait A Boolean value to control whether the job will be blocking or nonblocking. Use TRUE for blocking, which prevents you from running other R code until the job completes. Use FALSE for nonblocking, which allows you to run other R code while the job continues to execute. consoleOutput A Boolean value that controls whether the output of R execution on the SQL Server displays locally in the R console. Another variable stores the result of the RxInSQLServer function and is passed as an argument to the rxSetComputeContext function. Now your subsequent RevoScaleR functions run on the server instance. Note The RevoScaleR package enables the scalable, high-performance, multicore analytic functions. In this chapter, we explore several functions in this package. Setting the compute context affects only the RevoScaleR functions. Open-source R functions continue to execute locally. Important At the time of this writing, the RevoScaleR package requires a SQL login with the necessary permissions to create tables and read data in a database. Data source To execute R commands against data, you define a data source. A data source is a subset of data from your database and can be a table, a view, or a SQL query. By creating a data source, you create only a reference to a result set. Data never leaves the database. Example 6-4 shows how to create a data source object in the R IDE by first assigning a T-SQL query string to a variable, passing the variable to the RxSqlServerData function, and storing the data source reference in another variable. Example 6-4: Creating a data source sampleDataQuery <- "select top 1000 tipped, fare_amount, passenger_count, trip_time_in_secs, trip_distance, pickup_datetime, dropoff_datetime, pickup_longitude, pickup_latitude, dropoff_longitude, dropoff_latitude from nyctaxi_sample" inDataSource <- RxSqlServerData(sqlQuery = sampleDataQuery, connectionString = connStr, colClasses = c(pickup_longitude = "numeric", pickup_latitude = "numeric", dropoff_longitude = "numeric", dropoff_latitude = "numeric"), stringsAsFactors=TRUE, rowsPerRead=500) In this example, the RxSqlServerData function takes the following arguments: sqlQuery A string representing a valid SQL query. connectionString An ODBC connection string for SQL Server. At the time of this writing, you must use a SQL login in the connection string. colClasses A character vector that maps the column types between SQL Server and R. For the purposes of this section, a character vector is a string. In this case, the string must contain the names of columns in the query paired with one of the following allowable column types: logical, integer, float32, numeric, character, factor, int16, uint16, or date. rowsPerRead Number of rows read into a chunk. R Services processes chunks of data and aggregates the results. Use this argument to control the chunk size to manage memory usage. If this value is too high, processing can slow as the result of inadequate memory resources, although a value that is too low might also adversely affect processing.

Articles in this issue

Archives of this issue

view archives of Netherlands: Software - Introductie van Micorosoft SQL Server 2016