7

Executing a delete query on an Amazon Timestream DB.

When executing this query:

delete from "data-api-timestream-test"."test_table" 

I get the error:

The query syntax is invalid at line 1:1

Can I delete records from Amazon Timestream?

Ermiya Eskandary
  • 15,323
  • 3
  • 31
  • 44
Adelin
  • 18,144
  • 26
  • 115
  • 175

2 Answers2

10

Unfortunately, AWS Timestream does not support deletes right now.

The only supported operations are inserts and upserts.

Ermiya Eskandary
  • 15,323
  • 3
  • 31
  • 44
gperego
  • 121
  • 4
  • Is there any work around to update the record data? – Sudheesh S Babu Dec 22 '21 at 12:23
  • 2
    You can upsert records by including the Version in record definition while sending a WriteRecords request. Amazon Timestream will store the record with the record with highest Version. https://docs.aws.amazon.com/timestream/latest/developerguide/code-samples.write.html – gperego Feb 17 '22 at 21:26
0

As mentioned in the comments, you can not delete the records from timestream database, but you can delete a table via AWS TimeStream SDK. I am attaching a code sample in golang, but you can also do it with Python, Java and bunch of other languages.

deleteTableInput := &timestreamwrite.DeleteTableInput{
    DatabaseName:   aws.String(*databaseName),
    TableName:    aws.String(*tableName),
}
_, err = writeSvc.DeleteTable(deleteTableInput)

if err != nil {
    fmt.Println("Error:")
    fmt.Println(err)
} else {
    fmt.Println("Table deleted", *tableName)
}

Ref: https://docs.aws.amazon.com/timestream/latest/developerguide/code-samples.delete-table.html

Priyank Chheda
  • 521
  • 5
  • 16