Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ private static Object fixValue(TypeSignature signature, Object value)
if (signature.isVarcharEnum()) {
return String.class.cast(value);
}
if (signature.isLongEnum()) {
if (value instanceof String) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would the value be string is the enum is long?

Copy link
Copy Markdown
Contributor Author

@daniel-ohayon daniel-ohayon Nov 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that happens because of JSON serialization – in JSON, keys are always strings (this is why we have a similar check a few lines below – line 138).

return Long.parseLong((String) value);
}
return ((Number) value).longValue();
}
switch (signature.getBase()) {
case BIGINT:
if (value instanceof String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public void testEnumLiterals()
"SELECT test.enum.testEnum.TEST, test.enum.testEnum.TEST2, test.enum.testEnum.TEST3, array[test.enum.testEnum.TEST4]",
singletonList(ImmutableList.of("\"}\"", "", " ", ImmutableList.of(")))\"\""))));

assertQueryResultUnordered(
"SELECT MAP(ARRAY[test.enum.mood.HAPPY], ARRAY[1])",
singletonList(ImmutableList.of(ImmutableMap.of(0L, 1))));

assertQueryFails("SELECT test.enum.mood.hello", ".*No key 'HELLO' in enum 'test.enum.mood'");
}

Expand Down