-
Notifications
You must be signed in to change notification settings - Fork 419
When using Redshift - PostgresSyntaxError: syntax error at or near "ORDER" - in query with no "ORDER" #1009
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
Comments
The error comes from the type introspection query. It might be possible to adapt asyncpg to Redshift, PRs welcome. |
Hey @elprans I'm experiencing the same error when trying to simply select a SUPER field from Redshift. Did you already have an idea of what are the main points to make asyncpg Redshift-compatible? |
For anyone else stumbling into this: the solution for me was to register a custom encoder/decoder for the |
Hi @elprans , I meet the same problem when trying a simple select query without ORDER from redshift. Are there any solution for this problem? |
@stefanondisponibile Thanks for the help. I can't get past this error though. Can you share the code you used? |
hey @remigabillet, I think that could depend specifically on the error you're getting, but you can find an example here. So for example: # ...
await connection.set_type_codec(
typename="super",
schema="pg_catalog",
encoder=your_encoder, decoder=your_decoder
)
# your_encoder and your_decoder can be as simple as json.dumps/json.loads to more complex implementations depending also on how you're storing your data. |
@stefanondisponibile this works! thank you!. I wasn't sure which
|
Glad it helped! |
@stefanondisponibile I'm running into the same error again when querying Redshift, when trying to bind a list: await conn.fetch(
"SELECT id, name FROM t WHERE id = ANY($1::BIGINT[])",
[976646132813407501, 976646132813407502]
) I debugged the code found OID 1016 is the one with a missing code. It maps to the type
I'm not sure hot how to proceed. Let me know if you have any ideas. |
@remigabillet I'm not sure that's directly related to this issue. Are you experiencing it also with other queries? Is the query you want to execute even working if you run it directly from the Redshift editor or psql? Array support in Redshift is quite different from Postgres (it's very poor actually, they have some ARRAY functions but they don't support the equivalent of the Postgres array data type), I would write that query with something like: SELECT id, name FROM t WHERE id IN (976646132813407501, 976646132813407502) So maybe in your case I wouldn't even use args ( |
the issue with a local PostgreSQL install?: I am using Amazon Redshift. I could not reproduce the issue with
potgres:9.0
Docker image.uvloop?: Have not tried
uvloop
.Running this snippet:
I get this exception:
I am wondering, where the "syntax error at or near "ORDER" comes from, as there is no "ORDER" in the original query.
If
asyncpg
does not rewrite queries in any way, and the query passed tofetch
is forwarded to the database without modification (#434 (comment), #859 (comment)) - where does the "ORDER" come from?Can this issue be worked around, or I should abandon
asyncpg
as a Redshift client? I do understand that Redshift is not officially supported, but this client is very good otherwise.I was not able to reproduce the error with the
postgres:9.0
instance (the oldest I was able to find quickly). The same (exceptssl=False
) snippet works without errors.The text was updated successfully, but these errors were encountered: