Skip to content

Commit

Permalink
Push topN to Phoenix unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
lhofhansl authored and hashhar committed Jun 28, 2021
1 parent 39b0af8 commit f2b6d09
Showing 1 changed file with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ public class PhoenixClient
extends BaseJdbcClient
{
private static final String ROWKEY = "ROWKEY";
private static final long MAX_TOPN_LIMIT = 2000000;

private final Configuration configuration;

Expand Down Expand Up @@ -293,21 +292,13 @@ public boolean supportsTopN(ConnectorSession session, JdbcTableHandle handle, Li
@Override
protected Optional<TopNFunction> topNFunction()
{
return Optional.of((query, sortItems, limit) -> {
// TODO: Remove when this is fixed in Phoenix.
// Phoenix severely over-estimates the memory
// required to execute a topN query.
// https://issues.apache.org/jira/browse/PHOENIX-6436
if (limit > MAX_TOPN_LIMIT) {
return query;
}
return TopNFunction.sqlStandard(this::quoted).apply(query, sortItems, limit);
});
return Optional.of(TopNFunction.sqlStandard(this::quoted));
}

@Override
public boolean isTopNGuaranteed(ConnectorSession session)
{
// There are multiple splits and TopN is not guaranteed across them.
return false;
}

Expand Down

0 comments on commit f2b6d09

Please sign in to comment.