iceberg icon indicating copy to clipboard operation
iceberg copied to clipboard

API - Do not validate input length to String Truncate Transform on every call

Open kbendick opened this issue 3 years ago • 3 comments

Working on #5431, I noticed that we are validating the input length to the String truncate transform in every call for every value.

However, the input length has already been validated when the transform is instantiated.

Given that this code runs in the per-record path of each string truncate transformation, I've separated the validation logic from the truncation logic to allow skipping length validation for the case when it's already been validated / is constant after validation.

kbendick avatar Aug 10 '22 22:08 kbendick

Did you mean to use the new method somewhere?

Also, I don't think that we want to use "unsafe" in the name. This is not unsafe, it is a different method contract.

rdblue avatar Aug 11 '22 16:08 rdblue

The validation seems redundant but I'd also play around with the method name.

aokolnychyi avatar Aug 11 '22 16:08 aokolnychyi

The validation seems redundant but I'd also play around with the method name.

+1 to the name thing. I changed it to truncateStringWithoutLengthValidation, which is better but I don't really love that either.

I'm open to suggestions if anybody has any. I would potentially change the name of the original function to truncateStringWithLengthValidation and make this the new function definition for the shorter name, but that involves updating more calls.

kbendick avatar Aug 11 '22 21:08 kbendick