Skip to content

Commit a9b4f63

Browse files
authored
Rename lookup_join -> join_lookup for consistency (#910)
1 parent 6c6ad2f commit a9b4f63

File tree

8 files changed

+111
-99
lines changed

8 files changed

+111
-99
lines changed

docs/api-reference/dataframe.md

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,21 +1594,21 @@ StreamingDataFrame: The same StreamingDataFrame instance with the enrichment app
15941594

15951595
**Example**:
15961596

1597-
15981597
```python
15991598
from quixstreams import Application
1600-
from quixstreams.dataframe.joins.lookups import QuixConfigurationService, QuixConfigurationServiceField as Field
1599+
from quixstreams.dataframe.joins.lookups import QuixConfigurationService,
1600+
QuixConfigurationServiceField as Field
16011601

16021602
app = Application()
16031603

16041604
sdf = app.dataframe(app.topic("input"))
16051605
lookup = QuixConfigurationService(app.topic("config"), config=app.config)
16061606

16071607
fields = {
1608-
"test": Field(type="test", default="test_default")
1608+
"test": Field(type="test", default="test_default")
16091609
}
16101610

1611-
sdf = sdf.lookup_join(lookup, fields)
1611+
sdf = sdf.join_lookup(lookup, fields)
16121612
```
16131613

16141614
<a id="quixstreams.dataframe.dataframe.StreamingDataFrame.register_store"></a>
@@ -2293,32 +2293,34 @@ Rows will be deserialized into a dictionary with column names as keys.
22932293

22942294
**Example**:
22952295

2296-
22972296
```python
22982297
lookup = SQLiteLookup(path="/path/to/db.sqlite")
22992298

2300-
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2301-
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"], on="col2")}
2299+
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2300+
fields = {
2301+
"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"], on="col2")}
23022302

2303-
# After the lookup the `my_field` column in the message will contains:
2304-
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>}
2305-
sdf = sdf.lookup_join(lookup, fields)
2303+
# After the lookup the `my_field` column in the message will contains:
2304+
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>}
2305+
sdf = sdf.join_lookup(lookup, fields)
23062306
```
2307-
2307+
23082308
```python
23092309
lookup = SQLiteLookup(path="/path/to/db.sqlite")
23102310

2311-
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2312-
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"], on="col2", first_match_only=False)}
2311+
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2312+
fields = {
2313+
"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"], on="col2",
2314+
first_match_only=False)}
23132315

2314-
# After the lookup the `my_field` column in the message will contains:
2315-
# [
2316-
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>},
2317-
# {"col1": <row2 col1 value>, "col2": <row2 col2 value>},
2318-
# ...
2319-
# {"col1": <rowN col1 value>, "col2": <rowN col2 value>,},
2320-
# ]
2321-
sdf = sdf.lookup_join(lookup, fields)
2316+
# After the lookup the `my_field` column in the message will contains:
2317+
# [
2318+
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>},
2319+
# {"col1": <row2 col1 value>, "col2": <row2 col2 value>},
2320+
# ...
2321+
# {"col1": <rowN col1 value>, "col2": <rowN col2 value>,},
2322+
# ]
2323+
sdf = sdf.join_lookup(lookup, fields)
23222324
```
23232325

23242326

@@ -2409,32 +2411,34 @@ Query results are returned as tuples of values, without additional deserializati
24092411

24102412
**Example**:
24112413

2412-
24132414
```python
24142415
lookup = SQLiteLookup(path="/path/to/db.sqlite")
24152416

2416-
# Select all columns from the first row of `my_table` where `col2` matches the value of `field1` in the message.
2417-
fields = {"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1")}
2417+
# Select all columns from the first row of `my_table` where `col2` matches the value of `field1` in the message.
2418+
fields = {
2419+
"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1")}
24182420

2419-
# After the lookup, the `my_field` column in the message will contain:
2420-
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>]
2421-
sdf = sdf.lookup_join(lookup, fields)
2421+
# After the lookup, the `my_field` column in the message will contain:
2422+
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>]
2423+
sdf = sdf.join_lookup(lookup, fields)
24222424
```
2423-
2425+
24242426
```python
24252427
lookup = SQLiteLookup(path="/path/to/db.sqlite")
24262428

2427-
# Select all columns from all rows of `my_table` where `col2` matches the value of `field1` in the message.
2428-
fields = {"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1", first_match_only=False)}
2429+
# Select all columns from all rows of `my_table` where `col2` matches the value of `field1` in the message.
2430+
fields = {
2431+
"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1",
2432+
first_match_only=False)}
24292433

2430-
# After the lookup, the `my_field` column in the message will contain:
2431-
# [
2432-
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>],
2433-
# [<row2 col1 value>, <row2 col2 value>, ..., <row2 colN value>],
2434-
# ...
2435-
# [<rowN col1 value>, <rowN col2 value>, ..., <rowN colN value>],
2436-
# ]
2437-
sdf = sdf.lookup_join(lookup, fields)
2434+
# After the lookup, the `my_field` column in the message will contain:
2435+
# [
2436+
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>],
2437+
# [<row2 col1 value>, <row2 col2 value>, ..., <row2 colN value>],
2438+
# ...
2439+
# [<rowN col1 value>, <rowN col2 value>, ..., <rowN colN value>],
2440+
# ]
2441+
sdf = sdf.join_lookup(lookup, fields)
24382442
```
24392443

24402444

@@ -2490,11 +2494,11 @@ based on a configurable TTL. The cache is a least recently used (LRU) cache with
24902494

24912495
**Example**:
24922496

2493-
24942497
```python
24952498
lookup = SQLiteLookup(path="/path/to/db.sqlite")
2496-
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col2"], on="primary_key_col")}
2497-
sdf = sdf.lookup_join(lookup, fields)
2499+
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col2"],
2500+
on="primary_key_col")}
2501+
sdf = sdf.join_lookup(lookup, fields)
24982502
```
24992503

25002504

docs/api-reference/quixstreams.md

Lines changed: 42 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,7 +2337,8 @@ Example:
23372337

23382338
```python
23392339
from quixstreams import Application
2340-
from quixstreams.dataframe.joins.lookups import QuixConfigurationService, QuixConfigurationServiceField as Field
2340+
from quixstreams.dataframe.joins.lookups import QuixConfigurationService,
2341+
QuixConfigurationServiceField as Field
23412342

23422343
app = Application()
23432344

@@ -2348,7 +2349,7 @@ fields = {
23482349
"test": Field(type="test", default="test_default")
23492350
}
23502351

2351-
sdf = sdf.lookup_join(lookup, fields)
2352+
sdf = sdf.join_lookup(lookup, fields)
23522353
```
23532354

23542355
<a id="quixstreams.dataframe.dataframe.StreamingDataFrame.register_store"></a>
@@ -2899,28 +2900,31 @@ Example:
28992900
```python
29002901
lookup = SQLiteLookup(path="/path/to/db.sqlite")
29012902

2902-
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2903-
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"], on="col2")}
2903+
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2904+
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"],
2905+
on="col2")}
29042906

2905-
# After the lookup the `my_field` column in the message will contains:
2906-
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>}
2907-
sdf = sdf.lookup_join(lookup, fields)
2907+
# After the lookup the `my_field` column in the message will contains:
2908+
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>}
2909+
sdf = sdf.join_lookup(lookup, fields)
29082910
```
29092911

29102912
```python
29112913
lookup = SQLiteLookup(path="/path/to/db.sqlite")
29122914

2913-
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2914-
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"], on="col2", first_match_only=False)}
2915+
# Select the value in `col1` from the table `my_table` where `col2` matches the `sdf.lookup_join` on parameter.
2916+
fields = {
2917+
"my_field": SQLiteLookupField(table="my_table", columns=["col1", "col2"], on="col2",
2918+
first_match_only=False)}
29152919

2916-
# After the lookup the `my_field` column in the message will contains:
2917-
# [
2918-
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>},
2919-
# {"col1": <row2 col1 value>, "col2": <row2 col2 value>},
2920-
# ...
2921-
# {"col1": <rowN col1 value>, "col2": <rowN col2 value>,},
2922-
# ]
2923-
sdf = sdf.lookup_join(lookup, fields)
2920+
# After the lookup the `my_field` column in the message will contains:
2921+
# [
2922+
# {"col1": <row1 col1 value>, "col2": <row1 col2 value>},
2923+
# {"col1": <row2 col1 value>, "col2": <row2 col2 value>},
2924+
# ...
2925+
# {"col1": <rowN col1 value>, "col2": <rowN col2 value>,},
2926+
# ]
2927+
sdf = sdf.join_lookup(lookup, fields)
29242928
```
29252929

29262930
**Arguments**:
@@ -3000,28 +3004,31 @@ Example:
30003004
```python
30013005
lookup = SQLiteLookup(path="/path/to/db.sqlite")
30023006

3003-
# Select all columns from the first row of `my_table` where `col2` matches the value of `field1` in the message.
3004-
fields = {"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1")}
3007+
# Select all columns from the first row of `my_table` where `col2` matches the value of `field1` in the message.
3008+
fields = {
3009+
"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1")}
30053010

3006-
# After the lookup, the `my_field` column in the message will contain:
3007-
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>]
3008-
sdf = sdf.lookup_join(lookup, fields)
3011+
# After the lookup, the `my_field` column in the message will contain:
3012+
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>]
3013+
sdf = sdf.join_lookup(lookup, fields)
30093014
```
30103015

30113016
```python
30123017
lookup = SQLiteLookup(path="/path/to/db.sqlite")
30133018

3014-
# Select all columns from all rows of `my_table` where `col2` matches the value of `field1` in the message.
3015-
fields = {"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1", first_match_only=False)}
3019+
# Select all columns from all rows of `my_table` where `col2` matches the value of `field1` in the message.
3020+
fields = {
3021+
"my_field": SQLiteLookupQueryField("SELECT * FROM my_table WHERE col2 = :field1",
3022+
first_match_only=False)}
30163023

3017-
# After the lookup, the `my_field` column in the message will contain:
3018-
# [
3019-
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>],
3020-
# [<row2 col1 value>, <row2 col2 value>, ..., <row2 colN value>],
3021-
# ...
3022-
# [<rowN col1 value>, <rowN col2 value>, ..., <rowN colN value>],
3023-
# ]
3024-
sdf = sdf.lookup_join(lookup, fields)
3024+
# After the lookup, the `my_field` column in the message will contain:
3025+
# [
3026+
# [<row1 col1 value>, <row1 col2 value>, ..., <row1 colN value>],
3027+
# [<row2 col1 value>, <row2 col2 value>, ..., <row2 colN value>],
3028+
# ...
3029+
# [<rowN col1 value>, <rowN col2 value>, ..., <rowN colN value>],
3030+
# ]
3031+
sdf = sdf.join_lookup(lookup, fields)
30253032
```
30263033

30273034
**Arguments**:
@@ -3071,8 +3078,9 @@ Example:
30713078

30723079
```python
30733080
lookup = SQLiteLookup(path="/path/to/db.sqlite")
3074-
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col2"], on="primary_key_col")}
3075-
sdf = sdf.lookup_join(lookup, fields)
3081+
fields = {"my_field": SQLiteLookupField(table="my_table", columns=["col2"],
3082+
on="primary_key_col")}
3083+
sdf = sdf.join_lookup(lookup, fields)
30763084
```
30773085

30783086
**Arguments**:

docs/joins.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ If you change timestamps of the record during processing, they will be processed
153153
This is an experimental feature; the API may change in future releases.
154154

155155

156-
`StreamingDataFrame.lookup_join()` is a special type of join that allows you to enrich records in a streaming dataframe with the data from external systems.
156+
`StreamingDataFrame.join_lookup()` is a special type of join that allows you to enrich records in a streaming dataframe with the data from external systems.
157157

158158
You can use it to enriching streaming data with configuration or reference data from an external source, like a database.
159159

@@ -163,7 +163,7 @@ To perform a lookup join, you need:
163163

164164
1. A subclass of [quixstreams.dataframe.joins.lookups.base.BaseLookup](api-reference/dataframe.md#baselookup) to query the external source and cache the results when necessary.
165165
2. A subclass of [quixstreams.dataframe.joins.lookups.base.BaseField](api-reference/dataframe.md#basefield) to define how the data is extracted from the result.
166-
3. To pass the lookup and the fields to the `StreamingDataFrame.lookup_join`.
166+
3. To pass the lookup and the fields to the `StreamingDataFrame.join_lookup`.
167167

168168

169169
See [SQLiteLookup](api-reference/dataframe.md#sqlitelookup) and [SQLiteLookupField](api-reference/dataframe.md#sqlitelookupfield) for the reference implementation.
@@ -177,13 +177,13 @@ from quixstreams.dataframe.joins.lookups import SQLiteLookup, SQLiteLookupField
177177
app = Application(...)
178178

179179
# An implementation of BaseLookup for SQLite
180-
lookup = SQLiteLookup(path="db.db")
180+
lookup = SQLiteLookup(path="db.db")
181181

182182
sdf = app.dataframe(app.topic("input"))
183183

184-
sdf = sdf.lookup_join(
184+
sdf = sdf.join_lookup(
185185
lookup,
186-
on="column", # A column in StreamingDataFrame to join on
186+
on="column", # A column in StreamingDataFrame to join on
187187
fields={
188188
# A mapping with SQLite fields to join with
189189
"lookup": SQLiteLookupField(table="table", columns=["column"], on="id"),

quixstreams/dataframe/dataframe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,7 +1722,7 @@ def join_asof(
17221722
how=how, on_merge=on_merge, grace_ms=grace_ms, store_name=name
17231723
).join(self, right)
17241724

1725-
def lookup_join(
1725+
def join_lookup(
17261726
self,
17271727
lookup: BaseLookup,
17281728
fields: dict[str, BaseField],
@@ -1765,7 +1765,7 @@ def lookup_join(
17651765
"test": Field(type="test", default="test_default")
17661766
}
17671767
1768-
sdf = sdf.lookup_join(lookup, fields)
1768+
sdf = sdf.join_lookup(lookup, fields)
17691769
```
17701770
"""
17711771
if callable(on):

quixstreams/dataframe/joins/lookups/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class BaseLookup(abc.ABC, Generic[F]):
1414
This class defines the interface for lookup joins, where incoming records are enriched with external data based on a key and
1515
a set of fields. Subclasses should implement the `join` method to specify how enrichment is performed.
1616
17-
Typical usage involves passing an instance of a subclass to `StreamingDataFrame.lookup_join`, along with a mapping of field names
17+
Typical usage involves passing an instance of a subclass to `StreamingDataFrame.join_lookup`, along with a mapping of field names
1818
to BaseField instances that describe how to extract or map enrichment data.
1919
2020
Example:

quixstreams/dataframe/joins/lookups/quix_configuration_service/lookup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class Lookup(BaseLookup[Field]):
3939
4040
Usage:
4141
- Instantiate with a configuration topic and (optionally) application config or connection details.
42-
- Use as the `lookup` argument in `StreamingDataFrame.lookup_join()` with a mapping of field names to Field objects.
42+
- Use as the `lookup` argument in `StreamingDataFrame.join_lookup()` with a mapping of field names to Field objects.
4343
- The `join` method is called for each record to enrich, updating the record in-place with configuration data.
4444
4545
Features:
@@ -50,7 +50,7 @@ class Lookup(BaseLookup[Field]):
5050
5151
Example:
5252
lookup = Lookup(topic, app_config=app.config)
53-
sdf = sdf.lookup_join(lookup, fields)
53+
sdf = sdf.join_lookup(lookup, fields)
5454
"""
5555

5656
def __init__(

0 commit comments

Comments
 (0)