Skip to content

Commit

Permalink
Fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
lschetanrao committed Dec 7, 2023
1 parent db24008 commit bf24760
Show file tree
Hide file tree
Showing 16 changed files with 95 additions and 67 deletions.
24 changes: 15 additions & 9 deletions mr/src/test/java/org/apache/iceberg/mr/TestCatalogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ public class TestCatalogs {

private Configuration conf;

@TempDir
public Path temp;
@TempDir public Path temp;

@BeforeEach
public void before() {
Expand Down Expand Up @@ -92,7 +91,8 @@ public void testLoadTableFromCatalog() throws IOException {

conf.set(InputFormatConfig.TABLE_IDENTIFIER, "table");

Assertions.assertThat(Catalogs.loadTable(conf).location()).isEqualTo(hadoopCatalogTable.location());
Assertions.assertThat(Catalogs.loadTable(conf).location())
.isEqualTo(hadoopCatalogTable.location());
}

@Test
Expand Down Expand Up @@ -124,8 +124,10 @@ public void testCreateDropTableToLocation() throws IOException {
Table table = tables.load(properties.getProperty("location"));

Assertions.assertThat(table.location()).isEqualTo(properties.getProperty("location"));
Assertions.assertThat(SchemaParser.toJson(table.schema())).isEqualTo(SchemaParser.toJson(SCHEMA));
Assertions.assertThat(PartitionSpecParser.toJson(table.spec())).isEqualTo(PartitionSpecParser.toJson(SPEC));
Assertions.assertThat(SchemaParser.toJson(table.schema()))
.isEqualTo(SchemaParser.toJson(SCHEMA));
Assertions.assertThat(PartitionSpecParser.toJson(table.spec()))
.isEqualTo(PartitionSpecParser.toJson(SPEC));
assertThat(table.properties()).containsEntry("dummy", "test");

Assertions.assertThatThrownBy(() -> Catalogs.dropTable(conf, new Properties()))
Expand Down Expand Up @@ -176,8 +178,10 @@ public void testCreateDropTableToCatalog() throws IOException {
HadoopCatalog catalog = new CustomHadoopCatalog(conf, warehouseLocation);
Table table = catalog.loadTable(identifier);

Assertions.assertThat(SchemaParser.toJson(table.schema())).isEqualTo(SchemaParser.toJson(SCHEMA));
Assertions.assertThat(PartitionSpecParser.toJson(table.spec())).isEqualTo(PartitionSpecParser.toJson(SPEC));
Assertions.assertThat(SchemaParser.toJson(table.schema()))
.isEqualTo(SchemaParser.toJson(SCHEMA));
Assertions.assertThat(PartitionSpecParser.toJson(table.spec()))
.isEqualTo(PartitionSpecParser.toJson(SPEC));
assertThat(table.properties()).containsEntry("dummy", "test");

Assertions.assertThatThrownBy(() -> Catalogs.dropTable(conf, new Properties()))
Expand Down Expand Up @@ -233,7 +237,7 @@ public void testLoadCatalogHadoop() {
Assertions.assertThat(hadoopCatalog.isPresent()).isTrue();
Assertions.assertThat(hadoopCatalog.get()).isInstanceOf(HadoopCatalog.class);
Assertions.assertThat(hadoopCatalog.get().toString())
.isEqualTo("HadoopCatalog{name=barCatalog, location=/tmp/mylocation}");
.isEqualTo("HadoopCatalog{name=barCatalog, location=/tmp/mylocation}");
Properties properties = new Properties();
properties.put(InputFormatConfig.CATALOG_NAME, catalogName);
Assertions.assertThat(Catalogs.hiveCatalog(conf, properties)).isFalse();
Expand All @@ -259,7 +263,9 @@ public void testLoadCatalogCustom() {

@Test
public void testLoadCatalogLocation() {
Assertions.assertThat(Catalogs.loadCatalog(conf, Catalogs.ICEBERG_HADOOP_TABLE_NAME).isPresent()).isFalse();
Assertions.assertThat(
Catalogs.loadCatalog(conf, Catalogs.ICEBERG_HADOOP_TABLE_NAME).isPresent())
.isFalse();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public static void assertEquals(Record expected, Record actual) {
if (expected.get(i) instanceof OffsetDateTime) {
// For OffsetDateTime we just compare the actual instant
Assertions.assertThat(((OffsetDateTime) actual.get(i)).toInstant())
.isEqualTo(((OffsetDateTime) expected.get(i)).toInstant());
.isEqualTo(((OffsetDateTime) expected.get(i)).toInstant());
} else if (expected.get(i) instanceof byte[]) {
Assertions.assertThat((byte[]) actual.get(i)).isEqualTo((byte[]) expected.get(i));
} else {
Expand Down Expand Up @@ -289,7 +289,8 @@ public static void validateFiles(Table table, Configuration conf, JobID jobId, i

Assertions.assertThat(dataFiles.size()).isEqualTo(dataFileNum);
Assertions.assertThat(
new File(HiveIcebergOutputCommitter.generateJobLocation(table.location(), conf, jobId))
.exists()).isFalse();
new File(HiveIcebergOutputCommitter.generateJobLocation(table.location(), conf, jobId))
.exists())
.isFalse();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@ public void testListDeserialize() {

@Test
public void testDeserializeEverySupportedType() {
Assumptions.assumeFalse(HiveVersion.min(HiveVersion.HIVE_3),
"No test yet for Hive3 (Date/Timestamp creation)");
Assumptions.assumeFalse(
HiveVersion.min(HiveVersion.HIVE_3), "No test yet for Hive3 (Date/Timestamp creation)");

Deserializer deserializer =
new Deserializer.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ public void testNotEqualsOperand() {

Assertions.assertThat(expected.op()).isEqualTo(actual.op());
Assertions.assertThat(expected.child().op()).isEqualTo(actual.child().op());
Assertions.assertThat(childExpressionExpected.ref().name()).isEqualTo(childExpressionActual.ref().name());
Assertions.assertThat(childExpressionExpected.literal()).isEqualTo(childExpressionActual.literal());
Assertions.assertThat(childExpressionExpected.ref().name())
.isEqualTo(childExpressionActual.ref().name());
Assertions.assertThat(childExpressionExpected.literal())
.isEqualTo(childExpressionActual.literal());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public class TestHiveIcebergOutputCommitter {
private static final PartitionSpec PARTITIONED_SPEC =
PartitionSpec.builderFor(CUSTOMER_SCHEMA).bucket("customer_id", 3).build();

@TempDir
public Path temp;
@TempDir public Path temp;

@Test
public void testNeedsTaskCommit() {
Expand All @@ -92,17 +91,20 @@ public void testNeedsTaskCommit() {

// Map only job should commit map tasks
Assertions.assertThat(
committer.needsTaskCommit(new TaskAttemptContextImpl(mapOnlyJobConf, MAP_TASK_ID))).isTrue();
committer.needsTaskCommit(new TaskAttemptContextImpl(mapOnlyJobConf, MAP_TASK_ID)))
.isTrue();

JobConf mapReduceJobConf = new JobConf();
mapReduceJobConf.setNumMapTasks(10);
mapReduceJobConf.setNumReduceTasks(10);

// MapReduce job should not commit map tasks, but should commit reduce tasks
Assertions.assertThat(
committer.needsTaskCommit(new TaskAttemptContextImpl(mapReduceJobConf, MAP_TASK_ID))).isFalse();
committer.needsTaskCommit(new TaskAttemptContextImpl(mapReduceJobConf, MAP_TASK_ID)))
.isFalse();
Assertions.assertThat(
committer.needsTaskCommit(new TaskAttemptContextImpl(mapReduceJobConf, REDUCE_TASK_ID))).isTrue();
committer.needsTaskCommit(new TaskAttemptContextImpl(mapReduceJobConf, REDUCE_TASK_ID)))
.isTrue();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ public class TestHiveIcebergSerDe {
private static final Schema schema =
new Schema(required(1, "string_field", Types.StringType.get()));

@TempDir
public Path tmp;
@TempDir public Path tmp;

@Test
public void testInitialize() throws IOException, SerDeException {
Expand All @@ -64,7 +63,8 @@ public void testInitialize() throws IOException, SerDeException {
HiveIcebergSerDe serDe = new HiveIcebergSerDe();
serDe.initialize(conf, properties);

Assertions.assertThat(serDe.getObjectInspector()).isEqualTo(IcebergObjectInspector.create(schema));
Assertions.assertThat(serDe.getObjectInspector())
.isEqualTo(IcebergObjectInspector.create(schema));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testIcebergByteBufferObjectInspector() {

Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE);
Assertions.assertThat(oi.getPrimitiveCategory())
.isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.BINARY);
.isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.BINARY);

Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.binaryTypeInfo);
Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.binaryTypeInfo.getTypeName());
Expand All @@ -51,15 +51,18 @@ public void testIcebergByteBufferObjectInspector() {

ByteBuffer buffer = ByteBuffer.wrap(bytes);
Assertions.assertThat(oi.getPrimitiveJavaObject(buffer)).isEqualTo(bytes);
Assertions.assertThat(oi.getPrimitiveWritableObject(buffer)).isEqualTo(new BytesWritable(bytes));
Assertions.assertThat(oi.getPrimitiveWritableObject(buffer))
.isEqualTo(new BytesWritable(bytes));

ByteBuffer slice = ByteBuffer.wrap(bytes, 1, 2).slice();
Assertions.assertThat(oi.getPrimitiveJavaObject(slice)).isEqualTo(new byte[] {1, 2});
Assertions.assertThat(oi.getPrimitiveWritableObject(slice)).isEqualTo(new BytesWritable(new byte[] {1, 2}));
Assertions.assertThat(oi.getPrimitiveWritableObject(slice))
.isEqualTo(new BytesWritable(new byte[] {1, 2}));

slice.position(1);
Assertions.assertThat(oi.getPrimitiveJavaObject(slice)).isEqualTo(new byte[] {2});
Assertions.assertThat(oi.getPrimitiveWritableObject(slice)).isEqualTo(new BytesWritable(new byte[] {2}));
Assertions.assertThat(oi.getPrimitiveWritableObject(slice))
.isEqualTo(new BytesWritable(new byte[] {2}));

byte[] copy = (byte[]) oi.copyObject(bytes);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void testIcebergDateObjectInspector() {
DateObjectInspector oi = IcebergDateObjectInspector.get();

Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE);
Assertions.assertThat(oi.getPrimitiveCategory()).isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.DATE);
Assertions.assertThat(oi.getPrimitiveCategory())
.isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.DATE);

Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.dateTypeInfo);
Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.dateTypeInfo.getTypeName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ public void testIcebergDecimalObjectInspector() {
HiveDecimalObjectInspector oi = IcebergDecimalObjectInspector.get(38, 18);

Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE);
Assertions.assertThat(oi.getPrimitiveCategory()).isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.DECIMAL);
Assertions.assertThat(oi.getPrimitiveCategory())
.isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.DECIMAL);

Assertions.assertThat(oi.getTypeInfo()).isEqualTo(new DecimalTypeInfo(38, 18));
Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.decimalTypeInfo.getTypeName(), oi.getTypeName());
Assertions.assertThat(oi.getTypeName())
.isEqualTo(TypeInfoFactory.decimalTypeInfo.getTypeName(), oi.getTypeName());

Assertions.assertThat(oi.precision()).isEqualTo(38);
Assertions.assertThat(oi.scale()).isEqualTo(18);
Expand All @@ -64,7 +66,7 @@ public void testIcebergDecimalObjectInspector() {

Assertions.assertThat(oi.getPrimitiveJavaObject(BigDecimal.ONE)).isEqualTo(one);
Assertions.assertThat(oi.getPrimitiveWritableObject(BigDecimal.ONE))
.isEqualTo(new HiveDecimalWritable(one));
.isEqualTo(new HiveDecimalWritable(one));

HiveDecimal copy = (HiveDecimal) oi.copyObject(one);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void testIcebergFixedObjectInspector() {

Assertions.assertThat(oi.getCategory()).isEqualTo(ObjectInspector.Category.PRIMITIVE);
Assertions.assertThat(oi.getPrimitiveCategory())
.isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.BINARY);
.isEqualTo(PrimitiveObjectInspector.PrimitiveCategory.BINARY);

Assertions.assertThat(oi.getTypeInfo()).isEqualTo(TypeInfoFactory.binaryTypeInfo);
Assertions.assertThat(oi.getTypeName()).isEqualTo(TypeInfoFactory.binaryTypeInfo.getTypeName());
Expand Down
Loading

0 comments on commit bf24760

Please sign in to comment.