MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / track_seen

Method track_seen

src/sql/src/func.rs:1415–1458  ·  view source on GitHub ↗

Determines the desired type of polymorphic compatibility, as well as the values to determine a polymorphic solution.

(&mut self, param: &ParamType, seen: CoercibleScalarType)

Source from the content-addressed store, hash-verified

1413 /// Determines the desired type of polymorphic compatibility, as well as the
1414 /// values to determine a polymorphic solution.
1415 fn track_seen(&mut self, param: &ParamType, seen: CoercibleScalarType) {
1416 use ParamType::*;
1417
1418 self.seen.push(match param {
1419 // These represent the keys of their respective compatibility classes.
1420 AnyElement | AnyCompatible | ListAnyCompatible | MapAnyCompatible | NonVecAny
1421 | RecordAny => seen,
1422 MapAny => seen.map_coerced(|array| array.unwrap_map_value_type().clone()),
1423 ListAny => seen.map_coerced(|array| array.unwrap_list_element_type().clone()),
1424 ArrayAny | ArrayAnyCompatible => {
1425 seen.map_coerced(|array| array.unwrap_array_element_type().clone())
1426 }
1427 RangeAny | RangeAnyCompatible => {
1428 seen.map_coerced(|range| range.unwrap_range_element_type().clone())
1429 }
1430 ListElementAnyCompatible => seen.map_coerced(|el| SqlScalarType::List {
1431 custom_id: None,
1432 element_type: Box::new(el),
1433 }),
1434 o => {
1435 assert!(
1436 !o.is_polymorphic(),
1437 "polymorphic parameters must track types they \
1438 encounter to determine polymorphic solution"
1439 );
1440 return;
1441 }
1442 });
1443
1444 let compat_class = param
1445 .try_into()
1446 .expect("already returned for non-polymorphic params");
1447
1448 match &self.compat {
1449 None => self.compat = Some(compat_class),
1450 Some(c) => {
1451 assert_eq!(
1452 c, &compat_class,
1453 "do not know how to correlate polymorphic classes {:?} and {:?}",
1454 c, &compat_class,
1455 )
1456 }
1457 };
1458 }
1459
1460 /// Attempt to resolve all polymorphic types to a single "key" type. For
1461 /// `target_for_param_type` to be useful, this must have already been

Callers 1

newMethod · 0.80

Calls 9

map_coercedMethod · 0.80
unwrap_map_value_typeMethod · 0.80
expectMethod · 0.80
pushMethod · 0.45
cloneMethod · 0.45
try_intoMethod · 0.45

Tested by

no test coverage detected