You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "grandfisher (Jira)" <ji...@apache.org> on 2022/12/23 07:38:00 UTC
[jira] [Created] (CALCITE-5456) Hints on Tablescan will lost when plannerImpl execute flattenTypes
grandfisher created CALCITE-5456:
------------------------------------
Summary: Hints on Tablescan will lost when plannerImpl execute flattenTypes
Key: CALCITE-5456
URL: https://issues.apache.org/jira/browse/CALCITE-5456
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.32.0
Reporter: grandfisher
I want to use some hints on tablescan for extra processing. But hints wll lost after `flattenTypes`
In PlannerImpl#rel(SqlNode sql)
{code:java}
// if hint apply on tablescan here
RelRoot root =
sqlToRelConverter.convertQuery(validatedSqlNode, false, true);
// flattenTypes will make hints on tablescan lost
root = root.withRel(sqlToRelConverter.flattenTypes(root.rel, true));{code}
This is due to `RelStructuredTypeFlattener` use `ImmutableList.of()` to initialize context, and `RelStructuredTypeFlattener` recreate a new `tablescan` relnode with this context
{code:java}
// PlannerImpl#flattenTypes
public RelNode flattenTypes(
RelNode rootRel,
boolean restructure) {
RelStructuredTypeFlattener typeFlattener =
new RelStructuredTypeFlattener(relBuilder,
rexBuilder, createToRelContext(ImmutableList.of()), restructure);
return typeFlattener.rewrite(rootRel);
} {code}
{code:java}
// RelStructuredTypeFlattener#rewriteRel
public void rewriteRel(TableScan rel) {
RelNode newRel = rel.getTable().toRel(toRelContext);
if (!SqlTypeUtil.isFlat(rel.getRowType())) {
newRel = coverNewRelByFlatteningProjection(rel, newRel);
}
setNewForOldRel(rel, newRel);
} {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)