How to operationalize your data analytics pipelines

Published Sep 08 2020 06:39 AM 3,545 Views
Microsoft

Azure Synapse Analytics is an analytics platform that provides productive developer experiences such as the Synapse Studio bulk load wizard helping data engineers quickly get data ingested and datasets onboarded through a code-less experience. The platform also comes with other low-code authoring experiences for data integration where it is now even easier to take the next step and further orchestrate and operationalize loads in just a few clicks. You can use built-in data pipelines that are extremely flexible where you can customize them according to your requirements all within the Synapse studio for maximum productivity.

 

This how to guide walks you through how to quickly set up a continuous data pipeline that automatically loads data as the files arrive in your storage account of your SQL pool.

 

1. Generate your COPY statement within a stored procedure by using the Synapse Studio bulk load wizard.

 

2. Use familiar dynamic SQL syntax to parameterize the COPY statement’s storage account location. You can also generate the time of ingestion using default values within the COPY statement. Sample code:

 

CREATE PROC [dbo].[loadSales] @storagelocation nvarchar(100) AS

    DECLARE @loadtime nvarchar(30);
    DECLARE @COPY_statement nvarchar(4000);

    SET @loadtime = GetDate();
    SET @COPY_statement = 
        N'COPY INTO [dbo].[Trip] 
		(
			[DateID] 1, 
			[MedallionID] 2, 
			[HackneyLicenseID] 3, 
			[PickupTimeID] 4,
			[DropoffTimeID] 5,
			[PickupGeographyID] 6,
			[DropoffGeographyID] 7,
			[PickupLatitude] 8,
			[PickupLongitude] 9,
			[PickupLatLong] 10,
			[DropoffLatitude] 11,
			[DropoffLongitude] 12,
			[DropoffLatLong] 13,
			[PassengerCount] 14,
			[TripDurationSeconds] 15,
			[TripDistanceMiles] 16,
			[PaymentType] 17,
			[FareAmount] 18,
			[SurchargeAmount] 19,
			[TaxAmount] 20,
			[TipAmount] 21,
			[TollsAmount] 22,
			[TotalAmount] 23,
			[loadTime] default ''' + @loadtime + ''' 24
	)
		FROM '''  + @storagelocation + ''' 
		WITH (
			FIELDTERMINATOR=''|'',
			ROWTERMINATOR=''0x0A''
		) OPTION (LABEL = ''loadTime: ' + @loadtime + ''');';

        EXEC sp_executesql @COPY_statement;

 

 

3. Create a Synapse pipeline in the Synapse Studio with an event-based trigger for when a blob is created in your storage container and parameterize the blob path (folder path and file name) as part of the pipeline. Additional documentation on pipeline triggers is here.

 

Parameterized pipeline:

ParameterizedPipeline.png

 

Event-based trigger:

EventBasedTrigger.png

 

Trigger parameters:

TriggerParameters.png

 

4. Add the stored procedure to a stored procedure activity in your pipeline where the stored procedure parameter is the blob path pipeline parameter and publish your pipeline to your workspace. Additional documentation on the stored procedure activity is here.

SPActivity.png

 

In just 4 steps, you have now created a data pipeline which automatically and continuously loads files as they land in your staging storage account location using the COPY statement in a stored procedure. You did not need to provision or integrate any event notification services such as Azure Event Grid or Azure Queue Storage to support this auto-ingestion workflow and there were minimal code changes.

 

Synapse pipelines are flexible where there is a range of configurations and customization you can set to address your scenarios. Here are some other considerations when operationalizing your data pipelines:

 

  1. Add additional transformation logic for further processing within your stored procedure or create additional stored procedures (activities) in your pipeline
  2. Instead of creating a stored procedure, you can leverage the pipeline COPY activity with the COPY statement. This will make your data pipeline authoring experience code-less. You can configure the COPY activity to ingest data based on blobs’ last modified date.
  3. Use data flows where you can quickly use pre-defined templates for handling common ETL patterns such as SCD1 and SCD2 in your pipeline - code free dimensional and fact processing.
  4. You can batch up files instead and leverage a schedule-based trigger. You can use a static storage location as your staging area to upload files. Note you may need to move and clean up files at the end of your pipeline to prevent duplicate loads if you follow this pattern - Synapse pipelines also has this capability built-in through the delete activity or move template.

