splitgraph / seafowl

Analytical database for data-driven Web applications 🪶
https://seafowl.io
Apache License 2.0
432 stars 12 forks source link

Can't query remote tables on DDN #207

Closed gruuya closed 1 year ago

gruuya commented 1 year ago

If we try to create a remote table pointing to some ns/repo/table on Splitgraph DDN the first issue we hit is that the default protocol that connector-x uses (binary) employs the COPY command at some point, but that is disallowed on DDN, so the rewrite errors-out: UnsupportedSQLError: Unsupported statement type CopyStmt

On the other hand, if we set the suboptimal protocol (cursor) we still hit an issue:

$ curl -H "Content-Type: application/json" -H "Authorization: Bearer oT2WTDMRb1h5ExZCNPjFV0UbPjzEPPEh" http://localhost:8080/q   -d@-<<EOF
> {"query": "CREATE EXTERNAL TABLE table_1 STORED AS TABLE '\"splitgraph/census:latest\".\"acs2017_census_tract_data\"' LOCATION 'postgresql://a446d9b44bd14fd3869faca4b6e389c1:57dbb4e66b6940ff80d54d1012012538@data.splitgraph.com:5432/ddn'"}
> EOF
Execution error: Failed running the remote query PostgresArrowTransportError(Source(PostgresError(Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E26000), message: "prepared statement \"s1\" does not exist", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("prepare.c"), line: Some(509), routine: Some("FetchPreparedStatement") }) })))
gruuya commented 1 year ago

Fixed by configuring session pooling mode for Splitgraph pgbouncer, as well as avoiding the copy statements altogether by forcing the cursor protocol for DDN