Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Apr 10, 2024
1 parent 89de5d3 commit 54069cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
12 changes: 6 additions & 6 deletions velox/expression/SignatureBinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ TypePtr SignatureBinder::tryResolveType(
typeParameters.push_back(TypeParameter(type));
}

try {
if (auto type = getType(typeName, typeParameters)) {
return type;
}
} catch (const std::exception&) {
// TODO Perhaps, modify getType to add suppress-errors flag.
TypePtr type;
auto status = getType(typeName, typeParameters, type);
if (type) {
return type;
}
if (!status.ok()) {
return nullptr;
}

Expand Down
17 changes: 12 additions & 5 deletions velox/type/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,18 +1140,25 @@ bool hasType(const std::string& name) {
return false;
}

TypePtr getType(
Status getType(
const std::string& name,
const std::vector<TypeParameter>& parameters) {
const std::vector<TypeParameter>& parameters,
TypePtr& type) {
if (singletonBuiltInTypes().count(name)) {
return singletonBuiltInTypes().at(name);
type = singletonBuiltInTypes().at(name);
}

if (parametricBuiltinTypes().count(name)) {
return parametricBuiltinTypes().at(name)(parameters);
try {
type = parametricBuiltinTypes().at(name)(parameters);
} catch (const std::exception& e) {
type = nullptr;
return Status::UserError(e.what());
}
}

return getCustomType(name);
type = getCustomType(name);
return Status::OK();
}

} // namespace facebook::velox

0 comments on commit 54069cd

Please sign in to comment.