Skip to content

Commit 6a51bc1

Browse files
authored
feat: Add primitive type with name to UserDefinedType (#26460)
Summary: Add a third possible type of UserDefinedType to allow more flexibility when returning a UserDefinedType from AbstractSqlInvokedFunctionNamespaceManager Differential Revision: D85103808 ``` == NO RELEASE NOTE == ```
1 parent ebe6a3f commit 6a51bc1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

presto-common/src/main/java/com/facebook/presto/common/type/UserDefinedType.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import static java.util.Objects.requireNonNull;
1919

2020
/**
21-
* UserDefinedType represents an enum type, or a distinct type.
21+
* UserDefinedType represents an enum type, a distinct type, or a primitive type with a name.
2222
* Type definition is defined by user and is extracted at runtime.
2323
*/
2424
public class UserDefinedType
@@ -46,4 +46,14 @@ public boolean isDistinctType()
4646
{
4747
return representation.isDistinctType();
4848
}
49+
50+
public boolean isEnumType()
51+
{
52+
return representation.isEnum();
53+
}
54+
55+
public boolean isPrimitiveType()
56+
{
57+
return !representation.isDistinctType() && representation.getTypeSignatureBase().hasStandardType();
58+
}
4959
}

presto-main-base/src/main/java/com/facebook/presto/metadata/FunctionAndTypeManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ protected Type getType(UserDefinedType userDefinedType)
861861
if (userDefinedType.isDistinctType()) {
862862
return getDistinctType(userDefinedType.getPhysicalTypeSignature().getParameters().get(0).getDistinctTypeInfo());
863863
}
864-
// Enum type
864+
// Enum type or primitive type with name
865865
return getType(new TypeSignature(userDefinedType));
866866
}
867867

0 commit comments

Comments
 (0)