MCPcopy Create free account
hub / github.com/apache/datafusion / check_metadata_with_storage_equal

Function check_metadata_with_storage_equal

datafusion/common/src/metadata.rs:86–124  ·  view source on GitHub ↗

Assert equality of data types where one or both sides may have field metadata This currently compares absent metadata (e.g., one side was a DataType) and empty metadata (e.g., one side was a field where the field had no metadata) as equal and uses byte-for-byte comparison for the keys and values of the fields, even though this is potentially too strict for some cases (e.g., extension types where

(
    actual: (
        &DataType,
        Option<&std::collections::HashMap<String, String>>,
    ),
    expected: (
        &DataType,
        Option<&std::collections::HashMap<String, String>>,
   

Source from the content-addressed store, hash-verified

84/// Returns a planning error with suitably formatted type representations if
85/// actual and expected do not compare to equal.
86pub fn check_metadata_with_storage_equal(
87 actual: (
88 &DataType,
89 Option<&std::collections::HashMap<String, String>>,
90 ),
91 expected: (
92 &DataType,
93 Option<&std::collections::HashMap<String, String>>,
94 ),
95 what: &str,
96 context: &str,
97) -> Result<(), DataFusionError> {
98 if actual.0 != expected.0 {
99 return _plan_err!(
100 "Expected {what} of type {}, got {}{context}",
101 format_type_and_metadata(expected.0, expected.1),
102 format_type_and_metadata(actual.0, actual.1)
103 );
104 }
105
106 let metadata_equal = match (actual.1, expected.1) {
107 (None, None) => true,
108 (None, Some(expected_metadata)) => expected_metadata.is_empty(),
109 (Some(actual_metadata), None) => actual_metadata.is_empty(),
110 (Some(actual_metadata), Some(expected_metadata)) => {
111 actual_metadata == expected_metadata
112 }
113 };
114
115 if !metadata_equal {
116 return _plan_err!(
117 "Expected {what} of type {}, got {}{context}",
118 format_type_and_metadata(expected.0, expected.1),
119 format_type_and_metadata(actual.0, actual.1)
120 );
121 }
122
123 Ok(())
124}
125
126/// Given a data type represented by storage and optional metadata, generate
127/// a user-facing string

Callers 2

get_parameter_fieldsMethod · 0.85
verify_fieldsMethod · 0.85

Calls 1

is_emptyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…