charles
# if everything fits except for the parent, just truncate the parent
elif (len(norm_child) + len(json_path_hash) + len(norm_suffix)) < (max_length - min_parent_length):
max_parent_length = max_length - len(norm_child) - len(json_path_hash) - len(norm_suffix)
return f"{norm_parent[:max_parent_length]}_{json_path_hash}_{norm_child}{norm_suffix}"
# otherwise first truncate parent to the minimum length and middle truncate the child
else:
norm_child_max_length = max_length - min_parent_length - len(json_path_hash) - len(norm_suffix)
trunc_norm_child = name_transformer.truncate_identifier_name(norm_child, norm_child_max_length)
return f"{norm_parent[:min_parent_length]}_{json_path_hash}_{trunc_norm_child}{norm_suffix}"
https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/bases/base-n[…]rmalization/normalization/transform_catalog/stream_processor.py
Could you help me understand why we would ever want to prefer this elif case over the else case? I think anything that the elif case hands can be handled by the else case and it has the added benefit of including at least some part of the parent.user
05/25/2021, 8:36 AMelif
part tries to include as many characters as possible from the parent, and thus truncates just enough in order to stay under the destination character limits without touching the child names.
2. the else
case always truncates MINIMUM_PARENT_LENGTH
which is 10 characters from the parent (or less if it doesnt have 10 characters) but then truncates the child name toouser
05/25/2021, 4:16 PMuser
05/25/2021, 4:18 PM# if everything fits except for the parent, just truncate the parent
to:
# if everything fits except for the parent, just truncate the parent (still guarantees parent is of length MINIMUM_PARENT_LENGTH)
user
05/25/2021, 4:20 PMuser
05/25/2021, 4:21 PMuser
05/25/2021, 4:21 PMuser
05/25/2021, 4:22 PMuser
05/25/2021, 4:29 PMuser
05/25/2021, 4:29 PM