diff --git a/.changes/unreleased/Features-20240323-160251.yaml b/.changes/unreleased/Features-20240323-160251.yaml new file mode 100644 index 00000000..c4b59464 --- /dev/null +++ b/.changes/unreleased/Features-20240323-160251.yaml @@ -0,0 +1,6 @@ +kind: Features +body: Debug log when `type_code` fails to convert to a `data_type` +time: 2024-03-23T16:02:51.306658-06:00 +custom: + Author: dbeatty10 + Issue: "8912" diff --git a/dbt/adapters/events/adapter_types.proto b/dbt/adapters/events/adapter_types.proto index aa0b507c..69d64325 100644 --- a/dbt/adapters/events/adapter_types.proto +++ b/dbt/adapters/events/adapter_types.proto @@ -515,3 +515,13 @@ message ConstraintNotSupportedMsg { AdapterCommonEventInfo info = 1; ConstraintNotSupported data = 2; } + +// E050 +message TypeCodeNotFound { + int32 type_code = 1; +} + +message TypeCodeNotFoundMsg { + AdapterCommonEventInfo info = 1; + TypeCodeNotFound data = 2; +} diff --git a/dbt/adapters/events/types.py b/dbt/adapters/events/types.py index ddd435b9..6886bbf3 100644 --- a/dbt/adapters/events/types.py +++ b/dbt/adapters/events/types.py @@ -421,3 +421,12 @@ def message(self) -> str: "be ignored. Set 'warn_unsupported: false' on this constraint to ignore this warning." ) return line_wrap_message(warning_tag(msg)) + + +class TypeCodeNotFound(DebugLevel): + def code(self) -> str: + return "E050" + + def message(self) -> str: + msg = f"The `type_code` {self.type_code} was not recognized, which may affect error messages for enforced contracts that fail as well as `Column.data_type` values returned by `get_column_schema_from_query`" + return msg diff --git a/tests/unit/test_events.py b/tests/unit/test_events.py index bda7c6f4..22e71896 100644 --- a/tests/unit/test_events.py +++ b/tests/unit/test_events.py @@ -153,6 +153,7 @@ def test_event_codes(self): types.FinishedRunningStats(stat_line="", execution="", execution_time=0), types.ConstraintNotEnforced(constraint="", adapter=""), types.ConstraintNotSupported(constraint="", adapter=""), + types.TypeCodeNotFound(type_code=0), ]