Skip to content
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

Merged
merged 2 commits into from
Mar 21, 2023

Conversation

Praveen2112
Copy link
Member

@Praveen2112 Praveen2112 commented Mar 7, 2023

Description

Add support for coercing from

  • char to bigger char
  • char to smaller char

Additional context and related issues

Similar to #5530

Release notes

(x) Release notes are required, with the following suggested text:

## Hive Connector Changes
* Support coercion between `char` types of different lengths.

@cla-bot cla-bot bot added the cla-signed label Mar 7, 2023
@Praveen2112 Praveen2112 force-pushed the praveen/char_coercion_test branch 3 times, most recently from 620f356 to 5c8eb0b Compare March 13, 2023 08:42
@github-actions github-actions bot added the hive Hive connector label Mar 13, 2023
@Praveen2112 Praveen2112 marked this pull request as ready for review March 13, 2023 08:46
@Praveen2112 Praveen2112 changed the title Additional test coverage for char coercion Support coercing char types in hive Mar 13, 2023
@Praveen2112 Praveen2112 changed the title Support coercing char types in hive Support coercing char types of different lengths in hive Mar 13, 2023
@@ -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)
Copy link
Member

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.

Suggested change
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) {
Copy link
Member

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) {.

@Praveen2112
Copy link
Member Author

@ebyhr AC

Copy link
Member

@skrzypo987 skrzypo987 left a 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(
Copy link
Member

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

@Praveen2112 Praveen2112 force-pushed the praveen/char_coercion_test branch from a04a5c9 to 47fbca7 Compare March 17, 2023 13:45
@Praveen2112
Copy link
Member Author

@skrzypo987 AC

@Praveen2112 Praveen2112 force-pushed the praveen/char_coercion_test branch 3 times, most recently from db48677 to ecc9895 Compare March 21, 2023 10:46
@Praveen2112 Praveen2112 force-pushed the praveen/char_coercion_test branch from ecc9895 to 8542ea2 Compare March 21, 2023 13:57
@Praveen2112 Praveen2112 merged commit 57ace68 into trinodb:master Mar 21, 2023
@github-actions github-actions bot added this to the 411 milestone Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed hive Hive connector
Development

Successfully merging this pull request may close these issues.

4 participants