Repository navigation
fix(metadata): harden native metadata fallback coverage #336
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -243,7 +243,9 @@ pub(crate) static GET_FUNCTIONS_SCHEMA: LazyLock<SchemaRef> = LazyLock::new(|| { | |
| Arc::new(Schema::new(vec![ | ||
| Field::new("FUNCTION_CAT", DataType::Utf8, true), | ||
| Field::new("FUNCTION_SCHEM", DataType::Utf8, true), | ||
| Field::new("FUNCTION_NAME", DataType::Utf8, false), | ||
| // Classic SHOW FUNCTIONS can omit the modern `functionName` field. | ||
| // Keep this nullable so one malformed row does not discard the result. | ||
| Field::new("FUNCTION_NAME", DataType::Utf8, true), | ||
| Field::new("REMARKS", DataType::Utf8, true), | ||
| Field::new("FUNCTION_TYPE", DataType::Int16, true), | ||
| Field::new("SPECIFIC_NAME", DataType::Utf8, true), | ||
|
|
@@ -844,7 +846,12 @@ pub(crate) fn reshape_functions( | |
| ) -> Result<RecordBatch> { | ||
| let function_cat = constant_utf8(batch.num_rows(), Some(resolved_catalog)); | ||
| let function_schem = utf8_column(batch, "namespace")?; | ||
| let function_name = utf8_column(batch, "functionName")?; | ||
| let function_name = if column_index(batch.schema_ref(), "functionName").is_some() { | ||
| utf8_column(batch, "functionName")? | ||
| } else { | ||
| // Classic SHOW FUNCTIONS exposes a single column named `function`. | ||
| utf8_column(batch, "function")? | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Low — The classic-shape fallback maps the single |
||
| }; | ||
| let remarks = utf8_column(batch, "remarks")?; | ||
| let function_type = int16_column(batch, "functionType")?; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Low — Behavior change for the classic single-column |
||
| let specific_name = utf8_column(batch, "specificName")?; | ||
|
|
@@ -2088,6 +2095,33 @@ mod tests { | |
| assert_eq!(ftype.value(0), 1); | ||
| } | ||
|
|
||
| #[test] | ||
| fn reshape_functions_supports_classic_single_column_shape() { | ||
| let source = RecordBatch::try_new( | ||
| Arc::new(Schema::new(vec![Field::new( | ||
| "function", | ||
| DataType::Utf8, | ||
| true, | ||
| )])), | ||
| vec![Arc::new(StringArray::from(vec![ | ||
| Some("system.builtin.abs"), | ||
| None, | ||
| ]))], | ||
| ) | ||
| .unwrap(); | ||
|
|
||
| let out = reshape_functions(&source, "main").unwrap(); | ||
| let names = out | ||
| .column(2) | ||
| .as_any() | ||
| .downcast_ref::<StringArray>() | ||
| .unwrap(); | ||
| assert_eq!(names.value(0), "system.builtin.abs"); | ||
| assert!(names.is_null(1)); | ||
| assert!(out.column(1).is_null(0)); | ||
| assert!(out.column(3).is_null(0)); | ||
| } | ||
|
|
||
| /// `build_get_procedure_columns` raw server shape (information_schema | ||
| /// numeric metadata arrives as strings over the wire). | ||
| fn server_parameter_rows() -> RecordBatch { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 Low — Classic single-column
SHOW FUNCTIONSfallback places thefunctioncolumn value directly intoFUNCTION_NAME. Per the accompanying test, that column carries the fully-qualified name (e.g.system.builtin.abs) whileFUNCTION_SCHEM/FUNCTION_CATstay null (thenamespacecolumn is absent in this shape). JDBC/ThriftgetFunctionsnormally splits catalog/schema/name acrossFUNCTION_CAT/FUNCTION_SCHEM/FUNCTION_NAME, so consumers filtering or joining on the unqualified name may not match. This is the fallback path only and the behavior is deliberately encoded by the test, so it's likely acceptable — but worth confirming it matches how the reference drivers surface the classic shape.