from dbt.adapters.base import Column
from dataclasses import dataclass
from dbt.adapters.base.relation import BaseRelation
from dbt.exceptions import RuntimeException


@dataclass(frozen=True, eq=False, repr=False)
class PostgresRelation(BaseRelation):
    def __post_init__(self):
        # Check for length of Postgres table/view names.
        # Check self.type to exclude test relation identifiers
        if (
            self.identifier is not None
            and self.type is not None
            and len(self.identifier) > self.relation_max_name_length()
        ):
            raise RuntimeException(
               f"Postgres relation name '{self.identifier}' is longer than "
               f"{self.relation_max_name_length()} characters"
            )

    def relation_max_name_length(self):
        return 63


class PostgresColumn(Column):
    @property
    def data_type(self):
        # on postgres, do not convert 'text' to 'varchar()'
        if self.dtype.lower() == 'text':
            return self.dtype
        return super().data_type

@@ -407,29 +407,16 @@
     if (
-%0A            
 self.ide
@@ -430,36 +430,24 @@
  is not None
-%0A           
  and self.ty
@@ -460,16 +460,20 @@
 not None
+ and
 %0A       
@@ -477,19 +477,19 @@
         
-and
+   
  len(sel
@@ -535,25 +535,16 @@
 length()
-%0A        
 ):%0A     
@@ -593,20 +593,12 @@
     
+ 
 f%22
-Postgres r
+R
 elat
@@ -629,26 +629,12 @@
 er%7D'
- is longer than
  %22%0A
+ 
     
@@ -646,16 +646,31 @@
       f%22
+is longer than 
 %7Bself.re

Tweak error message, reformat for flake8