Skip to content
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

Error when using pull query #108

Open
victordriva opened this issue Jul 9, 2022 · 1 comment
Open

Error when using pull query #108

victordriva opened this issue Jul 9, 2022 · 1 comment

Comments

@victordriva
Copy link

This is my first issue, so sorry if i missed something.

I have encountered an issue when reading data from a stream using a PULL Query (im new to KSQL sorry if the problem is actually the query)

I have a test stream with only 4 rows, when i try to read it with the code bellow it outputs the rows but then throws an JSONDecodeError.

def consume_stream(stream: str, n_messages: int = 10) -> Generator[dict, None, None]:
    load_dotenv(find_dotenv())
    url = os.environ["KSQL_HOST"]

    client = KSQLAPI(url)

    client.query("SET 'auto.offset.reset' = 'earliest';")
    query = f"select * from {stream}"

    return client.query(query, return_objects=True)

The traceback is bellow (i use rich hence the pretty output, i can show the raw if needed), the problem is that the row returned is empty
image

A simple check like this fixes the issue

row = row.replace(",\n", "").replace("]\n", "")
if not row:
    return None

As a note if a use client.query(query) instead (without the return_objects=True) it still raises an error, but now is StopIteration, probably for the same reason.

@KenCox94 KenCox94 added bug and removed bug labels Jul 23, 2022
@sheinbergon
Copy link

sheinbergon commented Jul 25, 2024

Hello @KenCox94

I've forked the code, modernized it (replaced hyper with HTTPX, bumped all dependencies, updated to Python 3.9 as the minimal version, and fixed all the tests to behave with latest KSQL DB versions (0.29.0). Could you check if it's still present in my version?

https://github.com/sheinbergon/ksql-python-ng

I'll be making a PYPI release soon enough. In the meanwhile, you can test it by running

pipx install git+https://github.com/sheinbergon/ksql-python-ng.git --include-deps

or

pip install git+https://github.com/sheinbergon/ksql-python-ng.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants