Open rightx2 opened 1 year ago
I think this happened because date_time is str type, not datetime field so relative_on_field raised error.
Setting isodates=True didn't help me....
I initially was going to suggest referring to the datetime example for dataclasses_avroschema
until you provided the example comparing print(fp)
and count_table[fp.job_id] += 1
.
@app.agent(faust_topic)
async def process_fp(fps):
async for fp in fps.group_by(MyDtype.job_id):
count_table[fp.job_id] += 1
fp.job_id
is a string being passed to _window_ranges
when it expects a float
as an argument:
https://github.com/faust-streaming/faust/blob/948dd054b623b64812e87b83fff7a94eb0a5209d/faust/tables/base.py#L519-L522
group_by
works as intended as we can see from the page_views.py
example in https://faust-streaming.github.io/faust/playbooks/pageviews.html, so I think the issue is here:
count_table = app.Table(
f'{topic_name}_count_table', default=int,
).hopping(
size=timedelta(minutes=100),
step=timedelta(minutes=50),
expires=timedelta(minutes=100)
).relative_to_field(MyDtype.date_time)
From the example in https://github.com/faust-streaming/faust/blob/master/examples/windowed_aggregation.py, I think if you change your record to this:
class MyDtype(faust.Record, AvroModel):
job_id: str
value: int
date_time: datetime
your table should behave properly. I haven't had the opportunity to run your code yet so take my advice with a grain of salt.
Checklist
master
branch of Faust.I have a simple kafka producer code:
Faust code(working well):
It worked well.
However, When I changed below code
to
It raised error:
I think this happened because
date_time
is str type, not datetime field sorelative_on_field
raised error.Setting
isodates=True
didn't help me....How can I solve this?
Versions
docker.io/bitnami/kafka:3.2.1-debian-11-r2