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

1,483 views

Published on

Biml for Beginners: Speed up your SSIS development (Presented at SQLSaturday Vienna on April 1st 2016)

Published in: Data & Analytics
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,483
On SlideShare
0
From Embeds
0
Number of Embeds
815
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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

  1. 1. Biml for Beginners: Speed up your SSIS development Cathrine Wilhelmsen SQLSaturday Vienna April 1st 2016
  2. 2. 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!
  3. 3. Thank you to our sponsors!
  4. 4. Biml Basics Tools & Projects Code Management …the next 60 minutes…
  5. 5. Cathrine Wilhelmsen @cathrinew cathrinewilhelmsen.net Data Warehouse Architect Business Intelligence Developer
  6. 6. SSIS developer Easily bored Tired of repetitive work You… …?
  7. 7. Long development time Many SSIS packages Frequent requirement changes Work… …?
  8. 8. job done! new standards ...yay Ever experienced this?
  9. 9. Ready for a change?
  10. 10. 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?
  11. 11. Why would you use Biml? SSIS: Plumbing Biml: Business Logic
  12. 12. 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
  13. 13. 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
  14. 14. 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!
  15. 15. 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!
  16. 16. What do you need?
  17. 17. …or you can use the new Biml tools
  18. 18. How does it work? …generated packages look exactly like manually created packages
  19. 19. <Biml xmlns="http://schemas.varigence.com/biml.xsd"> <Packages> <Package Name="EmptyPackage1"></Package> <Package Name="EmptyPackage2"/> </Packages> </Biml> Biml syntax
  20. 20. <Biml xmlns="http://schemas.varigence.com/biml.xsd"> <Packages> <Package Name="EmptyPackage1"></Package> <Package Name="EmptyPackage2"/> </Packages> </Biml> Biml syntax: Root Element
  21. 21. <Biml xmlns="http://schemas.varigence.com/biml.xsd"> <Packages> <Package Name="EmptyPackage1"></Package> <Package Name="EmptyPackage2"/> </Packages> </Biml> Biml syntax: Collections of Root Objects
  22. 22. <Biml xmlns="http://schemas.varigence.com/biml.xsd"> <Packages> <Package Name="EmptyPackage1"></Package> <Package Name="EmptyPackage2"/> </Packages> </Biml> Biml syntax: Elements
  23. 23. <Biml xmlns="http://schemas.varigence.com/biml.xsd"> <Packages> <Package Name="EmptyPackage1"></Package> <Package Name="EmptyPackage2"/> </Packages> </Biml> Biml syntax: Attributes
  24. 24. <Biml xmlns="http://schemas.varigence.com/biml.xsd"> <Packages> <Package Name="EmptyPackage1"></Package> <Package Name="EmptyPackage2"/> </Packages> </Biml> Biml syntax: Full vs. Shorthand Syntax
  25. 25. Let's generate some packages!
  26. 26. Add New Biml File from BimlExpress menu…
  27. 27. …or right-click on SSIS project to Add New Biml File
  28. 28. Biml files are placed under Miscellaneous
  29. 29. Check Biml For Errors from BimlExpress menu…
  30. 30. …or right-click on file to Check Biml For Errors
  31. 31. Generate SSIS Packages from BimlExpress menu…
  32. 32. …or right-click on file to Generate SSIS Packages
  33. 33. 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>
  34. 34. 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>
  35. 35. .biml vs .dtsx: human-readable vs ALL THE CODE! (20% zoom)(150% zoom)
  36. 36. Ok, so we can go from Biml to SSIS…
  37. 37. …can we go from SSIS to Biml?
  38. 38. Yes! 
  39. 39. Let's reverse-engineer some packages!
  40. 40. Package Importer in BimlOnline
  41. 41. Choose a File
  42. 42. Convert from SSIS to Biml
  43. 43. Choose and filter assets
  44. 44. Copy the Biml…
  45. 45. …or Create /Add to BimlOnline Project
  46. 46. The magic is in the
  47. 47. 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
  48. 48. 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)
  49. 49. 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>
  50. 50. 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>
  51. 51. 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>
  52. 52. How does it work?
  53. 53. Yes, but how does it work?
  54. 54. 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>
  55. 55. Biml vs. BimlScript Automate, control and manipulate Biml with C# Flat XML "Just text"
  56. 56. Let's generate a lot of packages!
  57. 57. It's like magic!
  58. 58. Don't Repeat Yourself
  59. 59. 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
  60. 60. BimlExpress vs. BimlOnline / BimlStudio "Black Box" Only SSIS packages visible Visual Editors All in-memory objects visible
  61. 61. 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
  62. 62. 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
  63. 63. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  64. 64. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  65. 65. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  66. 66. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  67. 67. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  68. 68. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  69. 69. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  70. 70. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  71. 71. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  72. 72. Inside the Black Box: Tiered Biml Files <#@ template tier="1" #> <Connections>...</Connections> <#@ template tier="2" #> <Packages>...</Packages> <#@ template tier="3" #> <Package>...</Package>
  73. 73. Inside the Black Box: Tiered Biml Files
  74. 74. 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
  75. 75. 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
  76. 76. Include Files
  77. 77. Include Files
  78. 78. Include Files
  79. 79. 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
  80. 80. CallBimlScript with Parameters
  81. 81. CallBimlScript with Parameters
  82. 82. CallBimlScript with Parameters logic based on parameters
  83. 83. CallBimlScript with Parameters
  84. 84. CallBimlScript with Parameters
  85. 85. How does this actually work?
  86. 86. Biml Basics Tools & Projects Code Management …the past 60 minutes…
  87. 87. 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 :)
  88. 88. Get things done Start small Start simple Start with ugly code Keep going Expand Improve Deliver often
  89. 89. …BimlBreak the rest of the week  Biml on Monday...
  90. 90. Talk to sponsors in the break! 
  91. 91. @cathrinew cathrinewilhelmsen.net linkedin.com/in/cathrinewilhelmsen contact@cathrinewilhelmsen.net slideshare.net/cathrinewilhelmsen Biml resources and references: cathrinewilhelmsen.net/biml

×