Skip to content

Commit

Permalink
[CT-1940] Stand-alone Python module for PostgresColumn (#6773)
Browse files Browse the repository at this point in the history
  • Loading branch information
nssalian authored Jan 28, 2023
1 parent c653330 commit a8abc49
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Features-20230127-162812.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Features
body: Stand-alone Python module for PostgresColumn
time: 2023-01-27T16:28:12.212427-08:00
custom:
Author: nssalian
Issue: "6772"
2 changes: 1 addition & 1 deletion plugins/postgres/dbt/adapters/postgres/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# these are mostly just exports, #noqa them so flake8 will be happy
from dbt.adapters.postgres.connections import PostgresConnectionManager # noqa
from dbt.adapters.postgres.connections import PostgresCredentials
from dbt.adapters.postgres.relation import PostgresColumn # noqa
from dbt.adapters.postgres.column import PostgresColumn # noqa
from dbt.adapters.postgres.relation import PostgresRelation # noqa: F401
from dbt.adapters.postgres.impl import PostgresAdapter

Expand Down
12 changes: 12 additions & 0 deletions plugins/postgres/dbt/adapters/postgres/column.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from dbt.adapters.base import Column


class PostgresColumn(Column):
@property
def data_type(self):
# on postgres, do not convert 'text' or 'varchar' to 'varchar()'
if self.dtype.lower() == "text" or (
self.dtype.lower() == "character varying" and self.char_size is None
):
return self.dtype
return super().data_type
2 changes: 1 addition & 1 deletion plugins/postgres/dbt/adapters/postgres/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dbt.adapters.base.impl import AdapterConfig
from dbt.adapters.sql import SQLAdapter
from dbt.adapters.postgres import PostgresConnectionManager
from dbt.adapters.postgres import PostgresColumn
from dbt.adapters.postgres.column import PostgresColumn
from dbt.adapters.postgres import PostgresRelation
from dbt.dataclass_schema import dbtClassMixin, ValidationError
from dbt.exceptions import (
Expand Down
12 changes: 0 additions & 12 deletions plugins/postgres/dbt/adapters/postgres/relation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from dbt.adapters.base import Column
from dataclasses import dataclass
from dbt.adapters.base.relation import BaseRelation
from dbt.exceptions import DbtRuntimeError
Expand All @@ -21,14 +20,3 @@ def __post_init__(self):

def relation_max_name_length(self):
return 63


class PostgresColumn(Column):
@property
def data_type(self):
# on postgres, do not convert 'text' or 'varchar' to 'varchar()'
if self.dtype.lower() == "text" or (
self.dtype.lower() == "character varying" and self.char_size is None
):
return self.dtype
return super().data_type

0 comments on commit a8abc49

Please sign in to comment.