Skip to content

Commit

Permalink
Fix an issues processing varchar types.
Browse files Browse the repository at this point in the history
  • Loading branch information
EpsilonPrime committed Aug 15, 2023
1 parent c694428 commit 340ec9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/substrait/textplan/parser/SubstraitPlanTypeVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ ::substrait::proto::Type SubstraitPlanTypeVisitor::typeToProto(
break;
}
try {
if (!varChar->length()->isInteger()) {
errorListener_->addError(
ctx->getStart(), "Missing varchar length.");
break;
}
int32_t length = std::stoi(varChar->length()->value());
type.mutable_varchar()->set_length(length);
} catch (...) {
Expand Down
7 changes: 6 additions & 1 deletion src/substrait/type/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,12 @@ ParameterizedTypePtr ParameterizedType::decode(

const auto& leftAngleBracketPos = matchingType.find('<');
if (leftAngleBracketPos == std::string::npos) {
bool nullable = matchingType.back() == '?';
bool nullable;
if (matchingType.empty()) {
nullable = false;
} else {
nullable = matchingType.back() == '?';
}
// deal with type and with a question mask like "i32?".
const auto& baseType = nullable
? matchingType = matchingType.substr(0, questionMaskPos)
Expand Down

0 comments on commit 340ec9c

Please sign in to comment.