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

Add coercion test for unpartitioned tables in hive #16119

Conversation

Praveen2112
Copy link
Member

@Praveen2112 Praveen2112 commented Feb 15, 2023

Description

Adds additional test coverage for coercion on un-partitioned tables in hive.

Release notes

(x) This is not user-visible or docs only and no release notes are required.

@cla-bot cla-bot bot added the cla-signed label Feb 15, 2023
@Praveen2112 Praveen2112 force-pushed the praveen/coercion_test_un_partitioned_table branch 2 times, most recently from 7724041 to 2ff3167 Compare February 23, 2023 13:00
@Praveen2112 Praveen2112 force-pushed the praveen/coercion_test_un_partitioned_table branch from 2ff3167 to f23b8bc Compare March 6, 2023 12:59
@Praveen2112 Praveen2112 marked this pull request as ready for review March 6, 2023 13:57
@findepi
Copy link
Member

findepi commented Mar 6, 2023

@ebyhr does this relate to yours #15938 ?

@Praveen2112
Copy link
Member Author

It kind of add partial test coverage to #15938 - only for ORC as of now.

@Praveen2112 Praveen2112 force-pushed the praveen/coercion_test_un_partitioned_table branch 2 times, most recently from c6048db to 35b38d9 Compare March 7, 2023 07:39
Comment on lines +118 to +120
if (expectedExceptionsWithTrinoContext().isEmpty()) {
assertEquals(ImmutableSet.copyOf(prestoReadColumns), expectedPrestoResults.keySet());
Copy link
Member

Choose a reason for hiding this comment

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

why assertion became conditional?

Copy link
Member Author

Choose a reason for hiding this comment

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

In case of unpartitioned tables we might not support all the column coercion as of now so we avoid the assertion when Trino throws some sort of exception.

Copy link
Member

Choose a reason for hiding this comment

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

add a code comment then

import static java.lang.String.format;
import static java.util.Locale.ENGLISH;

public class TestHiveCoercionOnUnPartitionedTable
Copy link
Member

Choose a reason for hiding this comment

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

UnPartitioned is one word

}
}

@Requires(OrcRequirements.class)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think Requirements Providers gives us any benefit, especially for mutable tables which aren't reused.
Plain old direct create table in a test would be better.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we can remove the Requirements Provider as a follow up as it would be common for both partitioned and unpartitioned tables.

Set<String> unsupportedColumns = expectedExceptions.keySet().stream()
.filter(context -> context.hiveVersion().orElseThrow().equals(hiveVersion) && tableName.contains(context.format()))
Copy link
Member

Choose a reason for hiding this comment

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

why removed?

Copy link
Member Author

Choose a reason for hiding this comment

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

For Trino side failures we don't need check on hive version right ?

Copy link
Member

Choose a reason for hiding this comment

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

unless the failure is related to what hive version did modify the version

anyway, why are you changing this line to first add .orElseThrow() and then to remove the condition if all you need is remove the condition?

Copy link
Member Author

Choose a reason for hiding this comment

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

With the latest change by squashing the commits - this changeset got disappeared.

- varchar is also a primitive
- tailing/trailing
@Praveen2112 Praveen2112 force-pushed the praveen/coercion_test_un_partitioned_table branch 2 times, most recently from aec09cc to fd20512 Compare March 7, 2023 12:48
@Praveen2112
Copy link
Member Author

@findepi AC

@findepi
Copy link
Member

findepi commented Mar 7, 2023

@Praveen2112 didn't re-review, but i see the build is failin

@Praveen2112 Praveen2112 force-pushed the praveen/coercion_test_un_partitioned_table branch from fd20512 to e08a8dc Compare March 9, 2023 07:19
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 % findepi's comments

@Praveen2112 Praveen2112 force-pushed the praveen/coercion_test_un_partitioned_table branch from e08a8dc to 3c863f5 Compare March 9, 2023 09:04
@@ -881,11 +881,11 @@ private static List<List<?>> extract(List<TrinoArray> arrays)

public static class ColumnContext
{
private final String hiveVersion;
private final Optional<String> hiveVersion;
Copy link
Member

Choose a reason for hiding this comment

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

Make version optional in ColumnContext

can this commit include some description on why?
(sorry, i failed to infer this myself)

Comment on lines +118 to +120
if (expectedExceptionsWithTrinoContext().isEmpty()) {
assertEquals(ImmutableSet.copyOf(prestoReadColumns), expectedPrestoResults.keySet());
Copy link
Member

Choose a reason for hiding this comment

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

add a code comment then

Set<String> unsupportedColumns = expectedExceptions.keySet().stream()
.filter(context -> context.hiveVersion().orElseThrow().equals(hiveVersion) && tableName.contains(context.format()))
Copy link
Member

Choose a reason for hiding this comment

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

unless the failure is related to what hive version did modify the version

anyway, why are you changing this line to first add .orElseThrow() and then to remove the condition if all you need is remove the condition?

Comment on lines 74 to 75
STORED AS
""" + fileFormat);
Copy link
Member

Choose a reason for hiding this comment

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

redundant line break between STORED AS and ORC

It allows us to re-use `ColumnContext` in scenarios which are independent
of hive version.
@Praveen2112 Praveen2112 force-pushed the praveen/coercion_test_un_partitioned_table branch from 3c863f5 to f454737 Compare March 10, 2023 06:59
@Praveen2112
Copy link
Member Author

@findepi AC

@findepi
Copy link
Member

findepi commented Mar 10, 2023

LGTM

@Praveen2112 Praveen2112 merged commit 4bfa7b6 into trinodb:master Mar 10, 2023
@github-actions github-actions bot added this to the 411 milestone Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants