-
Notifications
You must be signed in to change notification settings - Fork 535
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
KeyDecodeError when group_by changes key type #543
Comments
Here's the workaround. It works: import faust
app = faust.App('example', broker='kafka://')
class StringModel(faust.Record):
string_value: str
int_topic = app.topic(
'int_topic',
key_type=int,
value_type=StringModel,
internal=True,
)
str_topic = app.topic(
'str_topic',
key_type=str,
value_type=StringModel,
internal=True,
)
@app.agent(int_topic)
async def int_agent(int_topic):
async for k, v in int_topic.group_by(StringModel.string_value, topic=str_topic).items():
print(f'{k}: {v}')
@app.task
async def example_sender(app):
await int_topic.send(key='5', value=StringModel(string_value="five"))
if __name__ == '__main__':
app.main() |
pscottdevos
pushed a commit
to pscottdevos/faust
that referenced
this issue
Dec 26, 2021
robinhood#543 Passes key_type to derive if key has "type" attribute.
I have submitted a PR that fixes this issue. |
pscottdevos
pushed a commit
to pscottdevos/faust
that referenced
this issue
Dec 27, 2021
robinhood#543 Passes key_type to derive if key has "type" attribute.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
stream.group_by does not appear to set it's topic's type properly, if it's different than the source stream's key type. Here's an example program that demonstrates converting from int key to str key:
run the program like
python bugdemo.py worker
Running the program generates a KeyDecodeError. It should not do that. A workaround is to explicitly specify the group_by topic to one with the correct key type
Full traceback
Versions
The text was updated successfully, but these errors were encountered: