From ad84aa0e62f8f2788cd3b1fb377d0a2dd41c5e5d Mon Sep 17 00:00:00 2001 From: Joseph Distler Date: Wed, 18 Sep 2024 14:54:48 -0500 Subject: [PATCH] Better handle nested Array types --- dbt/adapters/base/column.py | 50 +++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/dbt/adapters/base/column.py b/dbt/adapters/base/column.py index 195684a4..3f6eec3c 100644 --- a/dbt/adapters/base/column.py +++ b/dbt/adapters/base/column.py @@ -135,29 +135,31 @@ def from_description(cls, name: str, raw_data_type: str) -> "Column": if size_info is not None: # strip out the parentheses size_info = size_info[1:-1] - parts = size_info.split(",") - if len(parts) == 1: - try: - char_size = int(parts[0]) - except ValueError: - raise DbtRuntimeError( - f'Could not interpret data_type "{raw_data_type}": ' - f'could not convert "{parts[0]}" to an integer' - ) - elif len(parts) == 2: - try: - numeric_precision = int(parts[0]) - except ValueError: - raise DbtRuntimeError( - f'Could not interpret data_type "{raw_data_type}": ' - f'could not convert "{parts[0]}" to an integer' - ) - try: - numeric_scale = int(parts[1]) - except ValueError: - raise DbtRuntimeError( - f'Could not interpret data_type "{raw_data_type}": ' - f'could not convert "{parts[1]}" to an integer' - ) + # If it contains a nested type structure, ignore further size processing + if not re.search(r"[A-Z]+\(", size_info): + parts = size_info.split(",") + if len(parts) == 1: + try: + char_size = int(parts[0]) + except ValueError: + raise DbtRuntimeError( + f'Could not interpret data_type "{raw_data_type}": ' + f'could not convert "{parts[0]}" to an integer' + ) + elif len(parts) == 2: + try: + numeric_precision = int(parts[0]) + except ValueError: + raise DbtRuntimeError( + f'Could not interpret data_type "{raw_data_type}": ' + f'could not convert "{parts[0]}" to an integer' + ) + try: + numeric_scale = int(parts[1]) + except ValueError: + raise DbtRuntimeError( + f'Could not interpret data_type "{raw_data_type}": ' + f'could not convert "{parts[1]}" to an integer' + ) return cls(name, data_type, char_size, numeric_precision, numeric_scale)