Only one side of this optimization is valid. You can optimize "GROUP BY A" (groupbyExprs == null) with an index "ON (A, ABS(B))" (!expressionjson.isEmpty()).
You should add a test case like this.