Skip to content

Commit

Permalink
Rename Snowflake Table to table
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-jvasquezrojas committed Oct 24, 2024
1 parent 9a2d5ae commit 8ee557c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 24 deletions.
9 changes: 2 additions & 7 deletions src/snowflake/sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@
VARBINARY,
VARIANT,
)
from .sql.custom_schema import ( # noqa
DynamicTable,
HybridTable,
IcebergTable,
SnowflakeTable,
)
from .sql.custom_schema import DynamicTable, HybridTable, IcebergTable, Table # noqa
from .sql.custom_schema.options import ( # noqa
AsQueryOption,
ClusterByOption,
Expand Down Expand Up @@ -135,7 +130,7 @@
"CreateFileFormat",
)

_custom_tables = ("HybridTable", "DynamicTable", "IcebergTable", "SnowflakeTable")
_custom_tables = ("HybridTable", "DynamicTable", "IcebergTable", "Table")

_custom_table_options = (
"AsQueryOption",
Expand Down
4 changes: 2 additions & 2 deletions src/snowflake/sqlalchemy/sql/custom_schema/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
from .dynamic_table import DynamicTable
from .hybrid_table import HybridTable
from .iceberg_table import IcebergTable
from .snowflake_table import SnowflakeTable
from .table import Table

__all__ = ["DynamicTable", "HybridTable", "IcebergTable", "SnowflakeTable"]
__all__ = ["DynamicTable", "HybridTable", "IcebergTable", "Table"]
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .table_from_query import TableFromQueryBase


class SnowflakeTable(TableFromQueryBase):
class Table(TableFromQueryBase):
"""
A class representing a table in Snowflake with configurable options and settings.
Expand Down
20 changes: 10 additions & 10 deletions tests/custom_tables/test_compile_snowflake_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from sqlalchemy.orm import declarative_base
from sqlalchemy.sql.ddl import CreateTable

from snowflake.sqlalchemy import SnowflakeTable
from snowflake.sqlalchemy import Table
from snowflake.sqlalchemy.sql.custom_schema.options import (
AsQueryOption,
ClusterByOption,
Expand All @@ -25,7 +25,7 @@
def test_compile_snowflake_table(sql_compiler, snapshot):
metadata = MetaData()
table_name = "test_table_1"
test_geometry = SnowflakeTable(
test_geometry = Table(
table_name,
metadata,
Column("id", Integer),
Expand All @@ -44,7 +44,7 @@ def test_compile_snowflake_table(sql_compiler, snapshot):
def test_compile_snowflake_table_with_explicit_options(sql_compiler, snapshot):
metadata = MetaData()
table_name = "test_table_2"
test_geometry = SnowflakeTable(
test_geometry = Table(
table_name,
metadata,
Column("id", Integer),
Expand All @@ -64,7 +64,7 @@ def test_compile_snowflake_table_with_wrong_option_types(snapshot):
metadata = MetaData()
table_name = "test_snowflake_table"
with pytest.raises(ArgumentError) as argument_error:
SnowflakeTable(
Table(
table_name,
metadata,
Column("id", Integer),
Expand All @@ -79,7 +79,7 @@ def test_compile_snowflake_table_with_wrong_option_types(snapshot):
def test_compile_snowflake_table_with_primary_key(sql_compiler, snapshot):
metadata = MetaData()
table_name = "test_table_2"
test_geometry = SnowflakeTable(
test_geometry = Table(
table_name,
metadata,
Column("id", Integer, primary_key=True),
Expand All @@ -98,7 +98,7 @@ def test_compile_snowflake_table_with_primary_key(sql_compiler, snapshot):
def test_compile_snowflake_table_with_foreign_key(sql_compiler, snapshot):
metadata = MetaData()

SnowflakeTable(
Table(
"table",
metadata,
Column("id", Integer, primary_key=True),
Expand All @@ -109,7 +109,7 @@ def test_compile_snowflake_table_with_foreign_key(sql_compiler, snapshot):
)

table_name = "test_table_2"
test_geometry = SnowflakeTable(
test_geometry = Table(
table_name,
metadata,
Column("id", Integer, primary_key=True),
Expand All @@ -134,7 +134,7 @@ class TestSnowflakeTableOrm(Base):

@classmethod
def __table_cls__(cls, name, metadata, *arg, **kw):
return SnowflakeTable(name, metadata, *arg, **kw)
return Table(name, metadata, *arg, **kw)

__table_args__ = {
"schema": "SCHEMA_DB",
Expand All @@ -158,7 +158,7 @@ def __repr__(self):
def test_compile_snowflake_table_with_selectable(sql_compiler, snapshot):
Base = declarative_base()

test_table_1 = SnowflakeTable(
test_table_1 = Table(
"test_table_1",
Base.metadata,
Column("id", Integer, primary_key=True),
Expand All @@ -167,7 +167,7 @@ def test_compile_snowflake_table_with_selectable(sql_compiler, snapshot):
cluster_by=ClusterByOption("id", text("id > 100")),
)

test_table_2 = SnowflakeTable(
test_table_2 = Table(
"snowflake_test_table_1",
Base.metadata,
as_query=select(test_table_1).where(test_table_1.c.id == 23),
Expand Down
6 changes: 3 additions & 3 deletions tests/custom_tables/test_create_snowflake_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlalchemy import Column, Integer, MetaData, String, select, text
from sqlalchemy.orm import Session, declarative_base

from snowflake.sqlalchemy import SnowflakeTable
from snowflake.sqlalchemy import Table


def test_create_snowflake_table_with_cluster_by(
Expand All @@ -13,7 +13,7 @@ def test_create_snowflake_table_with_cluster_by(
metadata = MetaData()
table_name = "test_create_snowflake_table"

test_table_1 = SnowflakeTable(
test_table_1 = Table(
table_name,
metadata,
Column("id", Integer, primary_key=True),
Expand Down Expand Up @@ -46,7 +46,7 @@ class TestHybridTableOrm(Base):

@classmethod
def __table_cls__(cls, name, metadata, *arg, **kw):
return SnowflakeTable(name, metadata, *arg, **kw)
return Table(name, metadata, *arg, **kw)

id = Column(Integer, primary_key=True)
name = Column(String)
Expand Down
2 changes: 1 addition & 1 deletion tests/custom_tables/test_reflect_snowflake_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlalchemy import MetaData, Table
from sqlalchemy.sql.ddl import CreateTable

from src.snowflake.sqlalchemy import SnowflakeTable
from src.snowflake.sqlalchemy import Table as SnowflakeTable


def test_simple_reflection_of_table_as_sqlalchemy_table(
Expand Down

0 comments on commit 8ee557c

Please sign in to comment.