How do I disable table location caching?

You can disable table location caching via a JVM argument, or programmatically clear either the entire cache or the cache for specific tables.

Some use cases, like static user tables, often involve replacing partitions of data. The db object caches the results of table location discovery the first time you access that table, so that future accesses are as fast as possible. If caching is enabled and you try to access a table with partitions that have been replaced since the cache was created, you may encounter errors. To better support this workflow, you can disable table location caching and clear caches directly.

To disable caching for an entire session, set the JVM argument -DDatabase.useLocationCaches=false before launching your Code Studio or Persistent Query. If you want to clear caches programmatically, call the following:

// Clears all location caches
db.clearLocationCache()

// Clears the location cache for just the specified table.
db.clearLocationCache("Namespace", "TableName)
# Clears all location caches
db.j_db.clearLocationCache()

# Clears the location cache for just the specified table.
db.j_db.clearLocationCache("Namespace", "TableName)