-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support coercing char types of different lengths in hive #16402
Support coercing char types of different lengths in hive #16402
Conversation
620f356
to
5c8eb0b
Compare
@@ -372,6 +380,13 @@ public static boolean narrowerThan(VarcharType first, VarcharType second) | |||
return first.getBoundedLength() < second.getBoundedLength(); | |||
} | |||
|
|||
public static boolean narrowerThan(CharType first, CharType second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We use "short" at least in io.trino.spi.type.Chars
class. No requested change as there's the existing narrowerThan
method.
public static boolean narrowerThan(CharType first, CharType second) | |
public static boolean shorterThan(CharType first, CharType second) |
@@ -84,6 +85,9 @@ private boolean canCoerce(HiveType fromHiveType, HiveType toHiveType, HiveTimest | |||
if (fromType instanceof DecimalType) { | |||
return toType instanceof DecimalType || toHiveType.equals(HIVE_FLOAT) || toHiveType.equals(HIVE_DOUBLE); | |||
} | |||
if (fromType instanceof CharType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Move to before if (toType instanceof VarcharType) {
.
5c8eb0b
to
a04a5c9
Compare
@ebyhr AC |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm % small comments
@@ -327,6 +334,12 @@ else if (getHiveVersionMajor() == 3 && isFormat.test("orc")) { | |||
.put("varchar_to_smaller_varchar", Arrays.asList( | |||
"ab", | |||
"\uD83D\uDCB0\uD83D\uDCB0")) | |||
.put("char_to_bigger_char", Arrays.asList( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if ImmutableList
is not available then use List.of()
. Arrays.asList
is not cool anymore
testing/trino-product-tests/src/main/java/io/trino/tests/product/hive/BaseTestHiveCoercion.java
Show resolved
Hide resolved
a04a5c9
to
47fbca7
Compare
@skrzypo987 AC |
db48677
to
ecc9895
Compare
For list with null values we still use Arrays#asList
ecc9895
to
8542ea2
Compare
Description
Add support for coercing from
Additional context and related issues
Similar to #5530
Release notes
(x) Release notes are required, with the following suggested text: