MCPcopy Create free account
hub / github.com/bytedance/bolt / tryResolveType

Method tryResolveType

bolt/expression/SignatureBinder.cpp:251–315  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

249}
250
251TypePtr SignatureBinder::tryResolveType(
252 const exec::TypeSignature& typeSignature,
253 const std::unordered_map<std::string, SignatureVariable>& variables,
254 const std::unordered_map<std::string, TypePtr>& typeVariablesBindings,
255 std::unordered_map<std::string, int>& integerVariablesBindings) {
256 const auto baseName = typeSignature.baseName();
257
258 if (variables.count(baseName)) {
259 auto it = typeVariablesBindings.find(baseName);
260 if (it == typeVariablesBindings.end()) {
261 return nullptr;
262 }
263 return it->second;
264 }
265
266 // Type is not a variable.
267 auto typeName = boost::algorithm::to_upper_copy(baseName);
268
269 const auto& params = typeSignature.parameters();
270 std::vector<std::string> params_name;
271
272 std::vector<TypeParameter> typeParameters;
273 for (auto& param : params) {
274 if (param.rowFieldName().has_value()) {
275 params_name.emplace_back(param.rowFieldName().value());
276 } else {
277 params_name.emplace_back("");
278 }
279 auto literal =
280 tryResolveLongLiteral(param, variables, integerVariablesBindings);
281 if (literal.has_value()) {
282 typeParameters.push_back(TypeParameter(literal.value()));
283 continue;
284 }
285
286 auto type = tryResolveType(
287 param, variables, typeVariablesBindings, integerVariablesBindings);
288 if (!type) {
289 return nullptr;
290 }
291 typeParameters.push_back(TypeParameter(type));
292 }
293
294 try {
295 if (auto type = getType(typeName, typeParameters, std::move(params_name))) {
296 return type;
297 }
298 } catch (const std::exception&) {
299 // TODO Perhaps, modify getType to add suppress-errors flag.
300 return nullptr;
301 }
302
303 auto typeKind = tryMapNameToTypeKind(typeName);
304 if (!typeKind.has_value()) {
305 return nullptr;
306 }
307
308 // getType(parameters) function doesn't support OPAQUE type.

Callers 8

resolveAggregateFunctionFunction · 0.45
intermediateTypeMethod · 0.45
createMethod · 0.45
resolveAggregateTypeFunction · 0.45
resolveWindowTypeFunction · 0.45
getResultTypesFunction · 0.45
TESTFunction · 0.45

Calls 11

tryResolveLongLiteralFunction · 0.85
TypeParameterClass · 0.85
tryResolveTypeFunction · 0.85
getTypeFunction · 0.85
tryMapNameToTypeKindFunction · 0.85
has_valueMethod · 0.80
countMethod · 0.45
findMethod · 0.45
endMethod · 0.45
valueMethod · 0.45
push_backMethod · 0.45

Tested by 4

resolveAggregateTypeFunction · 0.36
resolveWindowTypeFunction · 0.36
getResultTypesFunction · 0.36
TESTFunction · 0.36