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

Post upgrade to 25.01, existing python code doesn't work anymore #7293

Open
productatvitrina opened this issue Jan 22, 2025 · 5 comments
Open

Comments

@productatvitrina
Copy link

I recently upgraded from 8.0.0.b32245 to 25.0.1 version.
However, all of my python code have stopped working.
For example, a simple code like below which reads output from another query and shows them as is, is running but not showing anything as output.

def query(query_id=58):
try:
# Fetch the query results
results = get_query_result(query_id)

    # Check if we have results
    if not results or 'rows' not in results:
        return {
            "rows": [],
            "columns": [],
            "error": "No results found"
        }

    # Just return the rows as they are
    return {
        "rows": results['rows'],
        "columns": [
            {"name": col, "type": "string"} 
            for col in results['rows'][0].keys()
        ] if results['rows'] else []
    }

except Exception as e:
    return {
        "rows": [],
        "columns": [],
        "error": str(e)
    }

There are around 22 records in my query_id 58.

Below is another example of my code which used to work smoothly when I had Redash 8.x version:

@eradman
Copy link
Collaborator

eradman commented Jan 27, 2025

@productatvitrina how were you executing this Python code with Redash 8.x?

@productatvitrina
Copy link
Author

@eradman something like below:

Fetch the query results

query_id = 58
results = get_query_result(query_id)

Initialize data structures

processed_data = []

if 'rows' in results:
for record in results['rows']:
# Process each record as needed
processed_record = {
"id": record.get('id', ''),
"name": record.get('name', ''),
"value": record.get('value', '')
}
processed_data.append(processed_record)

Prepare the result object for Redash

result = {
"rows": processed_data,
"columns": [
{"name": "id", "type": "string"},
{"name": "name", "type": "string"},
{"name": "value", "type": "string"}
]
}

Return the result for Redash

return result

@eradman
Copy link
Collaborator

eradman commented Jan 28, 2025

Oh! This is a data source, which is disabled by default
https://redash.io/help/data-sources/querying/python/

does the simple example on this page work?

@productatvitrina
Copy link
Author

Yes, I have manually added Python as data source in my env file. Running python queries as well. The problem has arisen after the upgrade.

@eradman
Copy link
Collaborator

eradman commented Jan 29, 2025

Does a new Python query work with 25.1? This worked for me
Image

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

2 participants