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 @@ -39,6 +39,7 @@
class BaseParquetReaderTest extends InitializedNullHandlingTest
{
ObjectWriter DEFAULT_JSON_WRITER = new ObjectMapper().writerWithDefaultPrettyPrinter();
protected final ObjectMapper objectMapper = new ObjectMapper();

InputEntityReader createReader(String parquetFile, InputRowSchema schema, JSONPathSpec flattenSpec)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,19 +94,16 @@ public void testBinaryAsString() throws IOException
+ " \"field\" : \"hey this is &é(-è_çà)=^$ù*! Ω^^\",\n"
+ " \"ts\" : 1471800234\n"
+ "}";
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));

Assert.assertEquals(objectMapper.readTree(expectedJson), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
final String expectedJsonBinary = "{\n"
+ " \"field\" : \"aGV5IHRoaXMgaXMgJsOpKC3DqF/Dp8OgKT1eJMO5KiEgzqleXg==\",\n"
+ " \"ts\" : 1471800234\n"
+ "}";
Assert.assertEquals(
expectedJsonBinary,
DEFAULT_JSON_WRITER.writeValueAsString(sampledAsBinary.get(0).getRawValues())
);
objectMapper.readTree(expectedJsonBinary),
objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampledAsBinary.get(0).getRawValues())));
}


