built-indownload.microsoft.com › download › e › 1 › 3 › e13a3c07-15b9-42b… ·...
TRANSCRIPT
built-in
at massive scale
built-in
On-prem and Cloud
Value
Data
$1.6trillion
(1800조원)
ActionDecisions
Open source “사실상 표준어”
분석, 컴퓨팅, 모델링
글로벌 커뮤니티
수백만 명의사용자
7,000+ 패키지
빅데이터생태계
확장성
주) The Comprehensive R Archive Network
https://cran.r-project.org/
http://www.maths.lancs.ac.uk/~rowlings/R/TaskViews/
$?
기업 관점에서TCO와 ROI에 대한불확실성
(오픈소스 프로젝트관리를 위한인력구성, 교육, 기술지원 영역)
체계적인 관리가되지 않을 경우, 데이터 인프라와통합이 복잡하고Silo를 방지하기쉽지 않음
스케일과 성능 문제 데이터 이동으로인하여 효율적인데이터 모델링이방해받음
In-DB 분석 (SP에서 R호출)
고성능 병렬쓰레딩/프로세싱
운영의 용이성
개발자, DBA, 데이터사이언티스트가 선호하는도구를 쓸 수 있음
온프레미스에서 모델링하고, 클라우드에서 스코어링하고 –또는 그 반대로
메모리 한계를 극복하는 손쉬운방법 – 대용량 데이터 처리시이점
SQL Server 2016에 포함 / 기술지원
기존의 R 코드를 재사용하고최적화할 수 있음
재개발 및 교육 비용 절감
$
Best of both worlds
SQL 사용 영역 : 인메모리 컬럼스토어 인덱스를 이용한 빠른 쿼리
R 사용 영역 : 데이터 탐색, 예측 모델링, 스코어링, 시각화
데이터 사이언티스트
데이터와 직접 상호작용
SQL 개발자 및 DBA데이터와 분석로직을
함께 관리
확장모듈솔루션 예시
영업 Forecasting
재고 효율화
예측 정비
신용 리스크 방지
…
010010
100100
010101
관계형 데이터
Analytics library
T-SQL 인터페이스
…R 통합모듈
Built into SQL Server 2016
010010100100010101
데이터를 이동할 필요 없이실시간으로 운영데이터 분석
R과 인메모리 고성능 분석을 동시에,병렬 쓰레드/프로세싱 R 함수 활용
Custom parallelization
PEMA-R API
rxDataStep
rxExec
Data step
Data import – Delimited, fixed, SAS, SPSS, OBDC
Variable creation & transformation
Recode variables
Factor variables
Missing value handling
Sort, merge, split
Aggregate by category (means, sums)
Descriptive statistics
Min/max, mean, median (approx.)
Quantiles (approx.)
Standard deviation
Variance
Correlation
Covariance
Sum of squares (cross-product matrix for set variables)
Pairwise cross tabs
Risk ratio & odds ratio
Cross-tabulation of data (standard tables & long form)
Marginal summaries of cross tabulations
Statistical tests
Chi Square Test
Kendall Rank Correlation
Fisher’s Exact Test
Student’s t-Test
Sampling
Subsample (observations & variables)
Random sampling
Predictive models
Sum of squares (cross-product matrix for set variables)
Multiple linear regression
Generalized linear models (GLM) exponential family distributions: binomial,
Gaussian, inverse Gaussian, Poisson, Tweedie. Standard link functions: cauchit,
identity, log, logit, probit. User defined distributions & link functions.
Covariance & correlation matrices
Logistic regression
Classification & regression trees
Predictions/scoring for models
Residuals for all models
Simulation
Simulation (e.g., Monte Carlo)
Parallel random number generation
Cluster analysis
K-Means
Classification
Decision trees
Decision forests
Gradient-boosted decision trees
Naïve Bayes
@language sysname Valid values are: R
, @script nvarchar(max) R script as a literal
, @parallel bit Indicates if multiple invocations of R script can be executed in parallel with distinct set of rows. Valid values are 0 | 1. Default is 0.
, @input_data_1 nvarchar(max) Input data for the R script in the form of a SQL query
, @input_data_1_partition_by_columns nvarchar(max) List of columns to partition the input data
{ , [ @params = ] N'@parameter_name data_type [ ,...n ]' } List of input parameter declarations for the R script
{ , [ @param1 = ] 'value1' [ ,...n ] } Values for the input parameters used by the R script
WITH <execute_option> [ ,...n ] ][;]
<execute_option>::={
{ RESULT SETS UNDEFINED } | { RESULT SETS NONE } | { RESULT SETS ( <result_sets_definition> [,...n ] ) }
}
<result_sets_definition> ::= {(
{ column_name data_type[ COLLATE collation_name ] [ NULL | NOT NULL ] }[,...n ]
)| AS OBJECT
[ db_name . [ schema_name ] . | schema_name . ] {table_name | view_name | table_valued_function_name }
| AS TYPE [ schema_name.]table_type_name| AS FOR XML
}
기존 R 스크립트:
IrisPredict <- function(data, model){library(e1071)predicted_species <- predict(model, data)return(predicted_species)
}
library(RODBC)conn <- odbcConnect("MySqlAzure", uid = myUser, pwd = myPassword);Iris_data <-sqlFetch(conn, "Iris_Data");Iris_model <-sqlQuery(conn, "select model from my_iris_model");IrisPredict (Iris_data, model);
SQL Server에서의 R 스크립트 실행:
/* Input table schema */create table Iris_Data (name varchar(100), length int, width int);/* Model table schema */create table my_iris_model (model varbinary(max));
declare @iris_model varbinary(max) = (select model from my_iris_model);
exec sp_execute_external_script@language = 'R'
, @script = 'IrisPredict <- function(data, model){library(e1071)predicted_species <- predict(model, data)return(predicted_species)
}IrisPredict(input_data_1, model);', @parallel = default, @input_data_1 = N'select * from Iris_Data', @params = N'@model varbinary(max)', @model = @iris_modelwith result sets ((name varchar(100), length int, width int, species varchar(30)));
yellow : Original R script내에포함된 SQL Queryaqua : SQL variable에 Bind된 R variable
데이터 사이언티스트 / 데이터 엔지니어
알고리즘 배포, 데이터 직접분석
전체 데이터셋에 대한 분석
In-DB에서 실행 및 검증
R을 통한 데이터 가공 스케쥴링
SQL/App 개발자
데이터 가공과 고급분석을DB를 통해 수행
SQL과 저장 프로시저를 통해R 실행 및 결과 리턴
개발 로직 단순화
DBA
데이터 저장공간과 분석공간의통합 관리
보다 쉽게 성능과 안정성 관리
보안 측면 R 런타임 실행 보호및 통제
서로 다른 두 플랫폼을 연결하는 기술
T-SQL을 이용하여 양쪽의 데이터를 연계/분석하고 데이터이동을 쉽게 해주는 확장성 있는 쿼리 처리 프레임웍
2012 2013 ……… 2016…2014
PolyBase가 SQL Server PDW V2에최초 도입됨(현재의 APS)
PolyBasein SQL Server 16 (CTP3)
PolyBasein SQL DW
PolyBasein SQL Server 2016
2015
Hadoop 데이터에 대한 고성능 데이터 조회
DW 데이터를 Hadoop 으로 Archiving (move)
DW 데이터를 Hadoop 으로 Export (copy)
Hadoop 데이터를 DW 로 Import (copy)
“Poly” & 클라우드와의 통합
다양한Hadoop Distribution의 지원
단일 쿼리로정형/비정형 연계분석
Push Down Capability
•다양한 Hadoop 배포판 지원 (no lock-in)
•On-Premise
•Hortonworks on Windows, Linux (~HDP 2.3)
•Cloudera CDH 4.3 - 5.5 on Linux
•HDInsight on Analytics Platform System
•Cloud : HDInsight on Azure, Azure blob storage
다양한 Hadoop Distribution의 지원
고성능 Push Down 기능
•Hadoop 내 요약(Column/Row Filtering) 후 가져옴
•데이터 이동량이 줄어 분석 성능 향상
•전송시 데이터 요약 여부를 자동 판단함
(PolyBase 엔진이 통계정보 기반 판단, 또는 힌트적용)
•Pushdown 외에도 병렬채널을 통해 전송속도 향상,
Hive에 비해 동시성(Concurrency)이 획기적 향상됨
“Poly” & 클라우드와의 통합
•Hadoop/HDFS를 넘어 다양한 형태로의 확장을 고려한
아키텍처
•현재 Delimited Textfile 및 Hive RCFile (Record
Columnar File), ORC File, Parquet 지원. JSON 지원.
•클라우드상 Blob Storage를 활용하는 최초의 “Hybrid
시나리오” 구현
단일 쿼리로 정형/비정형 연계분석
•분석 관점 : RDB/Hadoop 데이터를 인메모리 연계분석
•이동 관점 : RDB-Hadoop간 양방향 병렬 이동/저장
•표준 SQL 문법 : Map/Reduce 배울 필요 없음
SQL
PolyBaseEngine
SQLSQL SQL
PolyBaseDMS
PolyBaseDMS
PolyBaseDMS
PolyBaseDMS
Head Node
AzureStorageVolume
AzureStorageVolume
AzureStorageVolume
AzureNamenode(HDFS)
Hadoop Cluster
DataNode
FileSystem
DataNode
FileSystem
DataNode
FileSystem
DataNode
FileSystem
DataNode
FileSystem
Namenode(HDFS) DataNode
FileSystem
DataNode
FileSystem
DataNode
FileSystem
DataNode
FileSystem
DataNode
FileSystem
DataNode
FileSystem
Compute Nodes
Engine Service
SQL Server
DMS
DB
SQL Server
DMS
DB
SQL Server
DMS
DB
DMS
HeadNode
SQL ServerPolyBase Group
Hadoop Cluster
EXEC sp_join_polybase_group bob.contoso.local, DemoServer, 1433;EXEC sp_leave_polybase_group;
CREATE EXTERNAL DATA SOURCE HDP_2_sehan
WITH (
TYPE = HADOOP,
LOCATION = 'hdfs://xx.xx.xx.xx'
)
CREATE EXTERNAL FILE FORMAT TextDelimited_sehan
WITH (
FORMAT_TYPE = DELIMITEDTEXT,
FORMAT_OPTIONS (FIELD_TERMINATOR ='|')
);
CREATE EXTERNAL TABLE [dbo].[DimCustomer_Hadoop_sehan] (
[CustomerKey] int NULL,
[GeographyKey] int NULL,
[CustomerLabel] nvarchar(100) NULL,
…
)
WITH (LOCATION='/DemoDb/DimCustomer.txt',
DATA_SOURCE = HDP_2_sehan,
FILE_FORMAT = TextDelimited_sehan,
REJECT_VALUE = 0.1,
REJECT_SAMPLE_VALUE = 10000,
REJECT_TYPE = PERCENTAGE
)
Hadoop Cluster Data Source 정의
File Format 정의
External Table 정의
• 일반테이블처럼 BI/App에서 접근
• 권한 관리
built-in
at massive scale
built-in
On-prem and Cloud