drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul Rogers (JIRA)" <j...@apache.org>
Subject [jira] [Created] (DRILL-6167) Table functions give error without hidden type field
Date Mon, 19 Feb 2018 06:19:00 GMT
Paul Rogers created DRILL-6167:

             Summary: Table functions give error without hidden type field
                 Key: DRILL-6167
                 URL: https://issues.apache.org/jira/browse/DRILL-6167
             Project: Apache Drill
          Issue Type: Bug
    Affects Versions: 1.12.0
            Reporter: Paul Rogers

Drill provides [table functions|https://drill.apache.org/docs/plugin-configuration-basics/]
(see _Using the Formats Attributes as Table Function Parameters_) which allow queries to specify
properties of format plugins.

All table functions derive from the {{FormatPluginConfig}} base class:

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, 
      include = JsonTypeInfo.As.PROPERTY,
public interface FormatPluginConfig { }

The annotation above appears to define a property called {{type}} to identify the subtype
of the base class, and is used when deserializing JSON for the config object.

Suppose we define a "regex plugin" to let us read a log file using a regex. We define a plugin
config for this plugin:

public class RegexFormatConfig implements FormatPluginConfig {

  public String regex;

For the above, everything works just fine if we use the config in the normal way (define in
the Drill web console or programmatically in a test.)

Suppose we want to change the regex in a table function:

SELECT * FROM table(cp.`regex/simple.log2`
  (regex => 'some pattern'))

When run (in the debugger, as a test), we get the following error:

org.apache.calcite.runtime.CalciteContextException: From line 1,
    column 24 to line 2, column 40:
    DEFAULT is only allowed for optional parameters

The error is thrown in {{SqlOperator.checkOperandTypes()}} which calls {{FamilyOperandTypeChecker.isOptional()}}
which calls {{WorkspaceSchemaFactory.WithOptionsTableMacro.getParameters()}} which has somehow
decided that the {{type}} "parameter" is required.

OK, if it is required, let's provide it:

SELECT * FROM table(cp.`regex/simple.log2`
  (type => 'regex', regex => 'some pattern'))

The above SQL works as expected, producing the proper output.

Since the type is hidden, and is known only to Java developers, the code should not require
that the user specify it; especially since there is exactly only one correct value.

This message was sent by Atlassian JIRA

View raw message