TERA Mode For Strings Comparison
This section defines the translation specification for string in Tera mode.
Description
Teradata modes description
The Teradata database has different modes for running queries: ANSI Mode (rules based on the ANSI SQL: 2011 specifications) and TERA mode (rules defined by Teradata). Please review the following Teradata documentation for more information.
Teradata mode for string
For strings, the Teradata mode works differently. As it is explained in the following table based on the Teradata documentation:
Feature | ANSI mode | Teradata mode |
---|---|---|
Default attribute for character comparisons | CASESPECIFIC | NOT CASESPECIFIC |
Default TRIM behavior | TRIM(BOTH FROM) | TRIM(BOTH FROM) |
Translation specification summary
For this feature, the intended translation is focused only on Tera Mode. Notice that ANSI mode is added here just for comparison.
Mode | Column constraint values | Teradata behavior | SnowConvert expected behavior |
---|---|---|---|
ANSI Mode | CASESPECIFIC | CASESPECIFIC | No constraint added. |
NOT CASESPECIFIC | CASESPECIFIC | Add | |
Teradata Mode | CASESPECIFIC | CASESPECIFIC | In most cases, do not add COLLATE, and convert its usages of string comparison to |
NOT CASESPECIFIC | NOT CASESPECIFIC | In most cases, do not add COLLATE, and convert its usages of string comparison to |
Sample Source Patterns
Setup data
Evaluation operation
Sample 1: Column constraint is NOT CASESPECIFIC and database mode is TERA Mode
This example demonstrates the usage of a column set up as NOT CASE SPECIFIC
as it is a first_name
column. Even when asking for the string 'GEorge',
the query execution will retrieve results in Teradata because the case specification is not considered.
To emulate this scenario in Snowflake, there are implemented two functions: RTRIM(UPPER(string_evaluation))
, UPPER
is required in this scenario because the string does not review the case specification.
Teradata
Snowflake
Sample 2: Column constraint is CASESPECIFIC and database mode is TERA Mode
For this example, the column constraint is CASESPECIFIC
, for which the example does not retrieve rows in Teradata because 'Snow
' is not equal to 'SNOW
'.
In Snowflake, the resulting migration points only to the use of the RTRIM
function since the case specification is important.
Teradata
Snowflake
LIKE operation
This operation works differently from another one. Blank spaces must be the same quantity to retrieve information.
Sample 1: Column constraint is NOT CASESPECIFIC and database mode is TERA Mode
This example is expected to display one row because the case specification is not relevant.
In Snowflake, the migration uses the ILIKE operation. This performs a case-insensitive comparison.