You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by "Paul Rogers (JIRA)" <ji...@apache.org> on 2018/08/08 00:31:00 UTC
[jira] [Created] (DRILL-6673) Drill table functions cannot use
plugin configs with a constructor
Paul Rogers created DRILL-6673:
----------------------------------
Summary: Drill table functions cannot use plugin configs with a constructor
Key: DRILL-6673
URL: https://issues.apache.org/jira/browse/DRILL-6673
Project: Apache Drill
Issue Type: Bug
Affects Versions: 1.13.0
Reporter: Paul Rogers
Consider an example format plugin, such as the regex one used in the Drill book. (GitHub reference needed.) Format configurations should be immutable. So, we make the members {{private final}} and define a constructor like this:
{code}
public class RegexFormatConfig implements FormatPluginConfig {
private final String regex;
// Should be a List<String>. But, table functions don't support
// lists, so we store the fields as single string that contains
// a comma-delimited list: a, b, c. Spaces are optional.
private final String fields;
private final String extension;
public RegexFormatConfig(
@JsonProperty("extension") String extension,
@JsonProperty("regex") String regex,
@JsonProperty("fields") String fields
) {
this.regex = regex;
this.fields = fields;
this.extension = extension;
}
{code}
We can then create a plugin configuration using the Drill Web console, the {{bootstrap-storage-plugins.json}} and so on. All work fine.
Suppose we try to define a configuration using a Drill table function:
{code}
final String sql = "SELECT * FROM table(cp.`regex/simple.log2`\n" +
"(type => 'regex',\n" +
" extension => 'log2',\n" +
" regex => '(\\\\d\\\\d\\\\d\\\\d)-(\\\\d\\\\d)-(\\\\d\\\\d) .*',\n" +
" fields => 'a, b, c, d'))";
{code}
We get this error:
{noformat}
org.apache.drill.common.exceptions.UserRemoteException: PARSE ERROR:
configuration for format of type regex can not be created
(class: org.apache.drill.exec.store.easy.regex.RegexFormatConfig)
table regex/simple.log2
{noformat}
They fail because the code that resolves the plugin configuration does not know about the Jackson constructor conventions: it requires an default constructor:
{code}
package org.apache.drill.exec.store.dfs;
...
final class FormatPluginOptionsDescriptor {
...
FormatPluginConfig createConfigForTable(TableInstance t) {
...
try {
config = pluginConfigClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw UserException.parseError(e)
.message(
"configuration for format of type %s can not be created (class: %s)",
this.typeName, pluginConfigClass.getName())
...
{code}
The workaround would seem to be to define setters using Jackson standards. But, that does not work either due to DRILL-6672 which says that Drill table functions don't allow them. The only real workaround is to make the fields {{public}} and omit the constructor.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)