Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
1.12.0
-
None
-
None
-
None
Description
Drill provides table functions (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, property="type") 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:
@JsonTypeName("regex") @JsonInclude(Include.NON_DEFAULT) 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.
Attachments
Issue Links
- Is contained by
-
DRILL-6986 Table function improvements / issues (UMBRELLA JIRA)
- Open
- is related to
-
DRILL-6168 Table functions do not "inherit" default configuration
- Closed
- relates to
-
DRILL-6168 Table functions do not "inherit" default configuration
- Closed
- links to