@Test
public void testParquet1217() throws IOException
{
Expand Down Expand Up @@ -305,7 +302,7 @@ required group nestedIntsColumn (LIST) {
+ " } ]\n"
+ " }\n"
+ "}";
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(expectedJson), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -345,7 +342,6 @@ public void testOldRepeatedInt() throws IOException
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
}


@Test
public void testReadNestedArrayStruct() throws IOException
{
Expand Down Expand Up @@ -385,7 +381,7 @@ public void testReadNestedArrayStruct() throws IOException
+ " \"repeatedMessage\" : [ 3 ]\n"
+ " } ]\n"
+ "}";
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(expectedJson), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -435,6 +431,6 @@ public void testProtoStructWithArray() throws IOException
+ " \"someId\" : 9\n"
+ " }\n"
+ "}";
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(expectedJson), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void testFlat1NoFlattenSpec() throws IOException
flattenSpec
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(FLAT_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(FLAT_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -126,7 +126,7 @@ public void testFlat1Autodiscover() throws IOException
JSONPathSpec.DEFAULT
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(FLAT_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(FLAT_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -167,7 +167,7 @@ public void testFlat1Flatten() throws IOException
flattenSpec
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(FLAT_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(FLAT_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -204,9 +204,9 @@ public void testFlat1FlattenSelectListItem() throws IOException
schema,
flattenSpec
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);

Assert.assertEquals(FLAT_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(objectMapper.readTree(FLAT_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}


Expand Down Expand Up @@ -243,7 +243,7 @@ public void testNested1NoFlattenSpec() throws IOException
flattenSpec
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(NESTED_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(NESTED_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -276,7 +276,7 @@ public void testNested1Autodiscover() throws IOException
JSONPathSpec.DEFAULT
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(NESTED_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(NESTED_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -319,7 +319,7 @@ public void testNested1Flatten() throws IOException
flattenSpec
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(NESTED_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(NESTED_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down Expand Up @@ -360,7 +360,7 @@ public void testNested1FlattenSelectListItem() throws IOException
flattenSpec
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
Assert.assertEquals(NESTED_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(objectMapper.readTree(NESTED_JSON), objectMapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import org.apache.druid.data.input.ColumnsFilter;
import org.apache.druid.data.input.InputEntityReader;
import org.apache.druid.data.input.InputRow;
Expand All @@ -39,6 +40,7 @@
import org.junit.Test;

import java.io.IOException;
import java.util.HashSet;
import java.util.List;

public class NestedColumnParquetReaderTest extends BaseParquetReaderTest
Expand Down Expand Up @@ -218,7 +220,7 @@ public void testNestedColumnSchemalessNestedTestFile() throws IOException
);

List<InputRow> rows = readAllRows(reader);
Assert.assertEquals(ImmutableList.of("nestedData", "dim1", "metric1"), rows.get(0).getDimensions());
Assert.assertEquals(ImmutableSet.of("nestedData", "dim1", "metric1"), new HashSet<>(rows.get(0).getDimensions()));
Assert.assertEquals(FlattenSpecParquetInputTest.TS1, rows.get(0).getTimestamp().toString());
Assert.assertEquals(ImmutableList.of("d1v1"), rows.get(0).getDimension("dim1"));
Assert.assertEquals("d1v1", rows.get(0).getRaw("dim1"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.druid.data.input.parquet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import org.apache.druid.data.input.ColumnsFilter;
import org.apache.druid.data.input.InputEntityReader;
Expand Down Expand Up @@ -91,8 +92,9 @@ public void testDateHandling() throws IOException
+ " \"idx\" : 1,\n"
+ " \"date_as_date\" : 1497744000000\n"
+ "}";
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampledAsString.get(0).getRawValues()));
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampledAsDate.get(0).getRawValues()));
ObjectMapper mapper = new ObjectMapper();
Assert.assertEquals(mapper.readTree(expectedJson), mapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampledAsString.get(0).getRawValues())));
Assert.assertEquals(mapper.readTree(expectedJson), mapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampledAsDate.get(0).getRawValues())));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.druid.data.input.parquet;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableList;
import org.apache.druid.data.input.ColumnsFilter;
import org.apache.druid.data.input.InputEntityReader;
Expand All @@ -39,6 +40,8 @@
*/
public class WikiParquetReaderTest extends BaseParquetReaderTest
{
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();

@Test
public void testWiki() throws IOException
{
Expand Down Expand Up @@ -77,7 +80,7 @@ public void testWiki() throws IOException
+ " \"user\" : \"nuclear\",\n"
+ " \"timestamp\" : \"2013-08-31T01:02:33Z\"\n"
+ "}";
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(JSON_MAPPER.readTree(expectedJson), JSON_MAPPER.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}

@Test
Expand All @@ -96,6 +99,6 @@ public void testUint32Datatype() throws IOException
+ " \"foo\" : \"baz\",\n"
+ " \"time\" : 1678853101621\n"
+ "}";
Assert.assertEquals(expectedJson, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(JSON_MAPPER.readTree(expectedJson), JSON_MAPPER.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -1193,11 +1194,11 @@ public void testGetLockedIntervals()
Assert.assertEquals(2, lockedIntervals.size());

Assert.assertEquals(
Arrays.asList(
new HashSet<>(Arrays.asList(
Intervals.of("2017-01-01/2017-02-01"),
Intervals.of("2017-04-01/2017-05-01")
),
lockedIntervals.get(task1.getDataSource())
)),
new HashSet<>(lockedIntervals.get(task1.getDataSource()))
);

Assert.assertEquals(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,13 @@ protected ListenableFuture<Response> go(Request request) throws JsonProcessingEx
{
Assert.assertEquals("http://example.com/val1/val2", request.getUrl());
Assert.assertEquals(
StringUtils.format(
JSON_MAPPER.readTree(StringUtils.format(
"[%s,%s]\n",
JSON_MAPPER.writeValueAsString(events.get(0)),
JSON_MAPPER.writeValueAsString(events.get(1))
),
StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString()
)),
JSON_MAPPER.readTree(StandardCharsets.UTF_8.decode(request.getByteBufferData().slice()).toString())
);

return GoHandlers.immediateFuture(EmitterTest.okResponse());
}
}.times(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ private void smokeTest(NestedDataComplexColumn column) throws IOException
for (int i = 0; i < data.size(); i++) {
Map row = data.get(i);
Assert.assertEquals(
JSON_MAPPER.writeValueAsString(row),
JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawSelector.getObject()))
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(row)),
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawSelector.getObject())))
);

testPath(row, i, "v", vSelector, vDimSelector, vValueIndex, vPredicateIndex, vNulls, null);
Expand Down Expand Up @@ -539,8 +539,8 @@ private void smokeTestArrays(NestedDataComplexColumn column) throws IOException
while (offset.withinBounds()) {
Map row = arrayTestData.get(rowCounter);
Assert.assertEquals(
JSON_MAPPER.writeValueAsString(row),
JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawSelector.getObject()))
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(row)),
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawSelector.getObject())))
);

Object[] s = (Object[]) row.get("s");
Expand Down Expand Up @@ -595,8 +595,8 @@ private void smokeTestArrays(NestedDataComplexColumn column) throws IOException

Map row = arrayTestData.get(rowCounter);
Assert.assertEquals(
JSON_MAPPER.writeValueAsString(row),
JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawVector[i]))
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(row)),
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawVector[i])))
);
Object[] s = (Object[]) row.get("s");
Object[] l = (Object[]) row.get("l");
Expand Down Expand Up @@ -644,8 +644,8 @@ private void smokeTestArrays(NestedDataComplexColumn column) throws IOException
for (int i = 0; i < bitmapVectorOffset.getCurrentVectorSize(); i++, rowCounter += 2) {
Map row = arrayTestData.get(rowCounter);
Assert.assertEquals(
JSON_MAPPER.writeValueAsString(row),
JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawVector[i]))
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(row)),
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawVector[i])))
);
Object[] s = (Object[]) row.get("s");
Object[] l = (Object[]) row.get("l");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ private void smokeTest(NestedDataComplexColumn column) throws IOException
for (int i = 0; i < data.size(); i++) {
Map row = data.get(i);
Assert.assertEquals(
JSON_MAPPER.writeValueAsString(row),
JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawSelector.getObject()))
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(row)),
JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(StructuredData.unwrap(rawSelector.getObject())))
);
testPath(row, i, "v", vSelector, vDimSelector, vValueIndex, vPredicateIndex, vNulls, null);
testPath(row, i, "x", xSelector, xDimSelector, xValueIndex, xPredicateIndex, xNulls, ColumnType.LONG);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@

