Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

82
Biml for Beginners: Speed up your SSIS development Cathrine Wilhelmsen · SQLSaturday Chicago · March 5 th 2016

Transcript of Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Page 1: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Biml for Beginners:Speed up your SSIS development

Cathrine Wilhelmsen · SQLSaturday Chicago · March 5th 2016

Page 2: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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!

Page 3: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

The Basics Tools & Projects

Code Management

Page 4: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Cathrine Wilhelmsen

@cathrinew

cathrinewilhelmsen.net

Data Warehouse ArchitectBusiness Intelligence Developer

Page 5: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

SSIS developer?

Easily bored?

Tired of repetitive work?

You…

…?

Page 6: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Long development time?

Many SSIS packages?

Frequent requirement changes?

Work…

…?

Page 7: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

job done!

new standards

...yay

Ever experienced this?

Page 8: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Ready for a change?

Page 9: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)
Page 10: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Business Intelligence Markup Language

Easy to read and write XML language

Describes business intelligence objects:

• Databases, Schemas, Tables, Views, Columns

• SSIS Packages

• SSAS Cubes

What is Biml?

Page 11: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

From Traditional SSIS to Agile SSIS

Traditional SSIS: Plumbing Agile SSIS: Business Logic

Page 12: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Will Biml solve all your problems?

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 problems!

Page 13: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

How can Biml help you?

Timesaving: Many SSIS Packages from one Biml file

Reusable: Write once and run on any platform

Flexible: Start simple, expand as you learn

Page 14: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

What do you need?

Page 15: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

…or you can use

Page 16: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

…or you can invest in

(Mist will be rebranded as BimlStudio)

Page 17: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

How does it work?

…generated packages look exactly like manually created packages

Page 18: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax

Page 19: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Root Element

Page 20: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Collections of Root Objects

Page 21: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Elements

Page 22: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Attributes

Page 23: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Full vs. Shorthand Syntax

Page 24: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Let's generatesome packages!

Page 25: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Right-click on SSIS project and click Add New Biml File

Page 26: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Biml files are placed in the Miscellaneous folder

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Page 27: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Right-click on the Biml file to Generate SSIS Packages

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Page 28: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

From Biml to SSIS

<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>

Page 29: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

From Biml to SSIS

<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>

Page 30: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

(20% zoom)(150% zoom)

Page 31: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Ok, so we can go from Biml to SSIS…

Page 32: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

…can we go from SSIS to Biml?

Page 33: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Yes!

Page 34: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Let's reverse-engineersome packages!

Page 35: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Package Importer in BimlOnline

Page 36: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Choose a File

Page 37: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Convert from SSIS to Biml

Page 38: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Choose and filter assets

Page 39: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Copy the Biml…

Page 40: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

…or Create /Add to BimlOnline Project

Page 41: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

The magic is in the

Page 42: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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 control and manipulate Biml code

Page 43: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

BimlScript Code Nuggets

<#@ … #> Directives (Instructions to BimlCompiler)

<# … #> Control Nuggets (Control logic)

<#= … #> Text Nuggets (Replace nugget with text value)

<#+ … #> Class Nuggets (Create helper classes and methods)

Page 44: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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>

Page 45: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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>

Page 46: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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>

Page 47: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

How does it work?

Page 48: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Yes, but how does it work?

Page 49: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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>

Page 50: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Biml vs. BimlScript

Automate, control and manipulate Biml with C#

Flat XML"Just text"

Page 51: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Let's generatea lot of packages!

Page 52: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Don't Repeat Yourself

Page 53: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Move common code to separate files

Centralize and reuse in many projects

Update code once for all projects

1. Tiered Biml files

2. Include files

3. CallBimlScript with parameters

Don't Repeat Yourself

Page 54: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

BIDS Helper vs. BimlOnline / Mist

"Black Box"

Only SSIS packages visible

Visual Editors

All in-memory objects visible

Page 55: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Tiered Biml Files

Use the template directive:

<#@ template tier="1" #>

Create objects in-memory from lowest to highest tier to:

• Solve logical dependencies

• Simulate manual workflows

In-memory objects are added to the RootNode

Get objects from RootNode in higher tiers

Page 56: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

Tier 1: Create database connections

Add connections to RootNode

Tier 2: Create loading packages

Use connections from RootNode

Add packages to RootNode

Tier 3: Create master package to execute packages

Use packages from RootNode

Add package to RootNode

Page 57: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 58: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 59: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 60: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 61: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 62: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 63: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 64: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 65: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 66: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

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

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

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

Page 67: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Inside the Black Box: Tiered Biml Files

Page 68: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

1. Create Biml files with specified tiers

2. Select all the tiered Biml files

3. Right-click and click Generate SSIS Packages

How do you use Tiered Biml files?

1

2

3

Page 69: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

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

Include pulls code from the included file into the main file

Page 70: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Include Files

Page 71: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Include Files

Page 72: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Include Files

Page 73: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

CallBimlScript with Parameters

Works like a parameterized include

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

<#@ property name="Table" type="AstTableNode" #>File that calls (caller) passes input parameters

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

CallBimlScript pushes parameters from the caller to the callee, and the callee returns code

Page 74: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

CallBimlScript with Parameters

Page 75: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

CallBimlScript with Parameters

Page 76: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

CallBimlScript with Parameters

logic basedon parameters

Page 77: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

CallBimlScript with Parameters

Page 78: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

CallBimlScript with Parameters

Page 79: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

How does this actually work?

Page 80: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

Get things doneStart small

Start simple

Start with ugly code

Keep goingExpand

Improve

Deliver often

Page 81: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

…BimlBreak the rest of the week

Biml on Monday...

Page 82: Biml for Beginners: Speed up your SSIS development (SQLSaturday Chicago)

@cathrinew

cathrinewilhelmsen.net

no.linkedin.com/in/cathrinewilhelmsen

[email protected]

slideshare.net/cathrinewilhelmsen

Biml resources and references:

cathrinewilhelmsen.net/biml