Repository navigation
feat(metadata): enable native list functions - #369
Conversation
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
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.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
|
Kernel integration tests triggered. View status. Results post back here as the "Kernel Integration Tests" check. |
There was a problem hiding this comment.
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.
| } | ||
| } | ||
|
|
||
| async fn current_catalog(&self) -> Result<String> { |
There was a problem hiding this comment.
🔵 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.
|
Integration test approval reset New commits were pushed to this PR. The A maintainer must re-review the changes and re-add the label to trigger tests again. Latest commit: d511b8f |
There was a problem hiding this comment.
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")?; |
There was a problem hiding this comment.
🟡 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.
|
Kernel integration tests triggered. View status. Results post back here as the "Kernel Integration Tests" check. |
Route function metadata through the Thrift-native
GetFunctionspath. Use theSHOW FUNCTIONScarrier 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
SHOWfallback is reshaped to the same schema.Tests:
cargo +stable fmt --all -- --checkcargo clippy --all-targets -- -D warningscargo test