I have one table that changes the name every 60 days. The name simple increases the number version, for example:
- Firtst 60 days: table_name_v1. After 60 days: table_name_v2 and so on.
What i want is to query the table wich name returned in the query of information_schema using just SQL in Databricks SQL. This is important because I have a Databricks SQL Dashboard and when the name change, I won’t need to adapt the query name.
Here is a example of what I want.
CREATE OR REPLACE TEMP VIEW db_copart AS
SELECT
table_name
FROM information_schema.tables
WHERE
table_schema = ‘table_sandbox’
and table_name ILIKE ‘%db_pi_copart_v%’; — this will return the latest table version
SELECT
*
FROM table_sandbox.(select table_name from db_copart)
jose nilton andrade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.