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

Vladimir Sitnikov commented on CALCITE-506:
-------------------------------------------

{quote} We don't expect the public to build classes that implement 
EnumerableRel outside of the Calcite code base.{quote}
We do expect public to _use_ that class, don't we?

1) How would you implement {{MongoToEnumerableConverter}} without 
{{EnumerableRelImplementor}}?
2) It is much easier to stick with enumerable convention unless you want to 
implement executor from scratch. I mean there 

{quote}[~vladimirsitnikov]I think the ability to "pass non-string literals to 
EnumerableImplementor" is quote often requested.{quote}
Any hints on the preferred approach here?

Well, "the proper way" might be to go through {{RexBuilder.makeLiteral}}. For 
instance, allow to invoke {{makeLiteral(customObject, SqlTypeName,OTHER, ...)}} 
for user-defined data types.
So the end-to-end would be:
1) User passes random java object into the query via 
{{RexBuilder#makeLiteral(customObject, SqlTypeName,OTHER}}
2) EnumerableImplementor detects such OTHER literals and passes it via 
DataContext transparently to the user.

Would this qualify as proper usage of OTHER sql type?

> Update EnumerableRelImplementor.stash so it is suitable for all kinds of 
> classes
> --------------------------------------------------------------------------------
>
>                 Key: CALCITE-506
>                 URL: https://issues.apache.org/jira/browse/CALCITE-506
>             Project: Calcite
>          Issue Type: Bug
>    Affects Versions: 1.0.0-incubating
>            Reporter: Vladimir Sitnikov
>            Assignee: Julian Hyde
>              Labels: newbie
>
> {code:java}
>   public Expression stash(RelNode child, Class clazz) {
>     final ParameterExpression x = register(child, clazz);
>     final Expression e = Expressions.call(getRootExpression(),
>         BuiltInMethod.DATA_CONTEXT_GET.method, Expressions.constant(x.name));
>     return Expressions.convert_(e, clazz);
>   }
> {code}
> I would like to make two corrections here:
> 1) I think {{public <T> Expression st(T x, Class<? super T> clazz) \{}} 
> should be better signature.
> 2) It makes sense to translate {{DATA_CONTEXT_GET}} as a store to a {{final}} 
> local variable at the very start of {{public 
> org.apache.calcite.linq4j.Enumerable bind(final 
> org.apache.calcite.DataContext root0)}} method (see {{implementRoot}}), so at 
> the usage time it is just a load of local variable, not a {{map.get}}



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

Reply via email to