biml for beginners: speed up your ssis development (sqlsaturday iceland)

96
Biml for Beginners: Speed up your SSIS development Cathrine Wilhelmsen · SQLSaturday Iceland · June 18 th 2016

Upload: cathrine-wilhelmsen

Post on 11-Jan-2017

2.767 views

Category:

Data & Analytics


0 download

TRANSCRIPT

Biml for Beginners:Speed up your SSIS development

Cathrine Wilhelmsen · SQLSaturday Iceland · June 18th 2016

Thank you to our sponsors!

SQL SATURDAY | #516 | REYKJAVIK 2016

Session Description

SSIS is a powerful tool for extracting, transforming and loading data, but creating and maintaining a large

number of SSIS packages can be both tedious and time-consuming. Even if you use templates and follow

best practices you often have to repeat the same steps over and over and over again. Handling metadata

and schema changes is a manual process, and there are no easy ways to implement new requirements in

multiple packages at the same time.

It is time to bring the Don't Repeat Yourself (DRY) software engineering principle to SSIS projects. First

learn how to use Biml and BimlScript to generate SSIS packages from database metadata and implement

changes in all packages with just a few clicks. Then take the DRY principle one step further and learn how

to update all packages in multiple projects by separating and reusing common code.

Speed up your SSIS development by using Biml and BimlScript, and see how you can complete in a day

what once took more than a week!

Biml Basics Tools & Projects

Code Management

…the next 60 minutes…

Cathrine Wilhelmsen

@cathrinew

cathrinew.net

Data Warehouse ArchitectBusiness Intelligence Developer

You…

…?

SSIS developer

Easily bored

Tired of repetitive work

Work…

…?

Long development time

Many SSIS packages

Frequent requirement changes

job done!

new standards

...yay

Ever experienced this?

Ready for a change?

What is Biml?

Business Intelligence Markup Language

Easy to read and write XML language

Describes business intelligence objects:

• Databases, Schemas, Tables, Views, Columns

• SSIS Packages

• SSAS Cubes

Why use Biml?

SSIS: Plumbing Biml: Business Logic

SSIS: Plumbing

Time wasted on dragging, dropping, connecting, aligning

Create the same package over and over and over again with just a few changes

Standards, patterns and templates must be defined up-front

Changes must be done in every single package

High risk of manual errors

More packages, more time

Biml: Business Logic

Spend time on what is unique in a package

Create a pattern once and reuse for all similar packages

Handle scope and requirement changes quickly and easily

Changes can be applied to all packages at once

Lower risk of manual errors

Longer time to start, but then reuse and scale

Will Biml solve all your challenges?

Probably not...

Biml is a tool for generating SSIS packages

Biml is not a pre-defined ETL framework

Biml is not a tool for automated deployment

...but it will solve many challenges!

How can Biml help you?

Biml is great for large projects with common patterns…

Timesaving: Many SSIS packages from one Biml file

Reusable: Write once and run on any platform

Flexible: Start simple, expand as you learn

…but is also useful for smaller projects!

What do you need?

BIDS Helper

Free open-source add-in for Visual Studio

60+ features for SSIS, SSAS and SSRS

Includes basic Biml package generator

bidshelper.codeplex.com

…or you can use the new Biml tools

BimlExpress

Free add-in for Visual Studio

Code editor with syntax highlighting and Biml Intellisense

More frequent updates than BIDS Helper

varigence.com/bimlexpress

BimlOnline

Free browser-based Biml editor

Code editor with Biml and C# Intellisense

Reverse-engineer from SSIS to Biml

bimlonline.com

BimlStudio

Licensed full-featured development environment for Biml

Visual designer and metadata modeling

Full-stack automation and transformers

varigence.com/bimlstudio

How does it work?

…generated packages look exactly like manually created packages

Biml syntax

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<Package Name="EmptyPackage1"></Package>

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Root Element

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<Package Name="EmptyPackage1"></Package>

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Collections of Root Elements

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<Package Name="EmptyPackage1"></Package>

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Elements

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<Package Name="EmptyPackage1"></Package>

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Attributes

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<Package Name="EmptyPackage1"></Package>

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Full vs. Shorthand Syntax

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<Package Name="EmptyPackage1"></Package>

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Let's generatesome packages!

Goal: Load from source to staging

Add New Biml File from BimlExpress menu…

…or right-click on SSIS project to Add New Biml File

Biml files are placed under Miscellaneous

Check Biml For Errors from BimlExpress menu…

…or right-click on file to Check Biml For Errors

Generate SSIS Packages from BimlExpress menu…

…or right-click on file to Generate SSIS Packages

From Biml to SSIS: Control Flow

<Package Name="TruncateLoad" ConstraintMode="Linear">

<Tasks>

<ExecuteSQL Name="Truncate Table" ConnectionName="Staging">

<DirectInput>TRUNCATE TABLE DestinationTable</DirectInput>

</ExecuteSQL>

<Dataflow Name="Load Table">

<Transformations>...</Transformations>

</Dataflow>

</Tasks>

</Package>

From Biml to SSIS: Data Flow

<Transformations>

<OleDbSource Name="Source" ConnectionName="AW2014">

<ExternalTableInput Table="SourceTable" />

</OleDbSource>

<DerivedColumns Name="Add LoadDate">

<Columns>

