fix(python): accept column names in order_by and validate early (#5119)

## Summary

- Accept column names, `(column_name, "asc"|"desc")` tuples,
`ColumnOrdering`, and `{"column_name": ...}` dicts in both sync and
async `order_by`, including mixed lists.
- Distinguish a bare direction tuple from a list of column names by
container type; `None` and `[]` clear ordering.
- Validate at setter time with actionable errors for unknown dict keys
and invalid directions.
- Export `ColumnOrdering` from `lancedb` and document the accepted forms
with examples.
- Reject non-empty ordering on sync hybrid queries explicitly instead of
silently ignoring it.

Fixes OSS-3108. Namespace pushdown (OSS-3126) is intentionally out of
scope.

## Tests

- `python/tests/test_query.py` (214 passed, 1 skipped)
- `python/tests/test_query.py -k order_by` (7 passed)
- `python/tests/test_fts.py -k order_by` (2 passed)
- `python/tests/test_remote_db.py::test_query_sync_maximal`
- `pytest --doctest-modules python/lancedb/query.py` (21 passed)
- `ruff format` / `ruff check`
This commit is contained in:
Xuanwo
2026-11-20 20:25:06 +08:00
committed by GitHub
parent 164aec1753
commit b9a2807049
4 changed files with 271 additions and 11 deletions
+2
View File
@@ -793,6 +793,8 @@ of raw SQL strings with [where][lancedb.query.LanceQueryBuilder.where] and
::: lancedb.query.Query
::: lancedb.query.ColumnOrdering
::: lancedb.query.LanceQueryBuilder
::: lancedb.query.LanceVectorQueryBuilder