SSC-EWI-RS0006

The behavior of the SUBSTRING function may differ when applied to binary data.

Severity

Medium

Description

The behavior of the SUBSTRING function may differ when applied to binary data. Since Redshift and Snowflake handle binary data differently, the results may vary between the two platforms.

Code Example

Input Code:

IN -> Redshift_01.sql
SELECT SUBSTRING('12345'::varbyte, 2, 4) AS substring_binary;
SELECT SUBSTRING('abc'::varbyte, 2, 4) AS substring_binary;

Output Code:

OUT -> Redshift_01.sql
SELECT SUBSTRING('12345':: BINARY, 2, 4) !!!RESOLVE EWI!!! /*** SSC-EWI-RS0006 - THE BEHAVIOR OF THE SUBSTRING FUNCTION MAY DIFFER WHEN APPLIED TO BINARY DATA. ***/!!! AS substring_binary;
SELECT SUBSTRING('abc':: BINARY, 2, 4) !!!RESOLVE EWI!!! /*** SSC-EWI-RS0006 - THE BEHAVIOR OF THE SUBSTRING FUNCTION MAY DIFFER WHEN APPLIED TO BINARY DATA. ***/!!! AS substring_binary;

Recommendations

Last updated