Skip to content

Small fix for column filtering #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
from databricks.labs.mcp.servers.unity_catalog.cli import CliSettings
from mcp.types import TextContent, Tool as ToolSpec

# Constant storing vector index content vector column name
CONTENT_VECTOR_COLUMN_NAME = "__db_content_vector"
# Constants used to identify vector columns by name.
# Columns matching both patterns will be excluded; all others will be returned.
CONTENT_VECTOR_COLUMN_STARTS_WITH = "__db_"
CONTENT_VECTOR_COLUMN_ENDS_WITH = "_vector"


class QueryInput(BaseModel):
Expand Down Expand Up @@ -57,8 +59,14 @@ def get_table_columns(
workspace_client: WorkspaceClient, full_table_name: str
) -> list[str]:
table_info = workspace_client.tables.get(full_table_name)

return [
col.name for col in table_info.columns if col.name != CONTENT_VECTOR_COLUMN_NAME
col.name
for col in table_info.columns
if not (
col.name.startswith(CONTENT_VECTOR_COLUMN_STARTS_WITH)
and col.name.endswith(CONTENT_VECTOR_COLUMN_ENDS_WITH)
)
]


Expand Down