aboutsummaryrefslogtreecommitdiff
path: root/exec/java-exec/src/test/java/org/apache/drill/exec/store/json
diff options
context:
space:
mode:
authorBhallamudi Venkata Siva Kamesh <kamesh.hadoop@gmail.com>2014-03-25 11:04:07 -0700
committerTimothy Chen <tnachen@apache.org>2014-03-25 11:04:15 -0700
commit721e7c25759eda2f12b17e15e4ca32ab16ec1e1c (patch)
treebd821bfcc32576637852bdba67d9cefe2cfe0a24 /exec/java-exec/src/test/java/org/apache/drill/exec/store/json
parent30ce7d710a1bb876a272fd454ff286b5909ff717 (diff)
DRILL-446 Fix Json Array parsing
Diffstat (limited to 'exec/java-exec/src/test/java/org/apache/drill/exec/store/json')
-rw-r--r--exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java
index bfeb8929b..e812997b6 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/store/json/JSONRecordReaderTest.java
@@ -387,4 +387,33 @@ public class JSONRecordReaderTest {
assertEquals(0, jr.next());
assertTrue(mutator.getRemovedFields().isEmpty());
}
+
+ @Test
+ public void testJsonArrayandNormalFields(@Injectable final FragmentContext context) throws ExecutionSetupException, IOException {
+ new Expectations() {
+ {
+ context.getAllocator();
+ returns(new TopLevelAllocator());
+ }
+ };
+
+ JSONRecordReader jr = new JSONRecordReader(context,
+ FileUtils.getResourceAsFile("/scan_json_test_7.json").toURI().toString(),
+ FileSystem.getLocal(new Configuration()), null, null);
+
+ MockOutputMutator mutator = new MockOutputMutator();
+ List<ValueVector> addFields = mutator.getAddFields();
+ jr.setup(mutator);
+ assertEquals(2, jr.next());
+ assertEquals(3, addFields.size());
+
+ assertField(addFields.get(0), 0, MinorType.VARCHAR, "ABC", "test");
+ assertField(addFields.get(2), 0, MinorType.VARCHAR, "drill", "a");
+ assertField(addFields.get(0), 1, MinorType.VARCHAR, "abc", "test");
+ assertField(addFields.get(2), 1, MinorType.VARCHAR, "apache", "a");
+
+
+ assertEquals(0, jr.next());
+ assertTrue(mutator.getRemovedFields().isEmpty());
+ }
}