For more information on Synapse data pipelines and getting started with data integration, visit the following documentation:

 

%3CLINGO-SUB%20id%3D%22lingo-sub-1637468%22%20slang%3D%22en-US%22%3EHow%20to%20operationalize%20your%20data%20analytics%20pipelines%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1637468%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20Synapse%20Analytics%20is%20an%20analytics%20platform%20that%20provides%20productive%20developer%20experiences%20such%20as%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-synapse-analytics%2Freduce-your-time-to-load-with-synapse-studio-and-the-copy%2Fba-p%2F1381550%22%20target%3D%22_blank%22%3ESynapse%20Studio%20bulk%20load%20wizard%3C%2FA%3E%20helping%20data%20engineers%20quickly%20get%20data%20ingested%20and%20datasets%20onboarded%20through%20a%20code-less%20experience.%20The%20platform%20also%20comes%20with%20other%20low-code%20authoring%20experiences%20for%20data%20integration%20where%20it%20is%20now%20even%20easier%20to%20take%20the%20next%20step%20and%20further%20orchestrate%20and%20operationalize%20loads%20in%20just%20a%20few%20clicks.%20You%20can%20use%20built-in%20data%20pipelines%20that%20are%20extremely%20flexible%20where%20you%20can%20customize%20them%20according%20to%20your%20requirements%20all%20within%20the%20Synapse%20studio%20for%20maximum%20productivity.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20how%20to%20guide%20walks%20you%20through%20how%20to%20quickly%20set%20up%20a%20continuous%20data%20pipeline%20that%20automatically%20loads%20data%20as%20the%20files%20arrive%20in%20your%20storage%20account%20of%20your%20SQL%20pool.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E1.%20Generate%20your%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Fcopy-into-transact-sql%3Fview%3Dazure-sqldw-latest%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ECOPY%20statement%3C%2FA%3E%20within%20a%20stored%20procedure%20by%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fazure-synapse-analytics%2Freduce-your-time-to-load-with-synapse-studio-and-the-copy%2Fba-p%2F1381550%22%20target%3D%22_blank%22%3ESynapse%20Studio%20bulk%20load%20wizard%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%20Use%20familiar%20dynamic%20SQL%20syntax%20to%20parameterize%20the%20COPY%20statement%E2%80%99s%20storage%20account%20location.%20You%20can%20also%20generate%20the%20time%20of%20ingestion%20using%20default%20values%20within%20the%20COPY%20statement.%20Sample%20code%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-javascript%22%3E%3CCODE%3ECREATE%20PROC%20%5Bdbo%5D.%5BloadSales%5D%20%40storagelocation%20nvarchar(100)%20AS%0A%0A%20%20%20%20DECLARE%20%40loadtime%20nvarchar(30)%3B%0A%20%20%20%20DECLARE%20%40COPY_statement%20nvarchar(4000)%3B%0A%0A%20%20%20%20SET%20%40loadtime%20%3D%20GetDate()%3B%0A%20%20%20%20SET%20%40COPY_statement%20%3D%20%0A%20%20%20%20%20%20%20%20N'COPY%20INTO%20%5Bdbo%5D.%5BTrip%5D%20%0A%20%20(%0A%20%20%20%5BDateID%5D%201%2C%20%0A%20%20%20%5BMedallionID%5D%202%2C%20%0A%20%20%20%5BHackneyLicenseID%5D%203%2C%20%0A%20%20%20%5BPickupTimeID%5D%204%2C%0A%20%20%20%5BDropoffTimeID%5D%205%2C%0A%20%20%20%5BPickupGeographyID%5D%206%2C%0A%20%20%20%5BDropoffGeographyID%5D%207%2C%0A%20%20%20%5BPickupLatitude%5D%208%2C%0A%20%20%20%5BPickupLongitude%5D%209%2C%0A%20%20%20%5BPickupLatLong%5D%2010%2C%0A%20%20%20%5BDropoffLatitude%5D%2011%2C%0A%20%20%20%5BDropoffLongitude%5D%2012%2C%0A%20%20%20%5BDropoffLatLong%5D%2013%2C%0A%20%20%20%5BPassengerCount%5D%2014%2C%0A%20%20%20%5BTripDurationSeconds%5D%2015%2C%0A%20%20%20%5BTripDistanceMiles%5D%2016%2C%0A%20%20%20%5BPaymentType%5D%2017%2C%0A%20%20%20%5BFareAmount%5D%2018%2C%0A%20%20%20%5BSurchargeAmount%5D%2019%2C%0A%20%20%20%5BTaxAmount%5D%2020%2C%0A%20%20%20%5BTipAmount%5D%2021%2C%0A%20%20%20%5BTollsAmount%5D%2022%2C%0A%20%20%20%5BTotalAmount%5D%2023%2C%0A%20%20%20%5BloadTime%5D%20default%20'''%20%2B%20%40loadtime%20%2B%20'''%2024%0A%20)%0A%20%20FROM%20'''%20%20%2B%20%40storagelocation%20%2B%20'''%20%0A%20%20WITH%20(%0A%20%20%20FIELDTERMINATOR%3D''%7C''%2C%0A%20%20%20ROWTERMINATOR%3D''0x0A''%0A%20%20)%20OPTION%20(LABEL%20%3D%20''loadTime%3A%20'%20%2B%20%40loadtime%20%2B%20''')%3B'%3B%0A%0A%20%20%20%20%20%20%20%20EXEC%20sp_executesql%20%40COPY_statement%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3.%26nbsp%3BCreate%20a%20Synapse%20pipeline%20in%20the%20Synapse%20Studio%20with%20an%20event-based%20trigger%20for%20when%20a%20blob%20is%20created%20in%20your%20storage%20container%20and%20parameterize%20the%20blob%20path%20(folder%20path%20and%20file%20name)%20as%20part%20of%20the%20pipeline.%20Additional%20documentation%20on%20pipeline%20triggers%20is%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Fhow-to-create-event-trigger%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EParameterized%20pipeline%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ParameterizedPipeline.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F216715iD9D7E390DB6B57F0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ParameterizedPipeline.png%22%20alt%3D%22ParameterizedPipeline.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EEvent-based%20trigger%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22EventBasedTrigger.png%22%20style%3D%22width%3A%20598px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F216716iFDDF42CA6C0963E0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22EventBasedTrigger.png%22%20alt%3D%22EventBasedTrigger.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ETrigger%20parameters%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22TriggerParameters.png%22%20style%3D%22width%3A%20513px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F216717i0FEF5FC27382258F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22TriggerParameters.png%22%20alt%3D%22TriggerParameters.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorkevin_ngo_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E4.%20Add%20the%20stored%20procedure%20to%20a%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Ftransform-data-using-stored-procedure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Estored%20procedure%20activity%3C%2FA%3E%20in%20your%20pipeline%20where%20the%20stored%20procedure%20parameter%20is%20the%20blob%20path%20pipeline%20parameter%20and%20publish%20your%20pipeline%20to%20your%20workspace.%20Additional%20documentation%20on%20the%20stored%20procedure%20activity%20is%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Ftransform-data-using-stored-procedure%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SPActivity.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F216718i8AEAD2F93C27830E%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22SPActivity.png%22%20alt%3D%22SPActivity.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20just%204%20steps%2C%20you%20have%20now%20created%20a%20data%20pipeline%20which%20automatically%20and%20continuously%20loads%20files%20as%20they%20land%20in%20your%20staging%20storage%20account%20location%20using%20the%20COPY%20statement%20in%20a%20stored%20procedure.%20You%20did%20not%20need%20to%20provision%20or%20integrate%20any%20event%20notification%20services%20such%20as%20Azure%20Event%20Grid%20or%20Azure%20Queue%20Storage%20to%20support%20this%20auto-ingestion%20workflow%20and%20there%20were%20minimal%20code%20changes.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESynapse%20pipelines%20are%20flexible%20where%20there%20is%20a%20range%20of%20configurations%20and%20customization%20you%20can%20set%20to%20address%20your%20scenarios.%20Here%20are%20some%20other%20considerations%20when%20operationalizing%20your%20data%20pipelines%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EAdd%20additional%20transformation%20logic%20for%20further%20processing%20within%20your%20stored%20procedure%20or%20create%20additional%20stored%20procedures%20(activities)%20in%20your%20pipeline%3C%2FLI%3E%0A%3CLI%3EInstead%20of%20creating%20a%20stored%20procedure%2C%20you%20can%20leverage%20the%20pipeline%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Fconnector-azure-sql-data-warehouse%23use-copy-statement%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECOPY%20activity%3C%2FA%3E%20with%20the%20COPY%20statement.%20This%20will%20make%20your%20data%20pipeline%20authoring%20experience%20code-less.%20You%20can%20configure%20the%20COPY%20activity%20to%20ingest%20data%20based%20on%20blobs%E2%80%99%20last%20modified%20date.%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fconcepts-data-flow-overview%3Ftoc%3D%2Fazure%2Fsynapse-analytics%2Ftoc.json%26amp%3Bbc%3D%2Fazure%2Fsynapse-analytics%2Fbreadcrumb%2Ftoc.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EUse%20data%20flows%3C%2FA%3E%20where%20you%20can%20quickly%20use%20pre-defined%20templates%20for%20handling%20common%20ETL%20patterns%20such%20as%20SCD1%20and%20SCD2%20in%20your%20pipeline%20-%20code%20free%20dimensional%20and%20fact%20processing.%3C%2FLI%3E%0A%3CLI%3EYou%20can%20batch%20up%20files%20instead%20and%20leverage%20a%20schedule-based%20trigger.%20You%20can%20use%20a%20static%20storage%20location%20as%20your%20staging%20area%20to%20upload%20files.%20Note%20you%20may%20need%20to%20move%20and%20clean%20up%20files%20at%20the%20end%20of%20your%20pipeline%20to%20prevent%20duplicate%20loads%20if%20you%20follow%20this%20pattern%20-%20Synapse%20pipelines%20also%20has%20this%20capability%20built-in%20through%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Fdelete-activity%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edelete%20activity%3C%2FA%3E%20or%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdata-factory%2Fsolution-template-move-files%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Emove%20template%3C%2FA%3E.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EFor%20more%20information%20on%20Synapse%20data%20pipelines%20and%20getting%20started%20with%20data%20integration%2C%20visit%20the%20following%20documentation%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fdata-factory%2Fconnector-overview%3Ftoc%3D%2Fazure%2Fsynapse-analytics%2Ftoc.json%26amp%3Bbc%3D%2Fazure%2Fsynapse-analytics%2Fbreadcrumb%2Ftoc.json%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EList%20of%20supported%20data%20stores%20and%20file%20formats%20with%20Synapse%20pipelines%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fsql%2Ft-sql%2Fstatements%2Fcopy-into-transact-sql%3Fview%3Dazure-sqldw-latest%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECOPY%20statement%20used%20to%20ingest%20data%20into%20a%20SQL%20database%3C%2FA%3E%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fsynapse-analytics%2Fquickstart-load-studio-sql-pool%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EGetting%20started%20with%20the%20COPY%20statement%20and%20the%20Synapse%20Studio%3C%2FA%3E%3C%2FLI%3E%0A%3C%2FUL%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1637468%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20Synapse%20Analytics%20comes%20with%20built-in%20data%20integration%20capabilities%20enabling%20you%20to%20orchestrate%20continuous%20data%20pipelines%20in%20a%20low-code%20experience.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1637468%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESynapse%20Pipelines%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESynapse%20SQL%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Sep 08 2020 06:40 AM
Updated by: