From 205f495801bb07424a5639e056f87b0184ad7491 Mon Sep 17 00:00:00 2001 From: Bryan Cutler Date: Fri, 13 Dec 2024 17:42:43 -0800 Subject: [PATCH] fix(fuzzer): Mark UUID type as unsuppported input type in PrestoQueryRunner 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 #11820. --- velox/exec/fuzzer/PrestoQueryRunner.cpp | 30 ++++++++++++++----------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/velox/exec/fuzzer/PrestoQueryRunner.cpp b/velox/exec/fuzzer/PrestoQueryRunner.cpp index 37f31869541d..fe7c11593b0a 100644 --- a/velox/exec/fuzzer/PrestoQueryRunner.cpp +++ b/velox/exec/fuzzer/PrestoQueryRunner.cpp @@ -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" @@ -426,18 +427,20 @@ bool PrestoQueryRunner::isConstantExprSupported( const core::TypedExprPtr& expr) { if (std::dynamic_pointer_cast(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; } @@ -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 PrestoQueryRunner::toSql(