Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package org.apache.parquet.crypto;

import static org.junit.Assert.assertArrayEquals;
import static org.assertj.core.api.Assertions.assertThat;

import org.apache.hadoop.conf.Configuration;
import org.junit.Test;
Expand All @@ -36,12 +36,10 @@ public void testLoadDecPropertiesFactory() {
FileDecryptionProperties decryptionProperties =
decryptionPropertiesFactory.getFileDecryptionProperties(conf, null);

assertArrayEquals(decryptionProperties.getFooterKey(), SampleDecryptionPropertiesFactory.FOOTER_KEY);
assertArrayEquals(
decryptionProperties.getColumnKey(SampleDecryptionPropertiesFactory.COL1),
SampleDecryptionPropertiesFactory.COL1_KEY);
assertArrayEquals(
decryptionProperties.getColumnKey(SampleDecryptionPropertiesFactory.COL2),
SampleDecryptionPropertiesFactory.COL2_KEY);
assertThat(decryptionProperties.getFooterKey()).isEqualTo(SampleDecryptionPropertiesFactory.FOOTER_KEY);
assertThat(decryptionProperties.getColumnKey(SampleDecryptionPropertiesFactory.COL1))
.isEqualTo(SampleDecryptionPropertiesFactory.COL1_KEY);
assertThat(decryptionProperties.getColumnKey(SampleDecryptionPropertiesFactory.COL2))
.isEqualTo(SampleDecryptionPropertiesFactory.COL2_KEY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@

package org.apache.parquet.crypto;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

import org.apache.hadoop.conf.Configuration;
import org.apache.parquet.conf.ParquetConfiguration;
Expand All @@ -40,13 +39,11 @@ public void testLoadEncPropertiesFactory() {
FileEncryptionProperties encryptionProperties =
encryptionPropertiesFactory.getFileEncryptionProperties(conf, null, null);

assertArrayEquals(encryptionProperties.getFooterKey(), SampleEncryptionPropertiesFactory.FOOTER_KEY);
assertEquals(
encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL1),
SampleEncryptionPropertiesFactory.COL1_ENCR_PROPERTIES);
assertEquals(
encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL2),
SampleEncryptionPropertiesFactory.COL2_ENCR_PROPERTIES);
assertThat(encryptionProperties.getFooterKey()).isEqualTo(SampleEncryptionPropertiesFactory.FOOTER_KEY);
assertThat(encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL1))
.isEqualTo(SampleEncryptionPropertiesFactory.COL1_ENCR_PROPERTIES);
assertThat(encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL2))
.isEqualTo(SampleEncryptionPropertiesFactory.COL2_ENCR_PROPERTIES);
}

@Test
Expand All @@ -60,12 +57,10 @@ public void testLoadEncPropertiesFactoryParquetConfiguration() {
FileEncryptionProperties encryptionProperties = encryptionPropertiesFactory.getFileEncryptionProperties(
ConfigurationUtil.createHadoopConfiguration(conf), null, null);

assertArrayEquals(encryptionProperties.getFooterKey(), SampleEncryptionPropertiesFactory.FOOTER_KEY);
assertEquals(
encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL1),
SampleEncryptionPropertiesFactory.COL1_ENCR_PROPERTIES);
assertEquals(
encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL2),
SampleEncryptionPropertiesFactory.COL2_ENCR_PROPERTIES);
assertThat(encryptionProperties.getFooterKey()).isEqualTo(SampleEncryptionPropertiesFactory.FOOTER_KEY);
assertThat(encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL1))
.isEqualTo(SampleEncryptionPropertiesFactory.COL1_ENCR_PROPERTIES);
assertThat(encryptionProperties.getColumnProperties(SampleEncryptionPropertiesFactory.COL2))
.isEqualTo(SampleEncryptionPropertiesFactory.COL2_ENCR_PROPERTIES);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@
import static org.apache.parquet.schema.Type.Repetition.OPTIONAL;
import static org.apache.parquet.schema.Type.Repetition.REPEATED;
import static org.apache.parquet.schema.Type.Repetition.REQUIRED;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -172,14 +171,14 @@ private void decryptParquetFileAndValid(String file, Configuration conf) throws
.build();
for (int i = 0; i < numRecord; i++) {
Group group = reader.read();
assertEquals(testData.get("Name")[i], group.getBinary("Name", 0).toStringUsingUTF8());
assertEquals(testData.get("Age")[i], group.getLong("Age", 0));
assertThat(group.getBinary("Name", 0).toStringUsingUTF8()).isEqualTo(testData.get("Name")[i]);
assertThat(group.getLong("Age", 0)).isEqualTo(testData.get("Age")[i]);

Group subGroup = group.getGroup("WebLinks", 0);
assertArrayEquals(
subGroup.getBinary("LinkedIn", 0).getBytes(), ((String) testData.get("LinkedIn")[i]).getBytes());
assertArrayEquals(
subGroup.getBinary("Twitter", 0).getBytes(), ((String) testData.get("Twitter")[i]).getBytes());
assertThat(((String) testData.get("LinkedIn")[i]).getBytes())
.isEqualTo(subGroup.getBinary("LinkedIn", 0).getBytes());
assertThat(((String) testData.get("Twitter")[i]).getBytes())
.isEqualTo(subGroup.getBinary("Twitter", 0).getBytes());
}
reader.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.parquet.encodings;

import static junit.framework.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -555,12 +555,11 @@ public PageValuesValidator(int rowGroupID, int pageID, List<?> expectedValues) {
}

