drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [drill] arina-ielchiieva commented on a change in pull request #2045: DRILL-7683: Add "message parsing" to new JSON loader
Date Tue, 31 Mar 2020 21:42:46 GMT
arina-ielchiieva commented on a change in pull request #2045: DRILL-7683: Add "message parsing"
to new JSON loader
URL: https://github.com/apache/drill/pull/2045#discussion_r401231516
 
 

 ##########
 File path: exec/java-exec/src/test/java/org/apache/drill/exec/store/easy/json/parser/TestJsonParserBasics.java
 ##########
 @@ -324,4 +327,64 @@ public void testJsonModeObjects() {
     assertFalse(fixture.next());
     fixture.close();
   }
+
+  /**
+   * Example message parser. A real parser would provide much better
+   * error messages for badly-formed JSON or error codes.
+   */
+  private static class MessageParserFixture implements MessageParser {
+
+    @Override
+    public boolean parsePrefix(TokenIterator tokenizer) {
+      assertEquals(JsonToken.START_OBJECT, tokenizer.requireNext());
+      assertEquals(JsonToken.FIELD_NAME, tokenizer.requireNext());
+      assertEquals(JsonToken.VALUE_STRING, tokenizer.requireNext());
+      if (!tokenizer.stringValue().equals("ok")) {
 
 Review comment:
   Usually is better to start with constant to avoid NPE (I know it's just a test, just noticed).
   ```suggestion
         if (!"ok".equals(tokenizer.stringValue()) {
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message