import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.HashSet;

public class ExpressionVirtualColumnTest extends InitializedNullHandlingTest
{
Expand Down Expand Up @@ -734,10 +735,10 @@ public void testLongSelectorOfTimeColumn()
@Test
public void testRequiredColumns()
{
Assert.assertEquals(ImmutableList.of("x", "y"), X_PLUS_Y.requiredColumns());
Assert.assertEquals(new HashSet<>(ImmutableList.of("x", "y")), new HashSet<>(X_PLUS_Y.requiredColumns()));
Assert.assertEquals(ImmutableList.of(), CONSTANT_LIKE.requiredColumns());
Assert.assertEquals(ImmutableList.of("z"), Z_LIKE.requiredColumns());
Assert.assertEquals(ImmutableList.of("x", "z"), Z_CONCAT_X.requiredColumns());
Assert.assertEquals(new HashSet<>(ImmutableList.of("x", "z")), new HashSet<>(Z_CONCAT_X.requiredColumns()));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private DiscoveryDruidNode buildDiscoveryDruidNode(NodeRole role, String host)
private void assertListener(TestListener listener, boolean nodeViewInitialized, List<DiscoveryDruidNode> nodesAdded, List<DiscoveryDruidNode> nodesRemoved)
{
Assert.assertEquals(nodeViewInitialized, listener.nodeViewInitialized.get());
Assert.assertEquals(nodesAdded, listener.nodesAddedList);
Assert.assertEquals(new HashSet<>(nodesAdded), new HashSet<>(listener.nodesAddedList));
Assert.assertEquals(nodesRemoved, listener.nodesRemovedList);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ public void testJsonAttr() throws IOException
Assert.assertEquals("wikipedia", deserialized.getId());
final String serialized = mapper.writeValueAsString(deserialized);
Assert.assertTrue(serialized.contains("\"source\""));
Assert.assertEquals(json, serialized);
Assert.assertEquals(mapper.readTree(json), mapper.readTree(serialized));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void testExecuteQuery() throws IOException
String expectedJson = mapper.writeValueAsString(
Collections.singletonList(((MapBasedInputRow) expectedRow).getEvent())
);
Assert.assertEquals(actualJson, expectedJson);
Assert.assertEquals(mapper.readTree(actualJson), mapper.readTree(expectedJson));
testUtils.dropTable(TABLE_NAME_1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -367,18 +368,18 @@ public void testGetAllBrokers()
{
Assert.assertEquals(
ImmutableMap.of(
"mediumBroker", ImmutableList.of(),
"coldBroker", ImmutableList.of("coldHost1:8080", "coldHost2:8080"),
"hotBroker", ImmutableList.of("hotHost:8080")
"mediumBroker", ImmutableSet.of(),
"coldBroker", ImmutableSet.of("coldHost1:8080", "coldHost2:8080"),
"hotBroker", ImmutableSet.of("hotHost:8080")
),
Maps.transformValues(
brokerSelector.getAllBrokers(),
new Function<List<Server>, List<String>>()
new Function<List<Server>, HashSet<String>>()
{
@Override
public List<String> apply(@Nullable List<Server> servers)
public HashSet<String> apply(@Nullable List<Server> servers)
{
return Lists.transform(servers, server -> server.getHost());
return new HashSet<>(Lists.transform(servers, server -> server.getHost()));
}
}
)
Expand Down