[ 
https://issues.apache.org/jira/browse/PHOENIX-7772?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Palash Chauhan updated PHOENIX-7772:
------------------------------------
    Description: 
SegmentInfoPlan passes null as QueryPlan delegate in its constructor. 
{code:java}
public SegmentInfoPlan(StatementContext context, FilterableStatement statement, 
TableRef tableRef,
  RowProjector projector, Integer totalSegmentsValue) {
  super(context, statement, tableRef, projector, null, null, null, 
OrderBy.EMPTY_ORDER_BY, null);
  this.totalSegmentsValue = totalSegmentsValue;
  this.sourceTables = ImmutableSet.of(tableRef);
} {code}
During TOTAL_SEGMENTS query, in QueryOptimizer when there is an index on the 
table, `dataPlan.isDegenerate()` is called
{code:java}
if (
  dataPlan.isApplicable() && (indexes.isEmpty() || dataPlan.isDegenerate()
    || dataPlan.getTableRef().hasDynamicCols() || 
select.getHint().hasHint(Hint.NO_INDEX))
) {
  return Collections.<QueryPlan> singletonList(dataPlan);
} {code}
SegmentInfoPlan -> ClientProcessingPlan -> DelegateQueryPlan
{code:java}
@Override
public boolean isDegenerate() {
  return delegate.isDegenerate();
} {code}
delegate is null which leads to NPE

 

  was:
SegmentInfoPlan passes null as delegate in its constructor. 
{code:java}
public SegmentInfoPlan(StatementContext context, FilterableStatement statement, 
TableRef tableRef,
  RowProjector projector, Integer totalSegmentsValue) {
  super(context, statement, tableRef, projector, null, null, null, 
OrderBy.EMPTY_ORDER_BY, null);
  this.totalSegmentsValue = totalSegmentsValue;
  this.sourceTables = ImmutableSet.of(tableRef);
} {code}
During TOTAL_SEGMENTS query, in QueryOptimizer when there is an index on the 
table, `dataPlan.isDegenerate()` is called
{code:java}
if (
  dataPlan.isApplicable() && (indexes.isEmpty() || dataPlan.isDegenerate()
    || dataPlan.getTableRef().hasDynamicCols() || 
select.getHint().hasHint(Hint.NO_INDEX))
) {
  return Collections.<QueryPlan> singletonList(dataPlan);
} {code}
SegmentInfoPlan -> ClientProcessingPlan -> DelegateQueryPlan
{code:java}
@Override
public boolean isDegenerate() {
  return delegate.isDegenerate();
} {code}
delegate is null which leads to NPE

 


> TOTAL_SEGMENTS query leads to NPE when table has index 
> -------------------------------------------------------
>
>                 Key: PHOENIX-7772
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-7772
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 5.3.0
>            Reporter: Palash Chauhan
>            Assignee: Palash Chauhan
>            Priority: Major
>             Fix For: 5.4.0, 5.3.1
>
>
> SegmentInfoPlan passes null as QueryPlan delegate in its constructor. 
> {code:java}
> public SegmentInfoPlan(StatementContext context, FilterableStatement 
> statement, TableRef tableRef,
>   RowProjector projector, Integer totalSegmentsValue) {
>   super(context, statement, tableRef, projector, null, null, null, 
> OrderBy.EMPTY_ORDER_BY, null);
>   this.totalSegmentsValue = totalSegmentsValue;
>   this.sourceTables = ImmutableSet.of(tableRef);
> } {code}
> During TOTAL_SEGMENTS query, in QueryOptimizer when there is an index on the 
> table, `dataPlan.isDegenerate()` is called
> {code:java}
> if (
>   dataPlan.isApplicable() && (indexes.isEmpty() || dataPlan.isDegenerate()
>     || dataPlan.getTableRef().hasDynamicCols() || 
> select.getHint().hasHint(Hint.NO_INDEX))
> ) {
>   return Collections.<QueryPlan> singletonList(dataPlan);
> } {code}
> SegmentInfoPlan -> ClientProcessingPlan -> DelegateQueryPlan
> {code:java}
> @Override
> public boolean isDegenerate() {
>   return delegate.isDegenerate();
> } {code}
> delegate is null which leads to NPE
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to