Github user sohami commented on a diff in the pull request:

    https://github.com/apache/drill/pull/752#discussion_r102362622
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/mock/MockStorageEngine.java
 ---
    @@ -109,7 +121,37 @@ public MockSchema(MockStorageEngine engine) {
     
         @Override
         public Table getTable(String name) {
    -      Pattern p = Pattern.compile("(\\w+)_(\\d+)(k|m)?", 
Pattern.CASE_INSENSITIVE);
    +      if (name.toLowerCase().endsWith(".json") ) {
    +        return getConfigFile(name);
    +      } else {
    +        return getDirectTable(name);
    +      }
    +    }
    +
    +    private Table getConfigFile(String name) {
    +      final URL url = Resources.getResource(name);
    +      if (url == null) {
    +        throw new IllegalArgumentException(
    +            "Unable to find mock table config file " + name);
    +      }
    +      MockTableDef mockTableDefn;
    +      try {
    +        String json = Resources.toString(url, Charsets.UTF_8);
    +        final ObjectMapper mapper = new ObjectMapper();
    +        mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, 
true);
    +        mockTableDefn = mapper.readValue(json, MockTableDef.class);
    +      } catch (JsonParseException e) {
    +        throw new IllegalArgumentException( "Unable to parse mock table 
definition file: " + name, e );
    +      } catch (JsonMappingException e) {
    +        throw new IllegalArgumentException( "Unable to Jackson deserialize 
mock table definition file: " + name, e );
    +      } catch (IOException e) {
    +        throw new IllegalArgumentException( "Unable to read mock table 
definition file: " + name, e );
    +      }
    +      return new DynamicDrillTable(engine, this.name, 
mockTableDefn.getEntries() );
    --- End diff --
    
    Please remove extra space before last` )`. there are few other places too 
like line 169 in this file, line 199 (MockTableDef.java), etc.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to