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

Method verify_fields

datafusion/common/src/param_value.rs:49–82  ·  view source on GitHub ↗

Verify parameter list length and type

(&self, expect: &[FieldRef])

Source from the content-addressed store, hash-verified

47
48 /// Verify parameter list length and type
49 pub fn verify_fields(&self, expect: &[FieldRef]) -> Result<()> {
50 match self {
51 ParamValues::List(list) => {
52 // Verify if the number of params matches the number of values
53 if expect.len() != list.len() {
54 return _plan_err!(
55 "Expected {} parameters, got {}",
56 expect.len(),
57 list.len()
58 );
59 }
60
61 // Verify if the types of the params matches the types of the values
62 let iter = expect.iter().zip(list.iter());
63 for (i, (param_type, lit)) in iter.enumerate() {
64 check_metadata_with_storage_equal(
65 (
66 &lit.value.data_type(),
67 lit.metadata.as_ref().map(|m| m.to_hashmap()).as_ref(),
68 ),
69 (param_type.data_type(), Some(param_type.metadata())),
70 "parameter",
71 &format!(" at index {i}"),
72 )?;
73 }
74 Ok(())
75 }
76 ParamValues::Map(_) => {
77 // If it is a named query, variables can be reused,
78 // but the lengths are not necessarily equal
79 Ok(())
80 }
81 }
82 }
83
84 pub fn get_placeholders_with_values(&self, id: &str) -> Result<ScalarAndMetadata> {
85 match self {

Callers 2

with_param_valuesMethod · 0.80
verifyMethod · 0.80

Calls 8

to_hashmapMethod · 0.80
lenMethod · 0.45
iterMethod · 0.45
data_typeMethod · 0.45
as_refMethod · 0.45
mapMethod · 0.45
metadataMethod · 0.45

Tested by

no test coverage detected