Skip to content

Commit

Permalink
Remove unnesary code to support dynamic tables in sqlalchemy 1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jvasquezrojas committed Sep 12, 2024
1 parent a7a3400 commit f753913
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
#
import typing
from abc import ABC
from typing import Any

from sqlalchemy.exc import ArgumentError
Expand All @@ -13,7 +12,7 @@
from .options.table_option import TableOption


class CustomTable(Table, ABC):
class CustomTableBase(Table):
__table_prefix__ = ""
_support_primary_and_foreign_keys = True

Expand Down
5 changes: 2 additions & 3 deletions src/snowflake/sqlalchemy/sql/custom_schema/dynamic_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
import typing
from typing import Any

from sqlalchemy import exc, inspection
from sqlalchemy.sql.schema import MetaData, SchemaItem

from snowflake.sqlalchemy.custom_commands import NoneType

from .options.target_lag import TargetLag
from .options.warehouse import Warehouse
from .table_from_query import TableFromQuery
from .table_from_query import TableFromQueryBase


class DynamicTable(TableFromQuery, inspection.Inspectable["DynamicTable"]):
class DynamicTable(TableFromQueryBase):
"""
A class representing a dynamic table with configurable options and settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
from typing import Union

from sqlalchemy import Selectable
from sqlalchemy.sql import Selectable

from .table_option import TableOption
from .table_option_base import Priority
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
#
from abc import ABC
from typing import Any

from sqlalchemy import exc
Expand All @@ -13,7 +12,7 @@
from .table_option_base import TableOptionBase


class TableOption(TableOptionBase, SchemaItem, ABC):
class TableOption(TableOptionBase, SchemaItem):
def _set_parent(self, parent: SchemaEventTarget, **kw: Any) -> None:
if self.__option_name__ == "default":
raise exc.SQLAlchemyError(f"{self.__class__.__name__} does not has a name")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
#
from abc import ABC, abstractmethod
from enum import Enum


Expand All @@ -15,20 +14,17 @@ class Priority(Enum):
HIGHEST = 8


class TableOptionBase(ABC):
class TableOptionBase:
__option_name__ = "default"
__visit_name__ = __option_name__
__priority__ = Priority.MEDIUM

@staticmethod
@abstractmethod
def template() -> str:
pass
raise NotImplementedError

@abstractmethod
def get_expression(self):
pass
raise NotImplementedError

@abstractmethod
def render_option(self, compiler) -> str:
pass
raise NotImplementedError
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
# from enum import Enum
from enum import Enum
from typing import Optional

from .table_option import TableOption
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
# Copyright (c) 2012-2023 Snowflake Computing Inc. All rights reserved.
#
import typing
from abc import ABC
from typing import Any, Optional

import sqlalchemy
from sqlalchemy import Selectable
from sqlalchemy.sql import Selectable
from sqlalchemy.sql.schema import Column, MetaData, SchemaItem
from sqlalchemy.util import NoneType

from .custom_table import CustomTable
from .custom_table_base import CustomTableBase
from .options.as_query import AsQuery


class TableFromQuery(CustomTable, ABC):
class TableFromQueryBase(CustomTableBase):

@property
def as_query(self):
Expand Down

0 comments on commit f753913

Please sign in to comment.