[
https://issues.apache.org/jira/browse/DRILL-4047?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15004548#comment-15004548
]
ASF GitHub Bot commented on DRILL-4047:
---------------------------------------
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?
> Select with options
> -------------------
>
> Key: DRILL-4047
> URL: https://issues.apache.org/jira/browse/DRILL-4047
> Project: Apache Drill
> Issue Type: Improvement
> Components: Execution - Relational Operators
> Reporter: Julien Le Dem
> Assignee: Julien Le Dem
>
> Add a mechanism to pass parameters down to the StoragePlugin when writing a
> Select statement.
> Some discussion here:
> http://mail-archives.apache.org/mod_mbox/drill-dev/201510.mbox/%3CCAO%2Bvc4AcGK3%2B3QYvQV1-xPPdpG3Tc%2BfG%3D0xDGEUPrhd6ktHv5Q%40mail.gmail.com%3E
> http://mail-archives.apache.org/mod_mbox/drill-dev/201511.mbox/%3ccao+vc4clzylvjevisfjqtcyxb-zsmfy4bqrm-jhbidwzgqf...@mail.gmail.com%3E
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)