public void validateNextValue(Object value) {
assertEquals(
String.format(
assertThat(value)
.as(String.format(
"Value from page is different than expected, ROW_GROUP_ID=%d PAGE_ID=%d VALUE_POS=%d",
rowGroupID, pageID, currentPos),
expectedValues.get(currentPos++),
value);
rowGroupID, pageID, currentPos))
.isEqualTo(expectedValues.get(currentPos++));
}

public static void validateValuesForPage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import static org.apache.parquet.schema.OriginalType.UTF8;
import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.BINARY;
import static org.apache.parquet.schema.PrimitiveType.PrimitiveTypeName.INT64;
import static org.junit.Assert.assertEquals;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -99,116 +99,110 @@ public void createDataFile() throws Exception {

@Test
public void testNormalFilter() throws Exception {
assertEquals(500, countFilteredRecords(path, lt(longColumn("id"), 500L)));
assertThat(countFilteredRecords(path, lt(longColumn("id"), 500L))).isEqualTo(500);
}

@Test
public void testSimpleMissingColumnFilter() throws Exception {
assertEquals(0, countFilteredRecords(path, lt(longColumn("missing"), 500L)));
assertThat(countFilteredRecords(path, lt(longColumn("missing"), 500L))).isEqualTo(0);
Set<Long> values = new HashSet<>();
values.add(1L);
values.add(2L);
values.add(5L);
assertEquals(0, countFilteredRecords(path, in(longColumn("missing"), values)));
assertEquals(1000, countFilteredRecords(path, notIn(longColumn("missing"), values)));
assertThat(countFilteredRecords(path, in(longColumn("missing"), values)))
.isEqualTo(0);
assertThat(countFilteredRecords(path, notIn(longColumn("missing"), values)))
.isEqualTo(1000);
}

@Test
public void testAndMissingColumnFilter() throws Exception {
// missing column filter is true
assertEquals(
500, countFilteredRecords(path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null))));
assertEquals(
500,
countFilteredRecords(
path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any")))));

assertEquals(
500, countFilteredRecords(path, and(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))));
assertEquals(
500,
countFilteredRecords(
path, and(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))));
assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null))))
.isEqualTo(500);
assertThat(countFilteredRecords(
path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any")))))
.isEqualTo(500);

assertThat(countFilteredRecords(path, and(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))))
.isEqualTo(500);
assertThat(countFilteredRecords(
path, and(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))))
.isEqualTo(500);

// missing column filter is false
assertEquals(
0,
countFilteredRecords(
path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any")))));
assertEquals(
0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null))));
assertEquals(
0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33))));
assertEquals(
0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33))));
assertEquals(
0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33))));
assertEquals(
0, countFilteredRecords(path, and(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33))));

assertEquals(
0,
countFilteredRecords(
path, and(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))));
assertEquals(
0, countFilteredRecords(path, and(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))));
assertEquals(
0, countFilteredRecords(path, and(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertEquals(
0, countFilteredRecords(path, and(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertEquals(
0, countFilteredRecords(path, and(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertEquals(
0, countFilteredRecords(path, and(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertThat(countFilteredRecords(
path, and(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any")))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33))))
.isEqualTo(0);

assertThat(countFilteredRecords(
path, and(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(0);
assertThat(countFilteredRecords(path, and(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(0);
}

@Test
public void testOrMissingColumnFilter() throws Exception {
// missing column filter is false
assertEquals(
500,
countFilteredRecords(
path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any")))));
assertEquals(
500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null))));
assertEquals(
500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33))));
assertEquals(
500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33))));
assertEquals(
500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33))));
assertEquals(
500, countFilteredRecords(path, or(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33))));

assertEquals(
500,
countFilteredRecords(
path, or(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))));
assertEquals(
500, countFilteredRecords(path, or(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))));
assertEquals(
500, countFilteredRecords(path, or(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertEquals(
500, countFilteredRecords(path, or(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertEquals(
500, countFilteredRecords(path, or(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertEquals(
500, countFilteredRecords(path, or(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))));
assertThat(countFilteredRecords(
path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), fromString("any")))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), null))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), lt(doubleColumn("missing"), 33.33))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), ltEq(doubleColumn("missing"), 33.33))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), gt(doubleColumn("missing"), 33.33))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), gtEq(doubleColumn("missing"), 33.33))))
.isEqualTo(500);

assertThat(countFilteredRecords(
path, or(eq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(notEq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(lt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(ltEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(gt(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(500);
assertThat(countFilteredRecords(path, or(gtEq(doubleColumn("missing"), 33.33), lt(longColumn("id"), 500L))))
.isEqualTo(500);

// missing column filter is false
assertEquals(
1000, countFilteredRecords(path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null))));
assertEquals(
1000,
countFilteredRecords(
path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any")))));

assertEquals(
1000, countFilteredRecords(path, or(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))));
assertEquals(
1000,
countFilteredRecords(
path, or(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))));
assertThat(countFilteredRecords(path, or(lt(longColumn("id"), 500L), eq(binaryColumn("missing"), null))))
.isEqualTo(1000);
assertThat(countFilteredRecords(
path, or(lt(longColumn("id"), 500L), notEq(binaryColumn("missing"), fromString("any")))))
.isEqualTo(1000);

assertThat(countFilteredRecords(path, or(eq(binaryColumn("missing"), null), lt(longColumn("id"), 500L))))
.isEqualTo(1000);
assertThat(countFilteredRecords(
path, or(notEq(binaryColumn("missing"), fromString("any")), lt(longColumn("id"), 500L))))
.isEqualTo(1000);
}

public static long countFilteredRecords(Path path, FilterPredicate pred) throws IOException {
Expand Down
Loading
Loading