[
https://issues.apache.org/jira/browse/CALCITE-4694?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17390373#comment-17390373
]
Krisztian Kasa commented on CALCITE-4694:
-----------------------------------------
[~julianhyde]
It makes sense to extract the non-trivial parts from the constructor. However
making the "Internal constructor" private prevents extending the
RelOptMaterialization class and pass a custom RelBuilderFactory. This is how it
looks like if the constructor is protected:
{code:java}
private HiveRelOptMaterialization(RelNode tableRel, RelNode queryRel,
RelOptTable starRelOptTable, List<String>
qualifiedTableName,
/* custom parameters */) {
super(tableRel, queryRel, starRelOptTable, qualifiedTableName,
HiveRelFactories.HIVE_BUILDER);
...
// custom initialization
}
{code}
We have to extend the RelOptMaterialization class because later the HepPlanner
expects RelOptMaterialization instances:
[https://github.com/apache/hive/blob/eef2a5dda0470525d0d89bd9820e761fe44dc3a8/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java#L2433]
When I wanted to use the create method in RelOptMaterialization I found that it
creates RelOptMaterialization instances but not the custom instances. It seems
that the only option to workaround this to wrap the RelOptMaterialization in
HiveRelOptMaterialization and provide a getter method to the wrapped
RelOptMaterialization field.
> When creating a RelOptMaterialization, if row types are not identical, create
> a cast using a custom RelBuilder
> --------------------------------------------------------------------------------------------------------------
>
> Key: CALCITE-4694
> URL: https://issues.apache.org/jira/browse/CALCITE-4694
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.25.0
> Reporter: Krisztian Kasa
> Assignee: Krisztian Kasa
> Priority: Minor
> Labels: pull-request-available
> Fix For: 1.28.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> RelOptMaterialization may add a Project on top of tableRel. This is always a
> LogicalProject since the RelFactories.ProjectFactory is hardcoded to
> RelFactories.DEFAULT_PROJECT_FACTORY.
> Some projects like Hive specifies its custom operators and custom
> RelFactories instead of using the built in Logical ones.
> Example:
> {code:java}
> public class HiveProject extends Project
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)