Github user jacques-n commented on a diff in the pull request:

    https://github.com/apache/drill/pull/246#discussion_r44822446
  
    --- Diff: 
exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/WorkspaceSchemaFactory.java
 ---
    @@ -148,12 +175,427 @@ private Path getViewPath(String name) {
         return DotDrillType.VIEW.getPath(config.getLocation(), name);
       }
     
    -  public WorkspaceSchema createSchema(List<String> parentSchemaPath, 
SchemaConfig schemaConfig) throws  IOException {
    +  public WorkspaceSchema createSchema(List<String> parentSchemaPath, 
SchemaConfig schemaConfig) throws IOException {
         return new WorkspaceSchema(parentSchemaPath, schemaName, schemaConfig);
       }
     
    -  public class WorkspaceSchema extends AbstractSchema implements 
ExpandingConcurrentMap.MapValueFactory<String, DrillTable> {
    -    private final ExpandingConcurrentMap<String, DrillTable> tables = new 
ExpandingConcurrentMap<>(this);
    +  /**
    +   * Describes the options for a format plugin
    +   * extracted from the FormatPluginConfig subclass
    +   */
    +  static final class OptionsDescriptor {
    +    final Class<? extends FormatPluginConfig> pluginConfigClass;
    +    final String typeName;
    +    private final Map<String, TableParamDef> functionParamsByName;
    +
    +    OptionsDescriptor(Class<? extends FormatPluginConfig> 
pluginConfigClass) {
    +      this.pluginConfigClass = pluginConfigClass;
    +      Map<String, TableParamDef> paramsByName = new LinkedHashMap<>();
    +      Field[] fields = pluginConfigClass.getDeclaredFields();
    +      // @JsonTypeName("text")
    +      JsonTypeName annotation = 
pluginConfigClass.getAnnotation(JsonTypeName.class);
    +      this.typeName = annotation != null ? annotation.value() : null;
    +      if (this.typeName != null) {
    +        paramsByName.put("type", new TableParamDef("type", String.class));
    +      }
    +      for (Field field : fields) {
    +        if (Modifier.isStatic(field.getModifiers())
    +            // we want to deprecate this field
    +            || (field.getName().equals("extensions") && field.getType() == 
List.class)) {
    +          continue;
    +        }
    +        Class<?> fieldType = field.getType();
    +        if (fieldType == char.class) {
    +          // calcite does not like char type. Just use String and enforce 
later that length == 1
    +          fieldType = String.class;
    +        }
    +        paramsByName.put(field.getName(), new 
TableParamDef(field.getName(), fieldType).optional());
    +      }
    +      this.functionParamsByName = unmodifiableMap(paramsByName);
    +    }
    +
    +    TableSignature getTableSignature(String tableName) {
    +      return new TableSignature(tableName, params());
    +    }
    +
    +    private List<TableParamDef> params() {
    +      return new ArrayList<>(functionParamsByName.values());
    +    }
    +
    +    String presentParams() {
    +      StringBuilder sb = new StringBuilder("(");
    +      List<TableParamDef> params = params();
    +      for (int i = 0; i < params.size(); i++) {
    +        TableParamDef paramDef = params.get(i);
    +        if (i != 0) {
    +          sb.append(", ");
    +        }
    +        sb.append(paramDef.name).append(": 
").append(paramDef.type.getSimpleName());
    +      }
    +      sb.append(")");
    +      return sb.toString();
    +    }
    +
    +    FormatPluginConfig eval(TableInstance t) {
    --- End diff --
    
    Can you provide a more descriptive method name and short doc?


---
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