Skip to content

Commit

Permalink
insufficient errors
Browse files Browse the repository at this point in the history
  • Loading branch information
v-chen_data committed Sep 26, 2024
1 parent 3b1fc4a commit a2ccc9e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion llmfoundry/command_utils/data_prep/convert_delta_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,22 @@ def run_query(
if method == 'dbsql':
if cursor is None:
raise ValueError(f'cursor cannot be None if using method dbsql')
cursor.execute(query)
try:
cursor.execute(query)
except Exception as e:
from databricks.sql.exc import ServerOperationError
if isinstance(e, ServerOperationError):
if 'INSUFFICIENT_PERMISSIONS' in e.message: # pyright: ignore
match = re.search(
r"'([^']+)'",
e.message, # pyright: ignore
)
if match:
table_name = match.group(1)
action = f'accessing table {table_name}'
else:
action = 'accessing table'
raise InsufficientPermissionsError(action=action,) from e
if collect:
return cursor.fetchall()
elif method == 'dbconnect':
Expand Down

0 comments on commit a2ccc9e

Please sign in to comment.