Fix subquery with order by (#11017)

* fix subquery with order by

* fix parameter
This commit is contained in:
chenyuzhi459 2021-03-26 19:43:46 +08:00 committed by GitHub
parent cc23befaa4
commit 248af38777
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 1 deletions

View File

@ -147,7 +147,7 @@ public class DruidPlanner implements Closeable
RelDataType rowType = root.validatedRowType;
SqlValidator validator = getValidator();
RelDataType parameterTypes = validator.getParameterRowType(validator.validate(parsed));
RelDataType parameterTypes = validator.getParameterRowType(validator.validate(validated));
if (explain != null) {
final RelDataTypeFactory typeFactory = root.rel.getCluster().getTypeFactory();

View File

@ -150,6 +150,34 @@ public class DruidStatementTest extends CalciteTestBase
);
}
@Test
public void testSubQueryWithOrderBy()
{
final String sql = "select T20.F13 as F22 from (SELECT DISTINCT dim1 as F13 FROM druid.foo T10) T20 order by T20.F13 ASC";
final DruidStatement statement = new DruidStatement("", 0, null, sqlLifecycleFactory.factorize(), () -> {
}).prepare(sql, -1, AllowAllAuthenticator.ALLOW_ALL_RESULT);
// First frame, ask for all rows.
Meta.Frame frame = statement.execute(Collections.emptyList()).nextFrame(DruidStatement.START_OFFSET, 6);
Assert.assertEquals(
Meta.Frame.create(
0,
true,
Lists.newArrayList(
new Object[]{""},
new Object[]{
"1"
},
new Object[]{"10.1"},
new Object[]{"2"},
new Object[]{"abc"},
new Object[]{"def"}
)
),
frame
);
Assert.assertTrue(statement.isDone());
}
@Test
public void testSelectAllInFirstFrame()
{