Skip to content

feat: add SQLiteLookup for lookup joins with SQLite database #900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions quixstreams/dataframe/joins/lookups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
QuixConfigurationService,
QuixConfigurationServiceField,
)
from .sqlite import SQLiteLookup, SQLiteLookupField, SQLiteLookupQueryField

__all__ = [
"BaseField",
"BaseLookup",
"QuixConfigurationService",
"QuixConfigurationServiceField",
"SQLiteLookup",
"SQLiteLookupField",
"SQLiteLookupQueryField",
]
20 changes: 18 additions & 2 deletions quixstreams/dataframe/joins/lookups/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import abc
import dataclasses
from typing import Any, Generic, TypeVar
from typing import Any, Generic, Mapping, TypedDict, TypeVar

from quixstreams.models.types import HeadersMapping

Expand All @@ -27,7 +27,7 @@ def join(self, fields, on, value, key, timestamp, headers):
@abc.abstractmethod
def join(
self,
fields: dict[str, F],
fields: Mapping[str, F],
on: str,
value: dict[str, Any],
key: Any,
Expand Down Expand Up @@ -60,3 +60,19 @@ class BaseField(abc.ABC):
"""

pass


class CacheInfo(TypedDict):
"""
Typed dictionary containing cache statistics for the LRU cache.

:param hits: The number of cache hits.
:param misses: The number of cache misses.
:param size: The current size of the cache.
:param maxsize: The maximum size of the cache.
"""

hits: int
misses: int
size: int
maxsize: int
Original file line number Diff line number Diff line change
@@ -1,27 +1,12 @@
from collections import OrderedDict
from typing import Any, Callable, Optional, Tuple, TypedDict
from typing import Any, Callable, Optional, Tuple

from quixstreams.utils.pickle import pickle_copier

from ..base import CacheInfo
from .models import ConfigurationVersion, Field


class CacheInfo(TypedDict):
"""
Typed dictionary containing cache statistics for the LRU cache.

:param hits: The number of cache hits.
:param misses: The number of cache misses.
:param size: The current size of the cache.
:param maxsize: The maximum size of the cache.
"""

hits: int
misses: int
size: int
maxsize: int


class VersionDataLRU:
"""
Least Recently Used (LRU) cache for configuration version data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import threading
import time
from collections import defaultdict
from typing import TYPE_CHECKING, Any, Literal, Optional, Union
from typing import TYPE_CHECKING, Any, Literal, Mapping, Optional, Union

import httpx
import orjson

from quixstreams.kafka import ConnectionConfig, Consumer
from quixstreams.models import HeadersMapping, Topic

from ..base import BaseLookup
from .cache import CacheInfo, VersionDataLRU
from ..base import BaseLookup, CacheInfo
from .cache import VersionDataLRU
from .environment import QUIX_REPLICA_NAME
from .models import Configuration, ConfigurationVersion, Event, Field

Expand Down Expand Up @@ -326,7 +326,7 @@ def cache_info(self) -> CacheInfo:

def join(
self,
fields: dict[str, Field],
fields: Mapping[str, Field],
on: str,
value: dict[str, Any],
key: Any,
Expand Down
Loading