<Column Name="LoadDate" DataType="DateTime">

@[System::StartTime]

</Column>

</Columns>

</DerivedColumns>

<OleDbDestination Name="Destination" ConnectionName="Staging">

<ExternalTableOutput Table="DestinationTable" />

</OleDbDestination>

</Transformations>

.biml vs .dtsx: human-readable vs ALL THE CODE!

(20% zoom)(150% zoom)

Ok, so we can go from Biml to SSIS…

…can we go from SSIS to Biml?

Yes!

Let's reverse-engineersome packages!

Package Importer in BimlOnline

Choose a File

Convert from SSIS to Biml

Choose and filter assets

Copy the Biml…

…or Create /Add to BimlOnline Project

The magic is in the

What is BimlScript?

Extend Biml with C# or VB code blocks

Import database structure and metadata

Loop over tables and columns

Expressions replace static values

Allows you to generate, control and manipulate Biml code

BimlScript Code Nuggets

<# … #> Control Nuggets (Control logic)

<#= … #> Text Nuggets (Returns string)

<#@ … #> Directives (Compiler instructions)

<#+ … #> Class Nuggets (Create C# classes)

BimlScript Syntax

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<# foreach (var table in RootNode.Tables) { #>

<Package Name="Load_<#=table.Name#>"></Package>

<# } #>

</Packages>

</Biml>

BimlScript Syntax: Control Nuggets

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<# foreach (var table in RootNode.Tables) { #>

<Package Name="Load_<#=table.Name#>"></Package>

<# } #>

</Packages>

</Biml>

BimlScript Syntax: Text Nuggets

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<# foreach (var table in RootNode.Tables) { #>

<Package Name="Load_<#=table.Name#>"></Package>

<# } #>

</Packages>

</Biml>

How does it work?

Yes, but how does it work?

Yes, but how does it actually work?

<Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<# foreach (var table in RootNode.Tables) { #>

<Package Name="Load<#=table.Name#>"></Package>

<# } #>

</Packages>

</Biml><Biml xmlns="http://schemas.varigence.com/biml.xsd">

<Packages>

<Package Name="LoadCustomer"></Package>

<Package Name="LoadProduct"></Package>

<Package Name="LoadSales"></Package>

</Packages>

</Biml>

Biml vs. BimlScript

Generate, control and manipulate Biml with C#

Flat XML"Just text"

Let's generatea lot of packages!

It's like magic!

Code Management

Don't Repeat Yourself

Move common code to separate files

Centralize and reuse in many projects

Update code once for all projects

1. Include files

2. CallBimlScript with parameters

3. Tiered Biml files

BimlExpress vs. BimlOnline / BimlStudio

"Black Box"

Only SSIS packages visible

Visual Editors

All in-memory objects visible

Include Files

Include common code in multiple files and projects

Can include many file types: .biml .txt .sql .cs

Use the include directive

<#@ include file="CommonCode.biml" #>

The directive will be replaced by the included file

Works like an automated Copy & Paste

Include Files

Include Files

Include Files

CallBimlScript with Parameters

Works like a parameterized include (or stored procedure)

File to be called (callee) specifies input parameters it accepts

<#@ property name="Parameter" type="String" #>

File that calls (caller) passes input parameters

<#=CallBimlScript("CommonCode.biml", Parameter)#>

CallBimlScript with Parameters

CallBimlScript with Parameters

CallBimlScript with Parameters

CallBimlScript with Parameters

CallBimlScript with Parameters

Tiered Biml Files

Split Biml code in multiple files and use the template directive:

<#@ template tier="1" #>

Compile Biml from lowest to highest tier to:

• Solve logical dependencies

• Simulate manual workflows

For each tier, objects are added to the RootNode

Higher tiers can use objects from lower tiers

What is this RootNode?

When working with flat Biml,the <Biml> root element contains collections of elements:

<Biml>

<Connections>...</Connections>

<Databases>...</Databases>

<Schemas>...</Schemas>

<Tables>...</Tables>

<Projects>...</Projects>

<Packages>...</Packages>

</Biml>

When working with BimlScript, the RootNode object contains collections of objects:

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

<#@ template tier="1" #><Connections>...</Connections>

<#@ template tier="2" #><Packages>...</Packages>

<#@ template tier="3" #><Package>...</Package>

Inside the Black Box: Tiered Biml Files

How do you use Tiered Biml files?

1. Create Biml files with specified tiers

2. Select all the tiered Biml files

3. Right-click and click Generate SSIS Packages

1

2

3

How does this actually work?

Biml Basics Tools & Projects

Code Management

…the past 60 minutes…

What do you do next?

1. Install BimlExpress

2. Complete lessons on BimlScript.com

3. Identify your SSIS patterns

4. Rewrite one SSIS package to Biml(Boost your learning by reverse-engineering with BimlOnline)

5. Expand with BimlScript

6. Separate and reuse common code

7. ...never look back to the days of drag&drop :)

Get things done

Start small

Start simple

Start with ugly code

Keep going

Expand

Improve

Deliver often

Biml on Monday...

…BimlBreak the rest of the week

@cathrinew

cathrinew.net

linkedin.com/in/cathrinewilhelmsen

[email protected]

slideshare.net/cathrinewilhelmsen

Biml resources and references:

cathrinew.net/biml