Skip to content

Commit 00e36b6

Browse files
amitkduttafacebook-github-bot
authored andcommitted
misc: Throw user error when unsupported character found during casting to number types
Summary: We are not supporting conversion of unicode chars to integer. Throwing unsupported error to notify users and proper classification of erros. VELOX_USER_FAIL has [invalid_error_code](https://github.com/facebookincubator/velox/blob/478c73d8c0ef2f486640e4dcc0688698fcc326f6/velox/common/base/Exceptions.h#L426) which maps to [Presto user error](https://github.com/prestodb/presto/blob/e936ad06e9e205df978ad74287a490f552870047/presto-native-execution/presto_cpp/main/common/Exception.h#L105) Differential Revision: D74148164
1 parent 478c73d commit 00e36b6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

velox/expression/CastExpr-inl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,10 +344,11 @@ void CastExpr::applyCastKernel(
344344
ToKind == TypeKind::INTEGER || ToKind == TypeKind::BIGINT ||
345345
ToKind == TypeKind::HUGEINT) {
346346
if constexpr (TPolicy::throwOnUnicode) {
347-
VELOX_USER_CHECK(
348-
functions::stringCore::isAscii(
349-
inputRowValue.data(), inputRowValue.size()),
350-
"Unicode characters are not supported for conversion to integer types");
347+
if (!functions::stringCore::isAscii(
348+
inputRowValue.data(), inputRowValue.size())) {
349+
VELOX_USER_FAIL(
350+
"Unicode characters are not supported for conversion to integer types");
351+
}
351352
}
352353
}
353354
}

0 commit comments

Comments
 (0)