Search code examples
amazon-web-servicesamazon-timestream

Is it possible to retrieve the Timestream schema via the API?


The AWS console for Timestream can show you the schema for tables, but I cannot find any way to retrieve this information programatically. While the schema is dynamically created from the write requests, it would be useful to check the schema to validate that writes are going to generate the same measure types.


Solution

  • As shown in this document, you can run the command beneath, it'll return the table's schema.

    DESCRIBE "database"."tablename"
    

    Having the right profile setup at your environment, to run this query from the CLI, you can run the command:

    aws timestream-query query --query-string 'DESCRIBE "db-name"."tb-name"' --no-paginate 
    

    This should return the table schema.

    You can also retrieve the same data running this query from source codes in Typescript/Javascript, Python, Java or C# just by using the Timestream-Query library from AWS's SDK.

    NOTE:

    If the table is empty, this query will return empty so, make sure you have data in your db/table before querying for it's schema, ok? Good luck!