Редагувати

Поділитися через


Cast transformation in mapping data flow

APPLIES TO: Azure Data Factory Azure Synapse Analytics

Tip

Try out Data Factory in Microsoft Fabric, an all-in-one analytics solution for enterprises. Microsoft Fabric covers everything from data movement to data science, real-time analytics, business intelligence, and reporting. Learn how to start a new trial for free!

Data flows are available both in Azure Data Factory and Azure Synapse Pipelines. This article applies to mapping data flows. If you are new to transformations, please refer to the introductory article Transform data using a mapping data flow.

Use the cast transformation to easily modify the data types of individual columns in a data flow. The cast transformation also enables an easy way to check for casting errors.

Configuration

Cast settings

To modify the data type for columns in your data flow, add columns to "Cast settings" using the plus (+) sign.

Column name: Pick the column you wish to cast from your list of metadata columns.

Type: Choose the data type to cast your column to. If you pick "complex", you can then select "Define complex type" and define structures, arrays, and maps inside the expression builder.

Note

Support for complex data type casting from the Cast transformation is currently unavailable. Use a Derived Column transformation instead. In the Derived Column, type conversion errors always result in NULL and require explicity error handling using an Assert. The Cast transformation can automatically trap conversion errors using the "Assert type check" property.

Format: Some data types, like decimal and dates, will allow for additional formatting options.

Assert type check: The cast transformation allows for type checking. If the casting fails, the row will be marked as an assertion error that you can trap later in the stream.

Data flow script

Syntax

<incomingStream>
    cast(output(
		AddressID as integer,
		AddressLine1 as string,
		AddressLine2 as string,
		City as string
	),
	errors: true) ~> <castTransformationName<>

Modify existing columns and new columns using the derived column transformation.