Skip to content

Commit

Permalink
fix(fuzzer): Mark UUID type as unsuppported input type in PrestoQuery…
Browse files Browse the repository at this point in the history
…Runner

Summary:

Mark UUID type as unsupported input type in Presto because Presto
doesn't allow creating HIVE columns of this type and requires constant
literals of these types to be valid string.

This follows a similar fix for IPADDRESS and IPPREFIX from facebookincubator#11820.
  • Loading branch information
BryanCutler committed Dec 14, 2024
1 parent bddddf8 commit 205f495
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions velox/exec/fuzzer/PrestoQueryRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "velox/functions/prestosql/types/IPAddressType.h"
#include "velox/functions/prestosql/types/IPPrefixType.h"
#include "velox/functions/prestosql/types/JsonType.h"
#include "velox/functions/prestosql/types/UuidType.h"
#include "velox/serializers/PrestoSerializer.h"
#include "velox/type/parser/TypeParser.h"

Expand Down Expand Up @@ -426,18 +427,20 @@ bool PrestoQueryRunner::isConstantExprSupported(
const core::TypedExprPtr& expr) {
if (std::dynamic_pointer_cast<const core::ConstantTypedExpr>(expr)) {
// TODO: support constant literals of these types. Complex-typed constant
// literals require support of converting them to SQL. Json, Ipaddress, and
// Ipprefix can be enabled after we're able to generate valid input values,
// because when these types are used as the type of a constant literal in
// SQL, Presto implicitly invoke json_parse(), cast(x as Ipaddress), and
// cast(x as Ipprefix) on it, which makes the behavior of Presto different
// from Velox. Timestamp constant literals require further investigation to
// ensure Presto uses the same timezone as Velox. Interval type cannot be
// used as the type of constant literals in Presto SQL.
// literals require support of converting them to SQL. Json, Ipaddress,
// Ipprefix, and Uuid can be enabled after we're able to generate valid
// input values, because when these types are used as the type of a constant
// literal in SQL, Presto implicitly invokes json_parse(),
// cast(x as Ipaddress), cast(x as Ipprefix) and cast(x as uuid) on it,
// which makes the behavior of Presto different from Velox. Timestamp
// constant literals require further investigation to ensure Presto uses the
// same timezone as Velox. Interval type cannot be used as the type of
// constant literals in Presto SQL.
auto& type = expr->type();
return type->isPrimitiveType() && !type->isTimestamp() &&
!isJsonType(type) && !type->isIntervalDayTime() &&
!isIPAddressType(type) && !isIPPrefixType(type);
!isIPAddressType(type) && !isIPPrefixType(type) &&
!isUuidType(type);
}
return true;
}
Expand All @@ -448,16 +451,17 @@ bool PrestoQueryRunner::isSupported(const exec::FunctionSignature& signature) {
// cast-to or constant literals. Hyperloglog can only be casted from varbinary
// and cannot be used as the type of constant literals. Interval year to month
// can only be casted from NULL and cannot be used as the type of constant
// literals. Json, Ipaddress, and Ipprefix require special handling, because
// Presto requires literals of these types to be valid, and doesn't allow
// creating HIVE columns of these types.
// literals. Json, Ipaddress, Ipprefix, and UUID require special handling,
// because Presto requires literals of these types to be valid, and doesn't
// allow creating HIVE columns of these types.
return !(
usesTypeName(signature, "interval year to month") ||
usesTypeName(signature, "hugeint") ||
usesTypeName(signature, "hyperloglog") ||
usesInputTypeName(signature, "json") ||
usesInputTypeName(signature, "ipaddress") ||
usesInputTypeName(signature, "ipprefix"));
usesInputTypeName(signature, "ipprefix") ||
usesInputTypeName(signature, "uuid"));
}

std::optional<std::string> PrestoQueryRunner::toSql(
Expand Down

0 comments on commit 205f495

Please sign in to comment.