Search code examples
databasetime-seriesquestdb

Cannot DETACH partition using QuestDB REST API


I can run this query just fine from the web console or using psycopg from python

ALTER TABLE events DETACH PARTITION WHERE timestamp < dateadd('M', -8, date_trunc('day', now()))

But when I try invoking the API directly I get an error: method is not allowed

curl -X POST "http://questdb.default.svc.cluster.local:9000/exec" --data-urlencode "query=ALTER TABLE events DETACH PARTITION WHERE timestamp < dateadd('M', -8, date_trunc('day', now()))"

Solution

  • This was an easy one! The /exec endpoint expects a GET request, unlike the imp endpoint which expects a POST.

    curl -G "http://questdb.default.svc.cluster.local:9000/exec" --data-urlencode "query=ALTER TABLE events DETACH PARTITION WHERE timestamp < dateadd('M', -8, date_trunc('day', now()))"