Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Feb 16, 2024
1 parent dadade0 commit ff45670
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions velox/expression/CastExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,10 @@ void CastExpr::applyPeeled(
fromType->asRow(),
toType);
break;
case TypeKind::UNKNOWN:
result =
BaseVector::createNullConstant(toType, rows.end(), context.pool());
break;
default: {
// Handle primitive type conversions.
VELOX_DYNAMIC_SCALAR_TYPE_DISPATCH(
Expand Down
27 changes: 27 additions & 0 deletions velox/expression/tests/CastExprTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,33 @@ TEST_F(CastExprTest, basics) {
{"1.888", "2.5", "3.6", "100.44", "-100.101", "1", "-2"});
}

TEST_F(CastExprTest, fromUnknownType) {
testCast<UnknownValue, int8_t>(
"tinyint", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, int16_t>(
"smallint", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, int32_t>(
"int", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, int64_t>(
"bigint", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, float>(
"float", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, double>(
"double", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, std::string>(
"string", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, bool>(
"boolean", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, Timestamp>(
"timestamp", {std::nullopt, std::nullopt}, {std::nullopt, std::nullopt});
testCast<UnknownValue, int32_t>(
"date",
{std::nullopt, std::nullopt},
{std::nullopt, std::nullopt},
UNKNOWN(),
DATE());
}

TEST_F(CastExprTest, realAndDoubleToString) {
setLegacyCast(false);
testCast<double, std::string>(
Expand Down

0 comments on commit ff45670

Please sign in to comment.