Native Data Type (Term Mapping)
Applies to
Platform: Microsoft SQL Server
Architecture: Stage
Native Data Type (NativeDataType) casts the increment threshold of an incremental Stage load to a data type of the source system. Use it when the source compares the increment term in its own type, for example an Oracle TIMESTAMP.
The property exists only in the Microsoft SQL Server Stage OpenQuery generator.
Where to set it
Set the property when you edit the term mapping of BG_IncrementalFilter in a Stage. It is a text field and empty by default. It has an effect only on this mapping and only with an incremental load.
Values and default
- Empty (default): the native query compares the increment term with the threshold as text.
- A data type of the source system, for example
DATETIMEOFFSETorTIMESTAMP: the native query compares the increment term withCAST('<threshold>' AS <native data type>).
Write the type in the syntax of the source system, because the linked server passes it unchanged. The threshold is converted to text first: dates as yyyymmdd, timestamps as yyyy-mm-dd hh:mi:ss with fractions.
Effect on generated output
Native Data Type changes only the condition on the increment term in the native query of the Stage loader. That query is the statement that OPENQUERY sends to the source system. With Increment Management Type User, the cast applies to the lower and to the upper threshold of the range. The Stage table and its increment table stay the same.
Example
A Stage load_with_native_datatype maps BG_IncrementalFilter to TRANSACTION_TIME, with Native Data Type DATETIMEOFFSET. The native query in its loader ends with:
WHERE ' + CASE WHEN @IncrementPrevious IS NOT NULL
THEN N'[TRANSACTION_TIME] > CAST(''''' + CONVERT(NVARCHAR(MAX),
@IncrementPrevious, 121) + ''''' AS DATETIMEOFFSET)'
ELSE N'1 = 1' END + N'
On the first load, @IncrementPrevious is NULL, and the query reads all rows.
Related articles
- Reference: BG_IncrementalFilter, Native Expression (Term), Increment Management Type (Model Object)
- See also: Configure an incremental load, Model a Stage OpenQuery Solution