Skip to content

Commit

Permalink
Remove TestingHiveStorageFormat
Browse files Browse the repository at this point in the history
  • Loading branch information
TishyaaChaudhry authored and tdcmeehan committed Apr 22, 2024
1 parent ef3d47a commit 6d052a3
Showing 1 changed file with 9 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1237,9 +1237,9 @@ public void testCreateEmptyUnpartitionedBucketedTableNoStaging()
@Test
public void testCreateEmptyBucketedPartition()
{
for (TestingHiveStorageFormat storageFormat : getAllTestingHiveStorageFormat()) {
testCreateEmptyBucketedPartition(storageFormat.getFormat(), false);
testCreateEmptyBucketedPartition(storageFormat.getFormat(), true);
for (HiveStorageFormat storageFormat : getSupportedHiveStorageFormats()) {
testCreateEmptyBucketedPartition(storageFormat, false);
testCreateEmptyBucketedPartition(storageFormat, true);
}
}

Expand Down Expand Up @@ -6713,19 +6713,19 @@ private static ConnectorSession getConnectorSession(Session session)

private void testWithAllStorageFormats(BiConsumer<Session, HiveStorageFormat> test)
{
for (TestingHiveStorageFormat storageFormat : getAllTestingHiveStorageFormat()) {
testWithStorageFormat(storageFormat, test);
Session session = getSession();
for (HiveStorageFormat storageFormat : getSupportedHiveStorageFormats()) {
testWithStorageFormat(session, storageFormat, test);
}
}

private static void testWithStorageFormat(TestingHiveStorageFormat storageFormat, BiConsumer<Session, HiveStorageFormat> test)
private static void testWithStorageFormat(Session session, HiveStorageFormat storageFormat, BiConsumer<Session, HiveStorageFormat> test)
{
Session session = storageFormat.getSession();
try {
test.accept(session, storageFormat.getFormat());
test.accept(session, storageFormat);
}
catch (Exception | AssertionError e) {
fail(format("Failure for format %s with properties %s", storageFormat.getFormat(), session.getConnectorProperties()), e);
fail(format("Failure for format %s with properties %s", storageFormat, session.getConnectorProperties()), e);
}
}

Expand All @@ -6736,34 +6736,4 @@ protected List<HiveStorageFormat> getSupportedHiveStorageFormats()
.filter(format -> format != HiveStorageFormat.CSV && format != HiveStorageFormat.ALPHA)
.collect(toImmutableList());
}

private List<TestingHiveStorageFormat> getAllTestingHiveStorageFormat()
{
Session session = getSession();
return getSupportedHiveStorageFormats().stream()
.map(format -> new TestingHiveStorageFormat(session, format))
.collect(toImmutableList());
}

private static class TestingHiveStorageFormat
{
private final Session session;
private final HiveStorageFormat format;

TestingHiveStorageFormat(Session session, HiveStorageFormat format)
{
this.session = requireNonNull(session, "session is null");
this.format = requireNonNull(format, "format is null");
}

public Session getSession()
{
return session;
}

public HiveStorageFormat getFormat()
{
return format;
}
}
}

0 comments on commit 6d052a3

Please sign in to comment.