Not able to access Table_tags in Databricks Apps:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2025 01:31 AM
When I try to fetch system.information_schema.schema_tags, it shows up but when I'm trying to fetch system.information_schema.table_tags it's not showing up and returns an empty df. Is there anything I am missing?
assert os.getenv('DATABRICKS_WAREHOUSE_ID'), "DATABRICKS_WAREHOUSE_ID must be set in app.yaml."
def sqlQuery(query: str) -> pd.DataFrame:
cfg = Config() # Pull environment variables for auth
with sql.connect(
server_hostname=cfg.host,
http_path=f"/sql/1.0/warehouses/{os.getenv('DATABRICKS_WAREHOUSE_ID')}",
credentials_provider=lambda: cfg.authenticate
) as connection:
with connection.cursor() as cursor:
cursor.execute(query)
result = cursor.fetchall_arrow()
if result is None or len(result) == 0:
st.warning(f"Query '{query}' returned no dataa.")
return pd.DataFrame()
return result.to_pandas()
st.set_page_config(layout="wide")
@st.cache_data(ttl=5) # only re-query if it's been 30 seconds
def getData():
# Query the system.information_schema.table_tags table
query = "SELECT * FROM system.information_schema.table_tags"
print(query)
df = sqlQuery(query)
print(df)
if df.empty:
st.error("No data returned from system.information_schema.table_tags. Check table existence or permissions.")
return df
data = getData()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2025 08:31 AM
How are you doing today? As per understanding, It looks like the system.information_schema.table_tags query is returning an empty DataFrame, which could be due to a couple of reasons. First, make sure that there are actually tags assigned to tables—if no tables have tags, the query will return nothing. Second, check if your Databricks SQL Warehouse has the right privileges to access table tags; sometimes, SELECT permissions on information_schema aren't sufficient, and you may need additional metadata permissions. Lastly, try running the same query directly in a Databricks SQL Editor to see if it returns results there—if not, then it’s likely a data or permissions issue rather than a code issue. Hope this helps!
Regards,
Brahma

