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

Jinfeng Ni commented on CALCITE-911:
------------------------------------

As I said yesterday, I tried a different approach. Turns out it did not work.

Basically, I want to avoid using CalciteSchema in Drill (Suppose CalciteSchema 
is not part of public API, and should not be used in Adapter like Drill??). The 
reason Drill originally has to use CalciteSchema is to get an instance of 
SchemaPlus, and pass that SchemaPlus to FrameworkConfig as the defaultSchema. 
With this idea, I implemented DrillSchemaPlus, an implementation of interface 
SchemaPlus, and maintain the sub-schema / tables etc in DrillSchemaPlus. 

However, I hit ClassCastException, as couple of places in Calcite core code 
expects instance of CalciteSchema$SchemaPlusImpl, in stead of any 
implementation of SchemaPlus. [1] [2]

{code}
 public static CalciteSchema from(SchemaPlus plus) {
    return ((SchemaPlusImpl) plus).calciteSchema();
  }
{code}

I'm not sure whether SchemaPlus is part of public API, or each different 
project could use different implementation of SchemaPlus. But seems the other 
part of Calcite closes such possibility, as people has to use CalciteSchema to 
get an instance of SchemaPlus (Does it make CalciteSchema not only used in 
Calcite internally, but also in other projects, thus violates the comments made 
in CalciteSchema??)

Anyway, for now, I do not see a way to avoid using CalciteSchema in order to 
use Calcite's Frameworks code.

[1] 
https://github.com/apache/incubator-calcite/blob/master/core/src/main/java/org/apache/calcite/tools/Frameworks.java#L111
[2] 
https://github.com/apache/incubator-calcite/blob/master/core/src/main/java/org/apache/calcite/prepare/CalcitePrepareImpl.java#L923


> Make CalciteSchema extendible for different implementation.
> -----------------------------------------------------------
>
>                 Key: CALCITE-911
>                 URL: https://issues.apache.org/jira/browse/CALCITE-911
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jinfeng Ni
>            Assignee: Jinfeng Ni
>             Fix For: 1.5.0-incubating
>
>
> CalciteSchema by default uses cache to store table, sub-schema, function. 
> This would work perfectly for schema-based system, yet would create problem 
> for Drill, which dynamically explore the schema on the fly during query 
> execution. 
> One solution is to refactor CalciteSchema and make it as an interface. The 
> default implementation would still use the current implementation. Further, 
> it would other system to extend the default behavior and make CalciteSchema 
> works for Drill as well. 
> Background information: The issue around CalciteSchema is one of the reasons 
> that Drill has to use a forked version of Calcite. Hopefully, if we could 
> resolve this issue, we are one step further to remove the forked Calcite in 
> the near future.
>  



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

Reply via email to