Skip to content

feat(metadata): enable native list functions - #369

Merged
vuanhphung merged 5 commits into
mainfrom
feat/native-list-functions
Sep 29, 2026
Merged

vuanhphung merged 5 commits into
mainfrom
feat/native-list-functions

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Sep 25, 2026 •

Copy link
Copy Markdown
Collaborator

Route function metadata through the Thrift-native GetFunctions path. Use the SHOW FUNCTIONS carrier expected by SEA and supply the all-functions pattern when no name filter is provided.

Native responses are normalized to the public JDBC schema and preserve the caller’s original catalog value; the executable SHOW fallback is reshaped to the same schema.

Tests:

  • cargo +stable fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No issues identified by the review bot.

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low · 1 Nit

Looks good overall — the SQL builder change, native-catalog override, and JDBC schema mapping all match the reference JDBC driver's CommandBuilder/MetadataResultSetBuilder behavior, with solid native-path test coverage. One low-severity robustness note: the non-native SHOW FUNCTIONS fallback reshape hard-errors on a missing column where JDBC tolerates it, and that branch is untested; plus a test-fixture naming nit.

Other findings

  • ⚪ Nit — The new server_function_row() test fixture populates a function row with procedure-flavored values (functionName = "sp_report", specificName = "sp_report", namespace = "sales"), which reads like a copy-paste from the procedures fixture. Using function-like sample values (e.g. avg, default) would make the functions reshape test clearer and less confusing to a future reader.

Comment thread src/metadata/thrift_shape.rs Resolved
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
@vuanhphung vuanhphung added the integration-test Maintainer-only: triggers cross-repo integration tests. Auto-removed on push for re-review. label Sep 28, 2026
@github-actions

Copy link
Copy Markdown

Kernel integration tests triggered. View status. Results post back here as the "Kernel Integration Tests" check.

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Low

Looks good — routes function metadata through the SHOW FUNCTIONS IN CATALOG carrier and normalizes native/fallback results to the JDBC getFunctions schema. Verified against the JDBC reference driver: the carrier SQL, hive_metastore fallback, CURRENT_CATALOG() resolution, original-catalog preservation for native results, and the reshape column names (catalogName/namespace/functionName/remarks/functionType/specificName) all match DatabricksMetadataQueryClient.listFunctions / CommandBuilder.fetchFunctionsSQL / MetadataResultConstants. Unit + wiremock coverage is thorough. One low-severity note inline about an unmemoized per-call round-trip.

Comment thread src/metadata_v0.rs
}
}

async fn current_catalog(&self) -> Result<String> {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Low — functions(None, ..) now issues an extra synchronous SELECT CURRENT_CATALOG() statement (full execute + close round-trip) on every call before the actual metadata query, replacing the previous single information_schema.routines query. resolve_functions_catalog only consults the session's configured default_catalog() as a fallback after current_catalog() fails, so the round-trip is unconditional whenever no catalog argument is supplied.

This mirrors the JDBC driver's session.getCurrentCatalog() behavior (which is why using the session default first would be incorrect — a prior USE CATALOG changes the current catalog but not the session default), so fetching it live is the correct source of truth. The concern is purely that the result isn't memoized: repeated functions(None, ..) calls each pay the extra round-trip. If the current catalog can be cached (with invalidation on USE CATALOG), it would remove a per-call latency hit on this metadata path. Flagging as low since the round-trip is correctness-motivated and matches the reference driver.

@github-actions github-actions Bot removed the integration-test Maintainer-only: triggers cross-repo integration tests. Auto-removed on push for re-review. label Sep 29, 2026
@github-actions

Copy link
Copy Markdown

Integration test approval reset

New commits were pushed to this PR. The integration-test label has been automatically removed for security.

A maintainer must re-review the changes and re-add the label to trigger tests again.

Latest commit: d511b8f

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 1 Medium

Solid change that routes function metadata through the Thrift-native GetFunctions path with a SHOW FUNCTIONS carrier; the SQL grammar (SHOW FUNCTIONS IN CATALOG x SCHEMA LIKE y LIKE z), hive_metastore default, and the native-result JDBC column mapping all match the reference JDBC driver, and wiremock coverage for native + fallback + current-catalog resolution is good. One Medium parity concern: the SHOW-fallback reshape reads the server's catalogName for FUNCTION_CAT instead of substituting the resolved catalog like JDBC does, which can yield a null catalog on servers using the executable fallback. Note also that functions(None, ...) now issues an extra SELECT CURRENT_CATALOG() round-trip per call (JDBC uses cached session state) — acceptable since the kernel has no cached current catalog and the carrier needs a concrete catalog even for the native path.

// them apart. Known parity gap; distinguishing TVFs would require selecting
// additional information_schema.routines columns in the builder.
let function_type = Arc::new(Int16Array::from(vec![Some(1_i16); n])) as ArrayRef;
let function_cat = utf8_column(batch, "catalogName")?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — In the SHOW FUNCTIONS fallback path, reshape_functions derives FUNCTION_CAT from the server's catalogName column. The reference JDBC driver does not trust the fallback result's catalog column: in getRowsForFunctions it substitutes the resolved catalog (the same non-null catalog used to build SHOW FUNCTIONS IN CATALOG <x>, defaulting to hive_metastore) into FUNCTION_CAT, and only reads namespace/functionName/remarks/functionType/specificName from the result. The native path here already mirrors JDBC correctly (normalize_native_functions_batch overrides column 0 with the caller's original catalog), but the SHOW-fallback reshape does not.

Consequence: utf8_column returns an all-null array when catalogName is absent (or the server leaves it empty, as the native GetFunctions path is documented to do), so a client on a server that executes the executable fallback can see FUNCTION_CAT = NULL where JDBC guarantees the resolved catalog name. The added fallback test (functions_falls_back_when_current_catalog_is_unavailable) never exercises this: its functions_batch fixture always populates catalogName with the expected catalog, so the divergence is untested. Consider substituting the resolved catalog for FUNCTION_CAT in the fallback reshape (as JDBC does) rather than reading catalogName.

@vuanhphung
vuanhphung added this pull request to the merge queue Sep 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 29, 2026
@vuanhphung vuanhphung added the integration-test Maintainer-only: triggers cross-repo integration tests. Auto-removed on push for re-review. label Sep 29, 2026
@github-actions

Copy link
Copy Markdown

Kernel integration tests triggered. View status. Results post back here as the "Kernel Integration Tests" check.

@vuanhphung
vuanhphung added this pull request to the merge queue Sep 29, 2026
Merged via the queue into main with commit 687a4ca Sep 29, 2026
30 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — d511b8fb Deployed Sep 29, 2026 by oss-reviewer-bot[bot] via followup #1690
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted integration-test Maintainer-only: triggers cross-repo integration tests. Auto-removed on push for re-review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants