Skip to content

Commit

Permalink
re-disallow DESC with ORDER BY ANN
Browse files Browse the repository at this point in the history
  • Loading branch information
jbellis committed Dec 6, 2024
1 parent 237cec4 commit 56a6e0f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,8 @@ else if (indexOrderings.size() == 1)
if (orderings.size() > 1)
throw new InvalidRequestException("Cannot combine clustering column ordering with non-clustering column ordering");
Ordering ordering = indexOrderings.get(0);
if (ordering.direction != Ordering.Direction.ASC && ordering.expression.isScored())
// TODO remove the instanceof with SelectStatement.ANN_USE_SYNTHETIC_SCORE.
if (ordering.direction != Ordering.Direction.ASC && (ordering.expression.isScored() || ordering.expression instanceof Ordering.Ann))
throw new InvalidRequestException("Descending ANN ordering is not supported");
if (!ENABLE_SAI_GENERAL_ORDER_BY && ordering.expression instanceof Ordering.SingleColumn)
throw new InvalidRequestException("SAI based ORDER BY on non-vector column is not supported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@
*/
public class SelectStatement implements CQLStatement.SingleKeyspaceCqlStatement
{
// TODO remove this when we no longer need to downgrade to replicas that don't know about synthetic columns
// (And don't forget to remove the related hacks in Columns.Serializer.encodeBitmap and UnfilteredSerializer.serializeRowBody)
// TODO remove this when we no longer need to downgrade to replicas that don't know about synthetic columns,
// and the related code in
// - Columns.Serializer.encodeBitmap
// - UnfilteredSerializer.serializeRowBody)
// - StatementRestrictions.addOrderingRestrictions
public static final boolean ANN_USE_SYNTHETIC_SCORE = Boolean.parseBoolean(System.getProperty("cassandra.sai.ann_use_synthetic_score", "false"));

private static final Logger logger = LoggerFactory.getLogger(SelectStatement.class);
Expand Down

0 comments on commit 56a6e0f

Please sign in to comment.