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,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 @@ -42,6 +43,8 @@
*/
public class CompatParquetReaderTest extends BaseParquetReaderTest
{
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();

@Test
public void testBinaryAsString() throws IOException
{
Expand Down Expand Up @@ -94,19 +97,14 @@ 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(JSON_MAPPER.readTree(expectedJson), JSON_MAPPER.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())
);
+ "}";
Assert.assertEquals(JSON_MAPPER.readTree(expectedJsonBinary), JSON_MAPPER.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampledAsBinary.get(0).getRawValues())));
}


@Test
public void testParquet1217() throws IOException
{
Expand Down Expand Up @@ -143,7 +141,7 @@ public void testParquet1217() throws IOException
final String expectedJson = "{\n"
+ " \"col\" : -1\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 Down Expand Up @@ -305,7 +303,7 @@ required group nestedIntsColumn (LIST) {
+ " } ]\n"
+ " }\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 Down Expand Up @@ -342,10 +340,9 @@ public void testOldRepeatedInt() throws IOException
final String expectedJson = "{\n"
+ " \"repeatedInt\" : [ 1, 2, 3 ]\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
public void testReadNestedArrayStruct() throws IOException
{
Expand Down Expand Up @@ -385,7 +382,7 @@ public void testReadNestedArrayStruct() throws IOException
+ " \"repeatedMessage\" : [ 3 ]\n"
+ " } ]\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 Down Expand Up @@ -435,6 +432,6 @@ public void testProtoStructWithArray() throws IOException
+ " \"someId\" : 9\n"
+ " }\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 @@ -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 @@ -205,8 +206,9 @@ public void testFlat1FlattenSelectListItem() throws IOException
flattenSpec
);
List<InputRowListPlusRawValues> sampled = sampleAllRows(reader);
ObjectMapper mapper = new ObjectMapper();

Assert.assertEquals(FLAT_JSON, DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues()));
Assert.assertEquals(mapper.readTree(FLAT_JSON), mapper.readTree(DEFAULT_JSON_WRITER.writeValueAsString(sampled.get(0).getRawValues())));
}


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