[ 
https://issues.apache.org/jira/browse/DRILL-6167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16369519#comment-16369519
 ] 

Paul Rogers commented on DRILL-6167:
------------------------------------

Note that adding the {{DEFAULT}} keyword does not help:

{code:sql}
SELECT * FROM table(cp.`regex/simple.log2`
  (type => DEFAULT, regex => 'some pattern'))
{code}

We get the same error:

{noformat}
org.apache.calcite.runtime.CalciteContextException:
  From line 1, column 24 to line 3, column 48:
  DEFAULT is only allowed for optional parameters
{noformat}

> 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
>            Priority: Major
>
> 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:
> {code}
> @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, 
>       include = JsonTypeInfo.As.PROPERTY,
>       property="type")
> public interface FormatPluginConfig { }
> {code}
> 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:
> {code}
> @JsonTypeName("regex")
> @JsonInclude(Include.NON_DEFAULT)
> public class RegexFormatConfig implements FormatPluginConfig {
>   public String regex;
> ...
> {code}
> 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:
> {code}
> SELECT * FROM table(cp.`regex/simple.log2`
>   (regex => 'some pattern'))
> {code}
> When run (in the debugger, as a test), we get the following error:
> {code}
> org.apache.calcite.runtime.CalciteContextException: From line 1,
>     column 24 to line 2, column 40:
>     DEFAULT is only allowed for optional parameters
> {code}
> 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:
> {code}
> SELECT * FROM table(cp.`regex/simple.log2`
>   (type => 'regex', regex => 'some pattern'))
> {code}
> 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
(v7.6.3#76005)

Reply via email to