Skip to content

Commit

Permalink
rename to SQLCacheBase
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers committed Feb 20, 2024
1 parent 5329d1b commit 45fbf04
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions airbyte/caches/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Base module for all caches."""
from __future__ import annotations

from airbyte.caches.base import SQLCacheConfigBase
from airbyte.caches.base import SQLCacheBase
from airbyte.caches.duckdb import DuckDBCache
from airbyte.caches.postgres import PostgresCache, PostgresCacheConfig
from airbyte.caches.snowflake import SnowflakeCacheConfig, SnowflakeSQLCache
Expand All @@ -12,7 +12,7 @@
"DuckDBCache",
"PostgresCache",
"PostgresCacheConfig",
"SQLCacheConfigBase",
"SQLCacheBase",
"SnowflakeCacheConfig",
"SnowflakeSQLCache",
]
10 changes: 5 additions & 5 deletions airbyte/caches/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class SQLRuntimeError(Exception):
"""Raised when an SQL operation fails."""


class SQLCacheConfigBase(CacheConfigBase):
class SQLCacheBase(CacheConfigBase):
"""Same as a regular config except it exposes the 'get_sql_alchemy_url()' method."""

schema_name: str = "airbyte_raw"
Expand All @@ -92,7 +92,7 @@ def get_database_name(self) -> str:
...


class GenericSQLCacheConfig(SQLCacheConfigBase):
class GenericSQLCacheConfig(SQLCacheBase):
"""Allows configuring 'sql_alchemy_url' directly."""

sql_alchemy_url: str
Expand All @@ -110,7 +110,7 @@ class SQLCacheInstanceBase(RecordProcessor):
"""

type_converter_class: type[SQLTypeConverter] = SQLTypeConverter
config_class: type[SQLCacheConfigBase]
config_class: type[SQLCacheBase]
file_writer_class: type[FileWriterBase]

supports_merge_insert = False
Expand All @@ -121,10 +121,10 @@ class SQLCacheInstanceBase(RecordProcessor):
@final # We don't want subclasses to have to override the constructor.
def __init__(
self,
config: SQLCacheConfigBase | None = None,
config: SQLCacheBase | None = None,
file_writer: FileWriterBase | None = None,
) -> None:
self.config: SQLCacheConfigBase
self.config: SQLCacheBase
self._engine: Engine | None = None
self._connection_to_reuse: Connection | None = None
super().__init__(config)
Expand Down
4 changes: 2 additions & 2 deletions airbyte/caches/duckdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from overrides import overrides

from airbyte._file_writers import ParquetWriter, ParquetWriterConfig
from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheConfigBase
from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheBase
from airbyte.telemetry import CacheTelemetryInfo


Expand All @@ -24,7 +24,7 @@
)


class DuckDBCache(SQLCacheConfigBase, ParquetWriterConfig):
class DuckDBCache(SQLCacheBase, ParquetWriterConfig):
"""A DuckDB cache.
Also inherits config from the ParquetWriter, which is responsible for writing files to disk.
Expand Down
4 changes: 2 additions & 2 deletions airbyte/caches/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from overrides import overrides

from airbyte._file_writers import ParquetWriter, ParquetWriterConfig
from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheConfigBase
from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheBase
from airbyte.telemetry import CacheTelemetryInfo


class PostgresCacheConfig(SQLCacheConfigBase, ParquetWriterConfig):
class PostgresCacheConfig(SQLCacheBase, ParquetWriterConfig):
"""Configuration for the Postgres cache.
Also inherits config from the ParquetWriter, which is responsible for writing files to disk.
Expand Down
4 changes: 2 additions & 2 deletions airbyte/caches/snowflake.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from airbyte.caches.base import (
RecordDedupeMode,
SQLCacheInstanceBase,
SQLCacheConfigBase,
SQLCacheBase,
)
from airbyte.telemetry import CacheTelemetryInfo
from airbyte.types import SQLTypeConverter
Expand All @@ -27,7 +27,7 @@
from sqlalchemy.engine import Connection


class SnowflakeCacheConfig(SQLCacheConfigBase, ParquetWriterConfig):
class SnowflakeCacheConfig(SQLCacheBase, ParquetWriterConfig):
"""Configuration for the Snowflake cache.
Also inherits config from the ParquetWriter, which is responsible for writing files to disk.
Expand Down
6 changes: 3 additions & 3 deletions tests/unit_tests/test_caches.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from airbyte._file_writers import ParquetWriterConfig
from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheConfigBase
from airbyte.caches.base import SQLCacheInstanceBase, SQLCacheBase
from airbyte.caches.duckdb import DuckDBCacheBase, DuckDBCache


Expand All @@ -27,7 +27,7 @@ def test_get_sql_alchemy_url_with_default_schema_name():
assert config.get_sql_alchemy_url() == 'duckdb:///test_path'

def test_duck_db_cache_config_inheritance():
assert issubclass(DuckDBCache, SQLCacheConfigBase)
assert issubclass(DuckDBCache, SQLCacheBase)
assert issubclass(DuckDBCache, ParquetWriterConfig)

def test_duck_db_cache_config_get_sql_alchemy_url():
Expand All @@ -54,7 +54,7 @@ def test_duck_db_cache_config_get_database_name_with_default_schema_name():
assert config.get_database_name() == 'test_db'

def test_duck_db_cache_config_inheritance_from_sql_cache_config_base():
assert issubclass(DuckDBCache, SQLCacheConfigBase)
assert issubclass(DuckDBCache, SQLCacheBase)

def test_duck_db_cache_config_inheritance_from_parquet_writer_config():
assert issubclass(DuckDBCache, ParquetWriterConfig)

0 comments on commit 45fbf04

Please sign in to comment.