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

Julian Hyde commented on CALCITE-601:
-------------------------------------

Please don't conflate ENUMERABLE convention with interface Enumerable.

For instance, Avatica does not depend on core Calcite, does not know about 
conventions, and does not know about planner rules. It does know about the 
Enumerable interface. So its Meta SPI returns an Enumerable<Object[]>.

BINDABLE convention is similar to ENUMERABLE convention at run time (they both 
use Enumerable) but radically different at planning time. We need both 
conventions.

Code that is constructing a result set knows whether the Enumerable came from 
the ENUMERABLE convention (and therefore whether it returns singleton boxed 
primitives, object arrays, or synthetic objects) or from the BINDABLE 
convention (and are therefore object arrays). Look at the 4 places that call 
deduce today.

Also, can we please leave user-defined functions should be a separate 
discussion? UDFs that accept relations as parameters and returns a relation (or 
even relations) are really complicated from a metadata standpoint. I'm not sure 
that Enumerable or Queryable have enough metadata for the job.

> Meta.CursorFactory#deduce should not try to check column count
> --------------------------------------------------------------
>
>                 Key: CALCITE-601
>                 URL: https://issues.apache.org/jira/browse/CALCITE-601
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.0.0-incubating
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>
> Current implementation of {{Meta.CursorFactory#deduce}} thinks that 
> Enumerable with single column cannot be {{Object\[\]}} wrapped.
> This sounds like an extreme high coupling.
> I think it makes sense if "Bindable" would provide its {{JavaRowFormat}} 
> along with "ElementType".
> I think it makes sense to reject non-typed, non-rowformatproviding Bindables 
> out of Enumerable/Bindable conventions.
> {code:java}
>     public static CursorFactory deduce(List<ColumnMetaData> columns,
>         Class resultClazz) {
>       if (columns.size() == 1) {
>         return OBJECT;  // <-- !! Look here. deduce just assumes 
> single-column results are always naked
>       } else if (resultClazz != null && !resultClazz.isArray()) {
>         return record(resultClazz);
>       } else {
>         return ARRAY;
>       }
>     }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to