Jess Balint created CALCITE-1610:
------------------------------------
Summary: RelBuilder sort-combining optimization treats aliases
incorrectly
Key: CALCITE-1610
URL: https://issues.apache.org/jira/browse/CALCITE-1610
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.11.0
Reporter: Jess Balint
Assignee: Julian Hyde
Priority: Minor
This optimization in {{RelBuilder.sortLimit()}} manipulates the stack using
{{replaceTop()}} which preserves the current field names. The current field
names are not guaranteed to be the same as any descendant the Project and thus
the {{replaceTop(sort2.getInput())}} call places a RelNode on top of the stack
with incorrect field names.
{code:java}
if (top instanceof Project) {
final Project project = (Project) top;
if (project.getInput() instanceof Sort) {
final Sort sort2 = (Sort) project.getInput();
if (sort2.offset == null && sort2.fetch == null) {
replaceTop(sort2.getInput());
final RelNode sort =
sortFactory.createSort(peek(), sort2.collation,
offsetNode, fetchNode);
replaceTop(sort);
project(project.getProjects());
return this;
}
}
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)