Pass case sensitive view name to TimescaleDB functions

What is the right way to pass a case-sensitive view name to add_continuous_aggregate_policy ?

Per this example, using a combination of single and double quotes will enable case-sensitive view names :

SELECT add_continuous_aggregate_policy('"iDU8boGyFcvWwfz6KhMSdg"', ...

This approach will work uniformly across all TimescaleDB functions, for example:

SELECT create_hypertable('"CaMeL"','"CaSe"');

Background

Postgres normalizes any table name to lowercase unless it is quoted.

The quoting logic you see in our functions is not implemented by Timescale but by Postgres. The outer ' indicates a text literal and the inner " marks the content range so it doesn’t get converted to lowercase.

When you call the function, it tries to cast the text literal to regclass. You can try this outside of a function call like this:

SELECT '"metrics"'::regclass;

Recommendation

It is best practice to use lowercase object names so you don’t have to deal with this. However, if your table names are not all lowercase then you can work around this using quotes as described.

**You can read the original discussion on Slack: **