57
Biml for Beginners: Speed up your SSIS development Cathrine Wilhelmsen · SQLBits XV · May 7 th 2016

Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Embed Size (px)

Citation preview

Page 1: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Biml for Beginners:Speed up your SSIS development

Cathrine Wilhelmsen · SQLBits XV · May 7th 2016

Page 2: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 (SQLBits XV)

Tools & Projects

Code Management

The Basicsa

Page 4: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Cathrine Wilhelmsen

@cathrinew

cathrinewilhelmsen.net

Data Warehouse ArchitectBusiness Intelligence Developer

Page 5: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

SSIS developer?

Easily bored?

Tired of repetitive work?

You…

Page 6: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Long development time?

Many SSIS packages?

Frequent requirement changes?

Work…

Page 7: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Ever experienced this?

takeoff!

new standards

crash landing!

Page 8: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Ready for a change?

Page 9: Biml for Beginners: Speed up your SSIS development (SQLBits XV)
Page 10: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 (SQLBits XV)

From Traditional SSIS to Agile SSIS

Traditional SSIS: Plumbing Agile SSIS: Business Logic

Page 12: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 (SQLBits XV)

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 (SQLBits XV)

What do you need?

Page 15: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

…or you can use the new Biml tools

Page 16: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

How does it work?

…generated packages look exactly like manually created packages

Page 17: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Biml syntax

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Page 18: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Root Element

Page 19: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

<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 20: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Elements

Page 21: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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

<Packages>

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

<Package Name="EmptyPackage2"/>

</Packages>

</Biml>

Biml syntax: Attributes

Page 22: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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

<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 (SQLBits XV)

Let's generatesome packages!

Page 25: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Ok, so we can go from Biml to SSIS…

Page 26: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

…can we go from SSIS to Biml?

Page 27: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Yes! :)

Page 28: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Let's reverse-engineersome packages!

Page 29: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

The magic is in the

Page 30: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 31: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

BimlScript Code Nuggets

<#@ … #> Directives (Compiler instructions)

<# … #> Control Nuggets (Control logic)

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

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

Page 32: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 33: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 34: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 35: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

How does it work?

Page 36: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Yes, but how does it work?

Page 37: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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="Load_Customer"/><Package Name="Load_Product"/><Package Name="Load_Sales"/>

</Packages></Biml>

Page 38: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Biml vs. BimlScript

Automate, control and manipulate Biml with C#

Flat XML"Just text"

Page 39: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Let's generatea lot of packages!

Page 40: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Don't Repeat Yourself

Page 41: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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

Don't Repeat Yourself

Page 42: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

BimlExpress vs. BimlOnline

"Black Box"

Only SSIS packages visible

Visual Editors

All in-memory objects visible

Page 43: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 44: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Include Files

Page 45: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Include Files

Page 46: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Include Files

Page 47: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 48: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

CallBimlScript with Parameters

Page 49: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

CallBimlScript with Parameters

Page 50: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

CallBimlScript with Parameters

Page 51: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

CallBimlScript with Parameters

Page 52: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

CallBimlScript with Parameters

Page 53: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

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 54: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

So how does this actually work?

Page 55: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Get things done

Start small

Start simple

Start with ugly code

Keep going

Expand

Improve

Deliver often

Page 56: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

Biml on Monday...

…BimlBreak the rest of the week :)

Page 57: Biml for Beginners: Speed up your SSIS development (SQLBits XV)

@cathrinew

cathrinewilhelmsen.net

linkedin.com/in/cathrinewilhelmsen

[email protected]

slideshare.net/cathrinewilhelmsen

Biml resources and references:

cathrinewilhelmsen.net/biml