Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
simonB2020
Creator
Creator

Trimming a field

I am using a File source.
Column in question is defined in Replicate a WSTRING(255)

Target is Redshift
Also defined in Replicate as WSTRING(255), and in Redshift itself as varchar(765)

Yet when the load executes, Redshift is throwing an error.
'String length exceeds DDL length'

Now, I can see in the source file, that there are extra spaces added onto the end of a value for this column , which explains where the extra length is.
However ....

If I am telling Replicate that the source is 255, shouldn't it either  throw an error when it reads the source file, or truncate the value before passing it to Redshift ?
Else what was the point of telling Replicate that the source fields is any length at all ?

I am just surprised as to why the extra length is getting to Redshift at all ?

Thanks




Labels (1)
1 Solution

Accepted Solutions
Bill_Steinagle
Support
Support

Hi,

Thank you for your post to the Replicate Forums. Along with John's update here is the mapping of the WSTRING to the Redshift Data Type and the size.  This may explain why there is extra bytes on the Redshift Target.

WSTRING

If length is => 1 and =< 65535, then:

NVARCHAR (Length in Bytes)

If length is => 65536 and =< 2147483647, then:

NVARCHAR (65535)

 

Thanks!

Bill

View solution in original post

2 Replies
john_wang
Support
Support

Hello @simonB2020 ,

Not very sure why it's defined as WSTRING(255) - it means NCHAR(255) in RDBMS. Anyway, you can use length() function to figure out the real length of the string. If it's padded by spaces, you may use trim() function to remove the unnecessary spaces, like:

john_wang_0-1664291241440.png

This can be set in column level (table settings), or in Global Transformation Rules of task "Global Rules...".

Hope this helps.

Regards,

John.

Help users find answers! Do not forget to mark a solution that worked for you! If already marked, give it a thumbs up!
Bill_Steinagle
Support
Support

Hi,

Thank you for your post to the Replicate Forums. Along with John's update here is the mapping of the WSTRING to the Redshift Data Type and the size.  This may explain why there is extra bytes on the Redshift Target.

WSTRING

If length is => 1 and =< 65535, then:

NVARCHAR (Length in Bytes)

If length is => 65536 and =< 2147483647, then:

NVARCHAR (65535)

 

Thanks!

Bill