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

92
Biml for Beginners: Speed up your SSIS development Cathrine Wilhelmsen SQLSaturday Vienna April 1 st 2016

Upload: cathrine-wilhelmsen

Post on 11-Jan-2017

1.476 views

Category:

Data & Analytics


0 download

TRANSCRIPT

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

Biml for Beginners:Speed up your SSIS development

Cathrine Wilhelmsen

SQLSaturday Vienna

April 1st 2016

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

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 4: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Biml Basics Tools & Projects

Code Management

…the next 60 minutes…

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

Cathrine Wilhelmsen

@cathrinew

cathrinewilhelmsen.net

Data Warehouse Architect

Business Intelligence Developer

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

SSIS developer

Easily bored

Tired of repetitive work

You…

…?

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

Long development time

Many SSIS packages

Frequent requirement changes

Work…

…?

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

job done!

new standards

...yay

Ever experienced this?

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

Ready for a change?

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

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 12: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Why would you use Biml?

SSIS: Plumbing Biml: Business Logic

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

Traditional 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

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

Agile SSIS: 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

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

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!

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

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!

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

What do you need?

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

…or you can use the new Biml tools

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

How does it work?

…generated packages look exactly like manually created packages

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

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax

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

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Root Element

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

<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 23: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Elements

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

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Attributes

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

<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 26: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Let's generatesome packages!

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

Add New Biml File from BimlExpress menu…

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

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

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

Biml files are placed under Miscellaneous

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

Check Biml For Errors from BimlExpress menu…

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

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

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

Generate SSIS Packages from BimlExpress menu…

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

…or right-click on file to Generate SSIS Packages

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

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>

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

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>

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

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

(20% zoom)(150% zoom)

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

Ok, so we can go from Biml to SSIS…

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

…can we go from SSIS to Biml?

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

Yes!

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

Let's reverse-engineersome packages!

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

Package Importer in BimlOnline

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

Choose a File

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

Convert from SSIS to Biml

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

Choose and filter assets

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

Copy the Biml…

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

…or Create /Add to BimlOnline Project

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

The magic is in the

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

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 49: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

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 50: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

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 51: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

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 52: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

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 53: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

How does it work?

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

Yes, but how does it work?

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

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 56: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Biml vs. BimlScript

Automate, control and

manipulate Biml with C#

Flat XML

"Just text"

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

Let's generatea lot of packages!

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

It's like magic!

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

Don't Repeat Yourself

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

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 61: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

BimlExpress vs. BimlOnline / BimlStudio

"Black Box"

Only SSIS packages visible

Visual Editors

All in-memory objects visible

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

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 63: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Inside the Black Box: Tiered Biml Files

Tier 1: Create database connections

Tier 2: Create loading packages

Tier 3: Create master package to execute packages

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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

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

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

Inside the Black Box: Tiered Biml Files

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

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 76: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

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 77: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Include Files

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

Include Files

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

Include Files

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

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 81: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

CallBimlScript with Parameters

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

CallBimlScript with Parameters

Page 83: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

CallBimlScript with Parameters

logic basedon parameters

Page 84: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

CallBimlScript with Parameters

Page 85: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

CallBimlScript with Parameters

Page 86: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

How does this actually work?

Page 87: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Biml Basics Tools & Projects

Code Management

…the past 60 minutes…

Page 88: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

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

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

Page 89: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

Get things done

Start small

Start simple

Start with ugly code

Keep going

Expand

Improve

Deliver often

Page 90: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

…BimlBreak the rest of the week

Biml on Monday...

Page 92: Biml for Beginners: Speed up your SSIS development (SQLSaturday Vienna)

@cathrinew

cathrinewilhelmsen.net

linkedin.com/in/cathrinewilhelmsen

[email protected]

slideshare.net/cathrinewilhelmsen

Biml resources and references:

cathrinewilhelmsen.net/biml