You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2020/03/31 21:42:46 UTC

[GitHub] [drill] arina-ielchiieva commented on a change in pull request #2045: DRILL-7683: Add "message parsing" to new JSON loader

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