This is an automated email from the ASF dual-hosted git repository.
jerryshao pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 4f48f057c3 [#13803] improvement(lance): Upgrade lance-core to 12.0.0
and lance-namespace to 0.11.1 (#13929)
4f48f057c3 is described below
commit 4f48f057c387b01bab0b250285fce222626d3652
Author: FANNG <[email protected]>
AuthorDate: Mon Nov 16 16:03:00 2026 +0800
[#13803] improvement(lance): Upgrade lance-core to 12.0.0 and
lance-namespace to 0.11.1 (#13929)
### What changes were proposed in this pull request?
Upgrades the Lance dependencies to the pair current Lance clients ship
with:
- `lance-core`: `6.0.0` -> `12.0.0`
- `lance-namespace-core` / `lance-namespace-apache-client`: `0.7.5` ->
`0.11.1`
**One production Java change.** `LanceTableOperations` now rejects the
`branch` and `tag` selectors that 0.11.1 adds to the describe and alter
requests. Gravitino keeps a single Lance history per table and
implements neither, so deserializing them and ignoring them would apply
a branch-scoped mutation to the table itself; a `drop_columns` naming
branch `dev` would drop the column from the table. They are refused with
`400`.
Nothing else in the server needed changing. Gravitino does not implement
`org.lance.namespace.LanceNamespace` — its REST layer is hand-written
JAX-RS over its own `lance-common` ops interfaces — so 0.11.1's
interface break does not reach it; every generated-client method it
calls is signature-identical, no model class was removed, and its
`lance-core` usage is all builder APIs that survived 6.0.0 -> 12.0.0.
Supporting changes:
- **OpenTelemetry excluded.** `lance-core` 12.0.0 adds compile-scope
`io.opentelemetry:opentelemetry-api`, used only by the opt-in
`org.lance.otel.LanceMetrics` bridge Gravitino never enables. Excluding
it keeps the distribution and the legal files unchanged. Both
`testImplementation(libs.lance)` declarations exclude it too, so a test
classpath cannot hide a new reference to `org.lance.otel.*` that would
then fail in the distribution.
- **Test matrices widened.** `lance-spark` goes from four bundles to six
(adding 0.6.1 and 0.7.1), so the default list covers every
`lance-namespace` generation a released bundle speaks — pre-0.7 (0.2.0,
0.4.0), 0.7.5 (0.5.1), 0.8.6 (0.6.1, 0.7.1), 0.11.1 (0.8.0) — with 0.8.0
as the primary bundle. `lance-ray` goes from two versions to four, with
per-row `lance-namespace` pins: `lance-ray` never bounds
`lance-namespace` while `pylance` does, so one shared pin cannot
describe the matrix, and 0.5.0 paired with the previous global `0.7.5`
is `ResolutionImpossible`. Both CI workflow defaults move with the
lists.
- **Blob file-format tests** no longer rely on Lance's default file
format version, which is now 2.2, and pin it explicitly instead.
- Docs, the compatibility matrix, and stale version comments.
### Why are the changes needed?
To keep the Lance REST service consistent with the Lance community.
12.0.0 + 0.11.1 is the combination current Lance clients ship with —
`lance-spark-bundle` 0.8.0 embeds exactly that pair.
Fix: #13803
### Does this PR introduce _any_ user-facing change?
Yes, two:
1. **Lance's default file format version is now 2.2** (it was 2.1 with
`lance-core` 6.0.0). A table created without blob columns therefore
accepts a later `External("lance.blob")` column but rejects
`External("lance.blob.legacy")`; previously it was the other way round.
Existing tables keep their stored version — an upgrade does not rewrite
it.
2. **A request that names a `branch` or a `tag` is rejected with
`400`.** Against 1.3.0 the same payload already failed, as an unknown
field — a `400` carrying a raw Jackson message as `text/plain`, from
`JacksonFeature`'s own `JsonMappingExceptionMapper`. What changes is
that the refusal is deliberate and carries the Lance error envelope.
Responses also carry an empty `context` map. Branch, materialized-view,
`update_field_metadata` and `rename` endpoints remain unimplemented.
**Not a change, though an earlier revision of this PR claimed it was:**
`lance-spark` 0.2.0 cannot `INSERT` into a table created through
Gravitino's own table API. It passes no data storage version to Lance,
and `FragmentCreateBuilder` resolves the version as
`params.data_storage_version.unwrap_or_default()` without reading the
dataset's manifest, so it always writes file format version 2.0 — while
such a dataset is pinned at `DataStorageFormat::default()`, which is 2.1
on `lance-core` 6.0.0 and 2.2 on 12.0.0. `check_storage_version` refuses
both. Measured both ways: at 2.1 the `INSERT` fails with `The operation
added files with version 2.0. However, the data storage version is
2.1.`, and once the dataset holds rows the mismatch surfaces earlier as
`All data files must have the same version. Detected both 2.2 and 2.0`.
This upgrade changes only the number in the message, and the fix belongs
to the client — `lance-spark` 0.4.0 reads the dataset's version in
`LanceDataset#newWriteBuilder`. Reads are unaffected, as are tables a
connector created itself through `declare`.
No API or property-key changes.
### How was this patch tested?
All of the following pass locally (macOS, JDK 17):
- `:lance:lance-common:test` + `:lance:lance-rest-server:test -PskipITs`
— 313 unit tests
- `:lance:lance-rest-server:test -PskipTests` — 57 ITs across all 6 IT
classes
- `:lance:lance-rest-server:lanceSparkMatrixTest` — 16 tests against
each of `0.2.0`, `0.4.0`, `0.5.1`, `0.6.1`, `0.7.1`, `0.8.0`; 96 total,
1 deliberate skip (`0.2.0`'s write, per the note above)
- `:clients:client-python:lanceRayMatrixTest` — all four rows pass
against a freshly built distribution of this branch: `lance-ray` 0.5.0 /
`lance-namespace` 0.11.1, 0.4.2 / 0.7.5, 0.3.0 / 0.7.5, 0.2.0 / 0.4.5
- `:catalogs:catalog-lakehouse-generic:test` (including
`CatalogGenericCatalogLanceIT`), `:core:coreUnitTest`,
`:spark-connector:spark-3.5:test`, `spotlessCheck`
- `compileDistribution` then `LanceRESTServiceIT -PtestMode=deploy` —
the deploy-mode run is what validates the OpenTelemetry exclusion
against the packaged classpath
Everything above was re-run on the branch as rebased onto current
`main`. For the `lance-ray` rows I also checked each per-version venv's
installed `lance-namespace` and `pylance` rather than trusting the exit
code: 0.2.0/0.4.5/pylance 2.0.1, 0.3.0/0.7.5/6.1.0, 0.4.2/0.7.5/6.1.0,
0.5.0/0.11.1/13.0.0.
New tests:
-
`TestLanceNamespaceOperations#testDescribeTableRejectsBranchAndTagSelectors`
and `#testAlterRequestsRejectBranchSelector` — assert the `400` and,
with `verify(..., never())` on the ops layer, that a refused mutation
never reaches the table. `#testBlankVersionSelectorsAreAccepted` pins
down that a present-but-blank selector is not a refusal.
- `LanceSparkRESTServiceIT#testSparkReadsTableCreatedThroughGravitino` —
covers the one combination the matrix could not reach before: a dataset
written by Gravitino itself, seeded with rows by the server's own
`lance-core` 12.0.0, then read by each bundle's own Lance. It asserts
`Dataset#getLanceFileFormatVersion` is `2.2`, so the matrix fails if the
server's `lance-core` is ever downgraded — without it every test in the
file passed against 6.0.0. `#testSparkWritesToGravitinoCreatedTable`
holds the `INSERT` separately, so a bundle that cannot write no longer
skips the reads with it.
- Three rewritten blob file-format tests in `TestLanceTableOperations`,
and `test_lance_ray_matrix_versions.py` for the `--versions` pairing
parser (10 cases).
Worth flagging in review: the distribution grows ~30 MB (lance-core 12's
jar is 201 MB vs 172 MB), and the weekly matrix job now covers six
`lance-spark` bundles and four `lance-ray` venvs instead of four and
two. The `lance-spark` half measured 1m59s locally for all six; the
`lance-ray` half pays one `ray[data]` + `pylance` install per version,
which is the bulk of its runtime.
---------
Co-authored-by: Qi Yu <[email protected]>
---
.../lance-compatibility-matrix-test-action.yml | 4 +-
.../workflows/lance-compatibility-matrix-test.yml | 10 +-
.../catalog-lakehouse-generic/build.gradle.kts | 8 +-
.../lakehouse/lance/TestLanceTableOperations.java | 86 +++++++++--
clients/client-python/build.gradle.kts | 9 +-
clients/client-python/requirements-dev.txt | 12 +-
.../client-python/scripts/run_lance_ray_matrix.py | 136 ++++++++++++++---
.../unittests/test_lance_ray_matrix_versions.py | 106 +++++++++++++
core/build.gradle.kts | 16 +-
docs/lakehouse-generic-lance-table.md | 15 ++
docs/lance-rest-integration.md | 55 +++++--
docs/lance-rest-service.md | 6 +-
gradle/libs.versions.toml | 4 +-
lance/lance-rest-server/build.gradle.kts | 17 ++-
.../service/rest/JsonNullableMapperProvider.java | 2 +-
.../lance/service/rest/LanceTableOperations.java | 32 +++-
.../integration/test/LanceSparkRESTServiceIT.java | 166 +++++++++++++++++++++
.../service/rest/TestLanceNamespaceOperations.java | 145 ++++++++++++++++++
18 files changed, 752 insertions(+), 77 deletions(-)
diff --git a/.github/workflows/lance-compatibility-matrix-test-action.yml
b/.github/workflows/lance-compatibility-matrix-test-action.yml
index 7258faea0d..18d380ac84 100644
--- a/.github/workflows/lance-compatibility-matrix-test-action.yml
+++ b/.github/workflows/lance-compatibility-matrix-test-action.yml
@@ -6,11 +6,11 @@ on:
lance_spark_versions:
required: false
type: string
- default: '0.2.0,0.4.0,0.5.1'
+ default: '0.2.0,0.4.0,0.5.1,0.6.1,0.7.1,0.8.0'
lance_ray_versions:
required: false
type: string
- default: '0.4.2,0.3.0'
+ default: '0.5.0=0.11.1,0.4.2=0.7.5,0.3.0=0.7.5,0.2.0=0.4.5'
jobs:
lance-spark-matrix:
diff --git a/.github/workflows/lance-compatibility-matrix-test.yml
b/.github/workflows/lance-compatibility-matrix-test.yml
index 955d6a14c4..eac7bd7896 100644
--- a/.github/workflows/lance-compatibility-matrix-test.yml
+++ b/.github/workflows/lance-compatibility-matrix-test.yml
@@ -6,11 +6,11 @@ on:
lance_spark_versions:
description: "Comma-separated lance-spark-bundle versions"
required: false
- default: "0.2.0,0.4.0,0.5.1"
+ default: "0.2.0,0.4.0,0.5.1,0.6.1,0.7.1,0.8.0"
lance_ray_versions:
- description: "Comma-separated lance-ray versions"
+ description: "Comma-separated lance-ray rows, each
<lance-ray>=<lance-namespace>"
required: false
- default: "0.4.2,0.3.0"
+ default: "0.5.0=0.11.1,0.4.2=0.7.5,0.3.0=0.7.5,0.2.0=0.4.5"
schedule:
# Run weekly on main so compatibility drift is caught outside PR
validation.
- cron: "0 18 * * 0"
@@ -26,5 +26,5 @@ jobs:
if: github.event_name != 'schedule' || github.repository ==
'apache/gravitino' || vars.ENABLE_SCHEDULED_TESTS == 'true'
uses: ./.github/workflows/lance-compatibility-matrix-test-action.yml
with:
- lance_spark_versions: ${{ github.event.inputs.lance_spark_versions ||
'0.2.0,0.4.0,0.5.1' }}
- lance_ray_versions: ${{ github.event.inputs.lance_ray_versions ||
'0.4.2,0.3.0' }}
+ lance_spark_versions: ${{ github.event.inputs.lance_spark_versions ||
'0.2.0,0.4.0,0.5.1,0.6.1,0.7.1,0.8.0' }}
+ lance_ray_versions: ${{ github.event.inputs.lance_ray_versions ||
'0.5.0=0.11.1,0.4.2=0.7.5,0.3.0=0.7.5,0.2.0=0.4.5' }}
diff --git a/catalogs/catalog-lakehouse-generic/build.gradle.kts
b/catalogs/catalog-lakehouse-generic/build.gradle.kts
index babe7b3144..0c660be515 100644
--- a/catalogs/catalog-lakehouse-generic/build.gradle.kts
+++ b/catalogs/catalog-lakehouse-generic/build.gradle.kts
@@ -57,7 +57,13 @@ dependencies {
testImplementation(libs.hadoop3.common)
testImplementation(libs.junit.jupiter.api)
testImplementation(libs.junit.jupiter.params)
- testImplementation(libs.lance) // Included in the test runtime classpath for
test only
+ // Included in the test runtime classpath for test only. The distribution
excludes
+ // io.opentelemetry from lance-core (see core/build.gradle.kts), so exclude
it here too: a test
+ // classpath that still carries it would hide a new reference to
org.lance.otel.* that then
+ // fails at runtime with NoClassDefFoundError.
+ testImplementation(libs.lance) {
+ exclude(group = "io.opentelemetry", module = "*")
+ }
testImplementation(libs.mockito.core)
testImplementation(libs.mysql.driver)
testImplementation(libs.postgresql.driver)
diff --git
a/catalogs/catalog-lakehouse-generic/src/test/java/org/apache/gravitino/catalog/lakehouse/lance/TestLanceTableOperations.java
b/catalogs/catalog-lakehouse-generic/src/test/java/org/apache/gravitino/catalog/lakehouse/lance/TestLanceTableOperations.java
index 0e1363b416..687a7fd4d8 100644
---
a/catalogs/catalog-lakehouse-generic/src/test/java/org/apache/gravitino/catalog/lakehouse/lance/TestLanceTableOperations.java
+++
b/catalogs/catalog-lakehouse-generic/src/test/java/org/apache/gravitino/catalog/lakehouse/lance/TestLanceTableOperations.java
@@ -1537,12 +1537,20 @@ public class TestLanceTableOperations {
}
@Test
- public void testAddBlobColumnChecksFileFormatVersion() {
- String location = tempDir.resolve("add-blob").toString();
- try (Dataset ignored =
+ public void testAddBlobV2ColumnRejectedOnLegacyFileFormatVersion() {
+ // The dataset's file format version is pinned to 2.1 through its legacy
blob column rather
+ // than relying on Lance's default, which has changed across lance-core
releases (it is 2.2 as
+ // of 12.0.0). What is under test is the version check, not Lance's choice
of default.
+ String location = tempDir.resolve("add-blob-legacy-dataset").toString();
+ try (Dataset dataset =
lanceTableOps.createDataset(
- location, new Column[] {Column.of("id", Types.IntegerType.get())},
Map.of())) {
- // A dataset without blob columns uses Lance's default file format
version.
+ location,
+ new Column[] {
+ Column.of("id", Types.IntegerType.get()),
+ Column.of("legacy_image",
Types.ExternalType.of("lance.blob.legacy"))
+ },
+ Map.of())) {
+ Assertions.assertEquals("2.1", dataset.getLanceFileFormatVersion());
}
Table table = mock(Table.class);
when(table.properties()).thenReturn(Map.of(Table.PROPERTY_LOCATION,
location));
@@ -1557,19 +1565,75 @@ public class TestLanceTableOperations {
TableChange.addColumn(
new String[] {"image"},
Types.ExternalType.of("lance.blob"))
}));
- Assertions.assertTrue(exception.getMessage().contains("2.2"),
exception.getMessage());
+ // Both rejection messages mention 2.2, so assert the clause that tells
them apart.
+ Assertions.assertTrue(
+ exception.getMessage().contains("requires Lance file format version
2.2 or later"),
+ exception.getMessage());
+ Assertions.assertTrue(
+ exception.getMessage().contains("the dataset uses 2.1"),
exception.getMessage());
+ }
+
+ @Test
+ public void testAddLegacyBlobColumnRejectedOnBlobV2FileFormatVersion() {
+ // Mirror case: a 2.2 dataset rejects the legacy blob encoding. A table
created without blob
+ // columns also lands on 2.2 with lance-core 12.0.0, so this is the path
such a table takes.
+ String location = tempDir.resolve("add-blob-v2-dataset").toString();
+ try (Dataset dataset =
+ lanceTableOps.createDataset(
+ location,
+ new Column[] {
+ Column.of("id", Types.IntegerType.get()),
+ Column.of("image", Types.ExternalType.of("lance.blob"))
+ },
+ Map.of())) {
+ Assertions.assertEquals("2.2", dataset.getLanceFileFormatVersion());
+ }
+ Table table = mock(Table.class);
+ when(table.properties()).thenReturn(Map.of(Table.PROPERTY_LOCATION,
location));
+
+ IllegalArgumentException exception =
+ Assertions.assertThrows(
+ IllegalArgumentException.class,
+ () ->
+ lanceTableOps.handleLanceTableChange(
+ table,
+ new TableChange[] {
+ TableChange.addColumn(
+ new String[] {"legacy_image"},
Types.ExternalType.of("lance.blob.legacy"))
+ }));
+ // Mirror assertion: this message mentions 2.2 twice, so match the
distinguishing clause.
+ Assertions.assertTrue(
+ exception
+ .getMessage()
+ .contains("is not supported by Lance file format version 2.2 or
later"),
+ exception.getMessage());
+ }
+
+ @Test
+ public void testAddBlobV2ColumnSucceedsOnDefaultFileFormatVersion() {
+ // Unlike the two tests above, this one deliberately depends on Lance's
default: the default is
+ // what decides whether a table created without blob columns later accepts
lance.blob, and
+ // docs/lakehouse-generic-lance-table.md states that behaviour as
user-facing. The version
+ // assertion is therefore a canary - if a lance-core upgrade moves the
default below 2.2 this
+ // fails, and the documented behaviour has to be revisited rather than
quietly flipped.
+ String location = tempDir.resolve("add-blob-default").toString();
+ try (Dataset dataset =
+ lanceTableOps.createDataset(
+ location, new Column[] {Column.of("id", Types.IntegerType.get())},
Map.of())) {
+ Assertions.assertEquals("2.2", dataset.getLanceFileFormatVersion());
+ }
+ Table table = mock(Table.class);
+ when(table.properties()).thenReturn(Map.of(Table.PROPERTY_LOCATION,
location));
lanceTableOps.handleLanceTableChange(
table,
new TableChange[] {
- TableChange.addColumn(
- new String[] {"legacy_image"},
Types.ExternalType.of("lance.blob.legacy"))
+ TableChange.addColumn(new String[] {"image"},
Types.ExternalType.of("lance.blob"))
});
try (Dataset dataset = lanceTableOps.openDataset(location, Map.of())) {
Assertions.assertEquals(
- Types.ExternalType.of("lance.blob.legacy"),
- LanceDataTypeConverter.CONVERTER.toGravitino(
- dataset.getSchema().findField("legacy_image")));
+ Types.ExternalType.of("lance.blob"),
+
LanceDataTypeConverter.CONVERTER.toGravitino(dataset.getSchema().findField("image")));
}
}
diff --git a/clients/client-python/build.gradle.kts
b/clients/client-python/build.gradle.kts
index 41de64f8dd..36b2233cc5 100644
--- a/clients/client-python/build.gradle.kts
+++ b/clients/client-python/build.gradle.kts
@@ -310,14 +310,17 @@ tasks {
// Run tests/integration/test_lance_ray.py against multiple lance-ray
// versions. Each version is exercised inside its own venv under
// build/lance-ray-matrix/.venv-<version>/ (cached across runs).
- // Override the matrix with `-PlanceRayVersions=0.4.2,0.3.0`.
+ // Override the matrix with `-PlanceRayVersions=0.4.2=0.7.5,0.3.0=0.7.5`,
+ // where each entry pairs a lance-ray version with the lance-namespace
+ // client it is tested against.
// Override the bootstrap interpreter with
`-PlanceRayPython=/path/to/python`.
register("lanceRayMatrixTest") {
group = "verification"
description =
"Run tests/integration/test_lance_ray.py against multiple lance-ray " +
- "versions. Override with -PlanceRayVersions=<csv> (default: " +
- "tracks docs/lance-rest-integration.md Compatibility Matrix)."
+ "versions. Override with -PlanceRayVersions=<csv>, where each entry " +
+ "is <lance-ray-version>=<lance-namespace-version> (default: tracks " +
+ "docs/lance-rest-integration.md Compatibility Matrix)."
val versions = project.findProperty("lanceRayVersions") as? String
val keepGoing = project.hasProperty("lanceRayKeepGoing")
diff --git a/clients/client-python/requirements-dev.txt
b/clients/client-python/requirements-dev.txt
index 852d7d301c..811f12f15b 100644
--- a/clients/client-python/requirements-dev.txt
+++ b/clients/client-python/requirements-dev.txt
@@ -42,10 +42,14 @@ sphinx==7.1.2
furo==2024.8.6
banks==2.4.5
-# Lance integration deps. Pinned so the default integration test runs against
-# a single, known-good (server-side `lance-namespace-core` 0.7.5+) combination.
-# The multi-version matrix (`:clients:client-python:lanceRayMatrixTest`) keeps
-# its own per-version venvs and does not consume these pins.
+# Lance integration deps. Pinned so the default integration test runs against
one
+# known-good combination instead of whatever pip resolves on the day. The pin
that
+# matters is `lance-namespace==0.7.5`: to satisfy it pip backtracks `pylance`
to
+# 6.1.0, so this lane deliberately drives an older client against the
+# `lance-namespace-core` 0.11.1 the server now embeds - the backward-compatible
+# direction, which is what the lane is here to cover. Current pairings are
covered
+# by the multi-version matrix (`:clients:client-python:lanceRayMatrixTest`),
which
+# keeps its own per-version venvs and does not consume these pins.
ray==2.55.1
lance-ray==0.4.2
lance-namespace==0.7.5
diff --git a/clients/client-python/scripts/run_lance_ray_matrix.py
b/clients/client-python/scripts/run_lance_ray_matrix.py
index f2daecb59e..987f2fe97f 100644
--- a/clients/client-python/scripts/run_lance_ray_matrix.py
+++ b/clients/client-python/scripts/run_lance_ray_matrix.py
@@ -22,12 +22,16 @@ Matrix (``docs/lance-rest-integration.md``).
For each version we provision a dedicated venv under
``clients/client-python/build/lance-ray-matrix/.venv-<version>/`` and install
-``ray``, ``lance-ray==<version>``, ``lance-namespace``, ``requests``, plus the
-in-tree ``apache-gravitino`` distribution (editable). The unittest itself is
-launched per-version with ``python -m unittest -v
+``ray``, ``lance-ray==<version>``, a ``lance-namespace`` pinned per version,
+``requests``, plus the in-tree ``apache-gravitino`` distribution (editable).
+The unittest itself is launched per-version with ``python -m unittest -v
tests.integration.test_lance_ray``; results are collected into a pass/fail
table at the end.
+Each ``--versions`` entry is ``<lance-ray-version>`` or
+``<lance-ray-version>=<lance-namespace-version>``; a bare version falls back to
+``--lance-namespace-spec``. The pairing matters, see ``DEFAULT_VERSIONS``.
+
The caller is responsible for starting the Gravitino server (with the
auxiliary lance-rest service enabled). The Gradle wrapper task
``:clients:client-python:lanceRayMatrixTest`` handles that. For ad-hoc local
@@ -35,7 +39,7 @@ use::
distribution/package/bin/gravitino.sh start
python3 clients/client-python/scripts/run_lance_ray_matrix.py \
- --versions 0.4.2,0.3.0 \
+ --versions 0.5.0=0.11.1,0.4.2=0.7.5 \
--gravitino-home distribution/package
distribution/package/bin/gravitino.sh stop
@@ -57,7 +61,28 @@ from typing import List
# Default version set tracks what the Compatibility Matrix in
# docs/lance-rest-integration.md claims to support. Keep these in sync.
-DEFAULT_VERSIONS = ["0.4.2", "0.3.0"]
+#
+# Each entry pins the lance-namespace client that lance-ray version is tested
+# with. The pairing is curated, not derived: lance-ray never bounds
+# lance-namespace, so a single shared pin or no pin at all would collapse every
+# row onto the same client and the matrix would lose its version spread. The
+# rows below were all measured against a 0.11.1 server:
+#
+# * 0.5.0 is pinned to 0.11.1, the generation the server itself embeds, so
the
+# matrix covers the matching client and not only older ones.
+# * pylance, not lance-ray, is what bounds lance-namespace: pylance 9-11
+# require >=0.8.5,<0.9 and pylance 12-13 require >=0.11.1,<0.12. lance-ray
+# 0.5.0 requires pylance>=9.0.0, so pairing it with 0.7.5 is unsatisfiable
+# and pip fails with ResolutionImpossible; 0.11.1 resolves to pylance
12/13.
+# * lance-namespace 0.6.1 creates tables through the legacy
+# ``POST /v1/table/{id}/create-empty`` endpoint, dropped from the spec in
+# 0.7.5 and never implemented by Gravitino, which serves ``declare``
+# instead. lance-ray 0.3.0 is therefore paired with 0.7.5 rather than the
+# 0.6.1 its own lockfile pins.
+# * 0.2.0 is pinned to 0.4.5 because that uniquely forces pylance 2.0.1:
+# pylance 3.0.0+ require lance-namespace >=0.5.2, and it is pylance 6.0.0
+# that lacks the ``LanceNamespaceStorageOptionsProvider`` 0.2.0 imports.
+DEFAULT_VERSIONS = ["0.5.0=0.11.1", "0.4.2=0.7.5", "0.3.0=0.7.5",
"0.2.0=0.4.5"]
REPO_ROOT = Path(__file__).resolve().parents[3]
@@ -77,6 +102,57 @@ class VersionResult:
details: str
+@dataclass(frozen=True)
+class VersionSpec:
+ """One matrix row: a lance-ray version and the lance-namespace pip spec
+ installed alongside it."""
+
+ version: str
+ lance_namespace_spec: str
+
+
+def parse_version_specs(
+ raw: str, default_lance_namespace_spec: str
+) -> List[VersionSpec]:
+ """Parse a ``--versions`` value into one :class:`VersionSpec` per row.
+
+ Each comma-separated entry is ``<lance-ray-version>`` or
+ ``<lance-ray-version>=<lance-namespace-version>``. An entry without a
+ pairing falls back to ``default_lance_namespace_spec``, so the plain
+ ``--versions 0.4.2,0.3.0`` form keeps working. Blank entries are ignored;
+ a malformed or repeated entry raises :class:`ValueError`.
+ """
+ specs: List[VersionSpec] = []
+ seen = set()
+ for entry in raw.split(","):
+ entry = entry.strip()
+ if not entry:
+ continue
+ version, separator, lance_namespace_version = entry.partition("=")
+ version = version.strip()
+ lance_namespace_version = lance_namespace_version.strip()
+ if not version:
+ raise ValueError(f"missing lance-ray version in entry {entry!r}")
+ if separator and not lance_namespace_version:
+ raise ValueError(
+ f"missing lance-namespace version after '=' in entry {entry!r}"
+ )
+ if version in seen:
+ raise ValueError(f"duplicate lance-ray version {version!r}")
+ seen.add(version)
+ specs.append(
+ VersionSpec(
+ version=version,
+ lance_namespace_spec=(
+ f"lance-namespace=={lance_namespace_version}"
+ if lance_namespace_version
+ else default_lance_namespace_spec
+ ),
+ )
+ )
+ return specs
+
+
def parse_args() -> argparse.Namespace:
p = argparse.ArgumentParser(
description=__doc__,
@@ -85,7 +161,10 @@ def parse_args() -> argparse.Namespace:
p.add_argument(
"--versions",
default=",".join(DEFAULT_VERSIONS),
- help="Comma-separated list of lance-ray versions to test. "
+ help="Comma-separated list of matrix rows. Each row is "
+ "'<lance-ray-version>' or "
+ "'<lance-ray-version>=<lance-namespace-version>'; a row without a "
+ "pairing uses --lance-namespace-spec. "
f"Default: {','.join(DEFAULT_VERSIONS)}",
)
p.add_argument(
@@ -117,9 +196,11 @@ def parse_args() -> argparse.Namespace:
p.add_argument(
"--lance-namespace-spec",
default="lance-namespace==0.7.5",
- help="Pip spec for lance-namespace. Pinned by default so the "
- "matrix is reproducible and does not drift with PyPI. Override "
- "(e.g. 'lance-namespace') for latest. Default: %(default)s",
+ help="Fallback pip spec for lance-namespace, used only by "
+ "--versions rows that carry no '=<lance-namespace-version>' "
+ "pairing. Pinned by default so the matrix is reproducible and does "
+ "not drift with PyPI. Override (e.g. 'lance-namespace') for "
+ "latest. Default: %(default)s",
)
p.add_argument(
"--keep-going",
@@ -292,10 +373,28 @@ def restore_lance_rest_binding_count(conf_path: Path,
original_count: int) -> No
)
+def print_summary(results: List[VersionResult], specs: List[VersionSpec]) ->
None:
+ """Print one aligned line per matrix row, including the pairing it ran."""
+ print("\n========== summary ==========")
+ version_width = max((len(r.version) for r in results), default=0)
+ pins = {spec.version: spec.lance_namespace_spec for spec in specs}
+ pin_width = max((len(p) for p in pins.values()), default=0)
+ for result in results:
+ pin = pins.get(result.version, "").ljust(pin_width)
+ print(
+ f" lance-ray=={result.version.ljust(version_width)} {pin} "
+ f"{result.status:11s} {result.details}"
+ )
+
+
def main() -> int:
args = parse_args()
- versions = [v.strip() for v in args.versions.split(",") if v.strip()]
- if not versions:
+ try:
+ specs = parse_version_specs(args.versions, args.lance_namespace_spec)
+ except ValueError as e:
+ print(f"--versions is invalid: {e}", file=sys.stderr)
+ return 2
+ if not specs:
print("--versions must contain at least one entry", file=sys.stderr)
return 2
@@ -314,8 +413,12 @@ def main() -> int:
original_binding_count = count_lance_rest_binding(conf_path)
results: List[VersionResult] = []
try:
- for version in versions:
- print(f"\n========== lance-ray=={version} ==========")
+ for spec in specs:
+ version = spec.version
+ print(
+ f"\n========== lance-ray=={version} "
+ f"({spec.lance_namespace_spec}) =========="
+ )
venv_dir = matrix_dir / f".venv-{version}"
try:
venv_python = ensure_venv(args.python, venv_dir)
@@ -324,7 +427,7 @@ def main() -> int:
venv_dir,
version,
args.ray_spec,
- args.lance_namespace_spec,
+ spec.lance_namespace_spec,
)
generate_version_ini(venv_python)
except Exception as e: # pylint: disable=broad-exception-caught
@@ -346,10 +449,7 @@ def main() -> int:
finally:
restore_lance_rest_binding_count(conf_path, original_binding_count)
- print("\n========== summary ==========")
- width = max(len(r.version) for r in results) if results else 0
- for r in results:
- print(f" lance-ray=={r.version.ljust(width)} {r.status:11s}
{r.details}")
+ print_summary(results, specs)
any_fail = any(r.status != "ok" for r in results)
return 1 if any_fail else 0
diff --git
a/clients/client-python/tests/unittests/test_lance_ray_matrix_versions.py
b/clients/client-python/tests/unittests/test_lance_ray_matrix_versions.py
new file mode 100644
index 0000000000..f0831272b2
--- /dev/null
+++ b/clients/client-python/tests/unittests/test_lance_ray_matrix_versions.py
@@ -0,0 +1,106 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import unittest
+
+from scripts.run_lance_ray_matrix import (
+ DEFAULT_VERSIONS,
+ parse_version_specs,
+)
+
+FALLBACK = "lance-namespace==0.7.5"
+
+
+class TestLanceRayMatrixVersions(unittest.TestCase):
+ """Covers --versions parsing for the lance-ray compatibility matrix."""
+
+ def test_paired_entry_pins_its_own_lance_namespace(self):
+ specs = parse_version_specs("0.5.0=0.11.1", FALLBACK)
+
+ self.assertEqual(1, len(specs))
+ self.assertEqual("0.5.0", specs[0].version)
+ self.assertEqual("lance-namespace==0.11.1",
specs[0].lance_namespace_spec)
+
+ def test_bare_entry_falls_back_to_default_spec(self):
+ specs = parse_version_specs("0.4.2", FALLBACK)
+
+ self.assertEqual("0.4.2", specs[0].version)
+ self.assertEqual(FALLBACK, specs[0].lance_namespace_spec)
+
+ def test_mixed_entries_keep_order_and_per_row_pins(self):
+ specs = parse_version_specs("0.5.0=0.11.1, 0.4.2 ,0.2.0=0.4.5",
FALLBACK)
+
+ self.assertEqual(
+ [
+ ("0.5.0", "lance-namespace==0.11.1"),
+ ("0.4.2", FALLBACK),
+ ("0.2.0", "lance-namespace==0.4.5"),
+ ],
+ [(s.version, s.lance_namespace_spec) for s in specs],
+ )
+
+ def test_blank_entries_are_ignored(self):
+ specs = parse_version_specs(" , 0.4.2 , ,", FALLBACK)
+
+ self.assertEqual(["0.4.2"], [s.version for s in specs])
+
+ def test_empty_value_yields_no_specs(self):
+ self.assertEqual([], parse_version_specs("", FALLBACK))
+ self.assertEqual([], parse_version_specs(" , ", FALLBACK))
+
+ def test_missing_lance_namespace_version_is_rejected(self):
+ with self.assertRaises(ValueError) as ctx:
+ parse_version_specs("0.5.0=", FALLBACK)
+
+ self.assertIn("missing lance-namespace version", str(ctx.exception))
+
+ def test_missing_lance_ray_version_is_rejected(self):
+ with self.assertRaises(ValueError) as ctx:
+ parse_version_specs("=0.8.6", FALLBACK)
+
+ self.assertIn("missing lance-ray version", str(ctx.exception))
+
+ def test_duplicate_lance_ray_version_is_rejected(self):
+ with self.assertRaises(ValueError) as ctx:
+ parse_version_specs("0.4.2=0.7.5,0.4.2=0.8.6", FALLBACK)
+
+ self.assertIn("duplicate lance-ray version", str(ctx.exception))
+
+ def test_default_versions_parse_to_the_verified_pairings(self):
+ # These pairings are the ones measured against a lance-namespace-core
+ # 0.11.1 server; see DEFAULT_VERSIONS for why each one is what it is.
+ specs = parse_version_specs(",".join(DEFAULT_VERSIONS), FALLBACK)
+
+ self.assertEqual(
+ [
+ ("0.5.0", "lance-namespace==0.11.1"),
+ ("0.4.2", "lance-namespace==0.7.5"),
+ ("0.3.0", "lance-namespace==0.7.5"),
+ ("0.2.0", "lance-namespace==0.4.5"),
+ ],
+ [(s.version, s.lance_namespace_spec) for s in specs],
+ )
+
+ def test_every_default_row_pins_explicitly(self):
+ # A default row that forgot its '=' would silently inherit the
+ # fallback pin, which cannot satisfy lance-ray 0.5.0.
+ for entry in DEFAULT_VERSIONS:
+ self.assertIn("=", entry, f"{entry} carries no lance-namespace
pin")
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/core/build.gradle.kts b/core/build.gradle.kts
index 8519d0e95f..8695e1117a 100644
--- a/core/build.gradle.kts
+++ b/core/build.gradle.kts
@@ -66,13 +66,19 @@ dependencies {
exclude(group = "com.fasterxml.jackson.jaxrs", module =
"jackson-jaxrs-json-provider") // using gravitino's version
exclude(group = "org.apache.httpcomponents.client5", module = "*") //
provided by gravitino
exclude(group = "org.lance", module = "lance-namespace-core") // This is
unnecessary in the core module
- // Same rationale as lance-namespace-core: lance-core 6.0.0 declares
+ // Same rationale as lance-namespace-core: lance-core 12.0.0 declares
// lance-namespace-apache-client as a transitive, but core never calls
into it.
- // Leaving it on the main classpath shadows the lance-rest aux service's
own
- // lance-namespace-apache-client (loaded via lance-rest-server/libs/), and
- // because the aux classloader is parent-first, the older transitive wins
- // on request deserialization (e.g. dropping fields like `check_declared`).
+ // The aux lance-rest service loads its own copy from
lance-rest-server/libs/ and
+ // its classloader is parent-first, so whatever sits on the main classpath
wins.
+ // lance-core 12.0.0 happens to pin the same 0.11.1 this build declares,
so today
+ // that resolves to the same jar; keeping the exclusion means the aux
service's
+ // version stays authoritative if the two ever drift apart again, which is
what
+ // previously broke request deserialization (fields such as
`check_declared`).
exclude(group = "org.lance", module = "lance-namespace-apache-client")
+ // lance-core 12.0.0 added io.opentelemetry:opentelemetry-api as a compile
+ // dependency. Only org.lance.otel.* uses it and instrumentation is opt-in,
+ // which Gravitino never enables, so keep it out of the distribution.
+ exclude(group = "io.opentelemetry", module = "*")
}
implementation(libs.mybatis)
diff --git a/docs/lakehouse-generic-lance-table.md
b/docs/lakehouse-generic-lance-table.md
index c8a713f1de..740c671bc4 100644
--- a/docs/lakehouse-generic-lance-table.md
+++ b/docs/lakehouse-generic-lance-table.md
@@ -123,6 +123,21 @@ them: 2.2 for `lance.blob` and 2.1 for
`lance.blob.legacy`. A table cannot have
column to an existing dataset fails with a clear error if the dataset's file
format version does not
support it.
+A table created without blob columns uses Lance's own default file format
version, 2.2 as of
+`lance-core` 12.0.0, and there is no property to override it. Such a table
accepts a later
+`lance.blob` column but rejects `lance.blob.legacy`; tables created by earlier
releases, whose
+Lance default was below 2.2, behave the other way round and keep their stored
version.
+
+Any Lance client can **read** such a table. **Writing** to it needs a client
that writes at the
+dataset's own file format version rather than at its own default.
`lance-spark` 0.2.0 does not: it
+passes no data storage version to Lance, so every write goes out at
`lance-core` 2.0.0's default of
+2.0 and the commit is refused with `All data files must have the same version.
Detected both 2.2
+and 2.0` — or, while the dataset is still empty, `The operation added files
with version 2.0.
+However, the data storage version is 2.2.` This is not specific to version
2.2: earlier Gravitino
+releases pinned the same tables at 2.1 and refused the same write.
`lance-spark` 0.4.0 and later
+read the dataset's version before writing and are unaffected, as are tables
created *through* a
+connector — that path uses `DeclareTable`, and the connector writes the
dataset at its own version.
+
Only the blob marker is recognized. Other blob metadata, such as
`lance-encoding:blob-dedicated-size-threshold`, is not shown in the Gravitino
type, and columns created
through Gravitino use Lance's defaults. A blob field in any other layout, for
example a blob v2 struct
diff --git a/docs/lance-rest-integration.md b/docs/lance-rest-integration.md
index b2b1fb607f..1df3adfb45 100644
--- a/docs/lance-rest-integration.md
+++ b/docs/lance-rest-integration.md
@@ -20,10 +20,11 @@ This documentation assumes familiarity with the Lance REST
service setup as desc
The following table outlines the tested compatibility between Gravitino
versions and Lance connector versions:
-| Gravitino Version (Lance REST) | Supported lance-spark Versions | Supported
lance-ray Versions |
-| ------------------------------ | ------------------------------ |
--------------------------------------------- |
-| 1.1.1 - 1.2.1 | 0.0.10 - 0.0.15 | 0.0.6 -
0.0.8 |
-| 1.3.0 | 0.2.0, 0.4.0, 0.5.1 | 0.3.0 -
0.4.2 (0.2.0 conditionally supported) |
+| Gravitino Version (Lance REST) | Supported lance-spark Versions |
Supported lance-ray Versions |
+| ------------------------------ | ---------------------------------------- |
------------------------------------------------------------------------ |
+| 1.1.1 - 1.2.1 | 0.0.10 - 0.0.15 |
0.0.6 - 0.0.8 |
+| 1.3.0 | 0.2.0, 0.4.0, 0.5.1 |
0.3.0 - 0.4.2 (0.2.0 conditionally supported) |
+| 2.0.0 | 0.2.0, 0.4.0, 0.5.1, 0.6.1, 0.7.1, 0.8.0 |
0.2.0 + `lance-namespace` 0.4.5; 0.3.0 and 0.4.2 + 0.7.5; 0.5.0 + 0.11.1 |
:::note
- These version entries show which versions are expected to work together.
@@ -37,9 +38,10 @@ The following table outlines the tested compatibility
between Gravitino versions
exposes — the table-declaration path was consolidated onto
`POST /lance/v1/table/{id}/declare` (`LanceTableOperations#declareTable`)
when the deprecated `createEmptyTable` API was removed during the
- `lance-namespace-core` 0.7.5 upgrade. Running 0.1.x against 1.3.0 surfaces
- as `404 Not Found` on every table-creation flow; the small set of
- list/describe-only tests still works, but any write path will fail.
+ `lance-namespace-core` 0.7.5 upgrade. Every table-creation flow fails; the
+ small set of list/describe-only tests still works. The failure surfaces as
+ `500 Internal Server Error`, not `404 Not Found` — see the note on
+ unimplemented endpoints below, which applies to 1.3.0 as well.
- **`lance-ray` 0.1.0 is not supported on Gravitino 1.3.0.** It exposes
`write_lance(... namespace=<LanceNamespace>)`, whereas the 0.2.0+ test path
uses the new `write_lance(... namespace_impl="rest",
@@ -53,6 +55,21 @@ The following table outlines the tested compatibility
between Gravitino versions
raising `ImportError: cannot import name
'LanceNamespaceStorageOptionsProvider' from 'lance'`. You can use
`lance-ray` 0.2.0 with Gravitino 1.3.0 by pinning `pylance` to 3.x or 4.x.
+- **Gravitino 2.0.0 embeds `lance-core` 12.0.0 and `lance-namespace-core`
0.11.1**, the pair
+ `lance-spark` 0.8.0 is built on. Older clients keep working: none of the
0.11.1 spec changes
+ reaches the endpoints Gravitino serves, and responses only gained an empty
`context` map, which
+ older clients ignore. Lance branches and tags are not implemented, so a
request setting `branch`
+ or `tag` is rejected with `400`.
+- **`lance-spark` 0.2.0 cannot write to a table created through the Gravitino
table API**, on
+ 2.0.0 and on every earlier release alike. It passes no data storage version
to Lance, so it
+ writes at its own `lance-core` 2.0.0 default of file format version 2.0
while such a dataset is
+ pinned at the server's `lance-core` default — 2.2 on 2.0.0, 2.1 on 1.3.0 —
and Lance refuses the
+ commit. Reads are unaffected, and so are tables a connector created itself
through
+ `POST /lance/v1/table/{id}/declare`, which the connector writes at its own
version.
+ `lance-spark` 0.4.0 and later read the dataset's version before writing and
have no such limit.
+- **An unimplemented endpoint answers `500`, not `404`**, because
`LanceExceptionMapper` matches
+ only Gravitino's own `NotFoundException`. A call to a removed endpoint
therefore looks like an
+ internal error.
- Before using in production, test the exact connector versions in your own
environment.
- The Lance ecosystem is changing quickly, so some versions may introduce
breaking changes.
:::
@@ -87,18 +104,21 @@ Generic Catalog unknown-format loading errors or change
the Generic Catalog's fo
Both connectors ship with a multi-version integration test driver so the
matrix can be re-verified (and extended) without ad-hoc scripting:
-For Lance Spark, the default `test` task uses the explicitly verified `0.5.1`
+For Lance Spark, the default `test` task uses the explicitly verified `0.8.0`
bundle, while `lanceSparkMatrixTest` uses the declared matrix
-(`0.2.0`, `0.4.0`, and `0.5.1`). Passing `-PlanceSparkBundleVersions=...` is a
-targeted diagnostic override; the supplied versions form the matrix and the
-first supplied version remains the primary for the normal `test` task.
+(`0.2.0`, `0.4.0`, `0.5.1`, `0.6.1`, `0.7.1`, and `0.8.0`), which spans every
+`lance-namespace` generation a released bundle speaks. Passing
+`-PlanceSparkBundleVersions=...` is a targeted diagnostic override; the
supplied
+versions form the matrix and the first supplied version remains the primary for
+the normal `test` task.
```bash
# lance-spark — runs LanceSparkRESTServiceIT once per bundle version.
# The default list intentionally omits 0.1.0 / 0.1.1: those bundles call the
-# removed /create-empty endpoint and will fail with 404 against 1.3.0+.
+# removed /create-empty endpoint and will fail against 1.3.0+ (as a 500, see
the
+# note on unimplemented endpoints in the Compatibility Matrix section).
./gradlew :lance:lance-rest-server:lanceSparkMatrixTest \
- -PlanceSparkBundleVersions=0.2.0,0.4.0,0.5.1 \
+ -PlanceSparkBundleVersions=0.2.0,0.4.0,0.5.1,0.6.1,0.7.1,0.8.0 \
-PskipDockerTests=true
# Per-version JUnit reports land under
# lance/lance-rest-server/build/reports/lance-spark-matrix/<version>/.
@@ -106,9 +126,11 @@ first supplied version remains the primary for the normal
`test` task.
# lance-ray — provisions a venv per version under
# clients/client-python/build/lance-ray-matrix/.venv-<version>/ and runs
# tests/integration/test_lance_ray.py against each. The Gradle wrapper
-# below starts / stops Gravitino automatically.
+# below starts / stops Gravitino automatically. Each entry is
+# <lance-ray-version>=<lance-namespace-version>; `lance-ray` does not bound
+# `lance-namespace` itself, so the pairing has to be given per version.
./gradlew :clients:client-python:lanceRayMatrixTest \
- -PlanceRayVersions=0.4.2,0.3.0
+ -PlanceRayVersions=0.5.0=0.11.1,0.4.2=0.7.5,0.3.0=0.7.5,0.2.0=0.4.5
```
### Rationale
@@ -305,7 +327,8 @@ pip install lance-ray
:::info
- Ray will be automatically installed if not already present
- For Gravitino 1.3.0, use a `lance-namespace` client compatible with
- server-side `lance-namespace-core` 0.7.5 or newer.
+ server-side `lance-namespace-core` 0.7.5 or newer; Gravitino 2.0.0 serves
+ `lance-namespace-core` 0.11.1, which also accepts those older clients.
- Ensure Ray version compatibility in your environment before deployment
:::
diff --git a/docs/lance-rest-service.md b/docs/lance-rest-service.md
index 53f1acd054..b3819d1935 100644
--- a/docs/lance-rest-service.md
+++ b/docs/lance-rest-service.md
@@ -309,6 +309,8 @@ URL encoded: lance_catalog%24schema%24table01
- Tables **cannot** be nested deeper than schema level
- Parent catalog must be created in Gravitino before using Lance REST API
- Namespace deletion defaults to `restrict`; use `cascade` to remove child
metadata
+- Lance **branches and tags** are not implemented; a request setting `branch`
or `tag` is
+ rejected with HTTP `400`
:::
## Error responses
@@ -516,7 +518,7 @@ curl -X POST \
<TabItem value="java" label="Java">
```java
-// Add dependency: implementation("org.lance:lance-namespace-core:0.4.5")
+// Add dependency: implementation("org.lance:lance-namespace-core:0.11.1")
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
@@ -582,7 +584,7 @@ tableApi.createTable(
<TabItem value="python" label="Python">
```python
-# Install: pip install lance-namespace==0.4.5
+# Install: pip install lance-namespace==0.11.1
import lance_namespace as ln
import requests
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 6ab9ece112..706b064ab5 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -40,8 +40,8 @@ lombok = "1.18.20"
slf4j = "2.0.17"
log4j = "2.25.4"
arrow = "18.3.0"
-lance = "6.0.0"
-lance-namespace = "0.7.5"
+lance = "12.0.0"
+lance-namespace = "0.11.1"
delta-kernel = "3.3.0"
jetty = "9.4.58.v20250814"
jersey = "2.41"
diff --git a/lance/lance-rest-server/build.gradle.kts
b/lance/lance-rest-server/build.gradle.kts
index ec56602eb5..aceeca5cba 100644
--- a/lance/lance-rest-server/build.gradle.kts
+++ b/lance/lance-rest-server/build.gradle.kts
@@ -30,19 +30,23 @@ val sparkVersion: String = libs.versions.spark35.get()
val scalaCollectionCompatVersion: String =
libs.versions.scala.collection.compat.get()
// Comma-separated list of lance-spark-bundle versions to test against.
// Without an explicit property, the integration test matrix covers every
-// declared version and the normal test task uses 0.5.1 as its primary bundle.
+// declared version and the normal test task uses 0.8.0 as its primary bundle,
+// since 0.8.0 is the bundle built on lance-core 12.0.0 / lance-namespace
0.11.1.
+// The default list spans every lance-namespace generation a released bundle
+// speaks: pre-0.7 (0.2.0, 0.4.0), 0.7.5 (0.5.1), 0.8.6 (0.6.1, 0.7.1) and
+// 0.11.1 (0.8.0).
// An explicit property is a targeted diagnostic override; its first version
// remains the primary bundle for compatibility with the existing behavior.
val lanceSparkBundleVersionsProperty =
project.properties["lanceSparkBundleVersions"] as? String
val lanceSparkBundleVersions: List<String> =
- (lanceSparkBundleVersionsProperty ?: "0.2.0,0.4.0,0.5.1")
+ (lanceSparkBundleVersionsProperty ?: "0.2.0,0.4.0,0.5.1,0.6.1,0.7.1,0.8.0")
.split(",").map { it.trim() }.filter { it.isNotEmpty() }.distinct()
if (lanceSparkBundleVersions.isEmpty()) {
throw GradleException("lanceSparkBundleVersions must contain at least one
version")
}
val primaryLanceSparkBundleVersion: String =
if (lanceSparkBundleVersionsProperty == null) {
- "0.5.1"
+ "0.8.0"
} else {
lanceSparkBundleVersions.first()
}
@@ -128,7 +132,12 @@ dependencies {
testImplementation(project(":spark-connector:spark-3.5"))
testImplementation(project(":integration-test-common", "testArtifacts"))
testImplementation(project(":server-common", "testArtifacts"))
- testImplementation(libs.lance)
+ // The distribution excludes io.opentelemetry from lance-core (see
core/build.gradle.kts),
+ // so exclude it here too: a test classpath that still carries it would hide
a new reference
+ // to org.lance.otel.* that then fails at runtime with NoClassDefFoundError.
+ testImplementation(libs.lance) {
+ exclude(group = "io.opentelemetry", module = "*")
+ }
testImplementation(libs.lance.namespace.apache.client)
lanceSparkBundleVersions.forEach { version ->
diff --git
a/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/JsonNullableMapperProvider.java
b/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/JsonNullableMapperProvider.java
index 31470e1a7b..db677cdcd4 100644
---
a/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/JsonNullableMapperProvider.java
+++
b/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/JsonNullableMapperProvider.java
@@ -28,7 +28,7 @@ import org.openapitools.jackson.nullable.JsonNullableModule;
* JAX-RS {@link ContextResolver} that provides an {@link ObjectMapper} with
the {@link
* JsonNullableModule} registered.
*
- * <p>lance-namespace 0.7.5 models use {@code JsonNullable<T>} for optional
fields, which requires
+ * <p>lance-namespace 0.11.1 models use {@code JsonNullable<T>} for optional
fields, which requires
* this module for correct Jackson serialization/deserialization.
*/
@Provider
diff --git
a/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceTableOperations.java
b/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceTableOperations.java
index fcc48afdb0..331efd15d3 100644
---
a/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceTableOperations.java
+++
b/lance/lance-rest-server/src/main/java/org/apache/gravitino/lance/service/rest/LanceTableOperations.java
@@ -34,6 +34,7 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import java.util.Map;
import java.util.Optional;
+import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.DefaultValue;
@@ -343,10 +344,11 @@ public class LanceTableOperations {
// No specific fields to validate for now
}
- private void validateDescribeTableRequest(
- @SuppressWarnings("unused") DescribeTableRequest request) {
+ private void validateDescribeTableRequest(DescribeTableRequest request) {
// We will ignore the id in the request body since it's already provided
in the path param
- // No specific fields to validate for now
+ if (request != null) {
+ validateVersionSelectors(request.getBranch(), request.getTag());
+ }
}
private void validateTableExists(@SuppressWarnings("unused")
TableExistsRequest request) {
@@ -361,6 +363,7 @@ public class LanceTableOperations {
private void validateDropColumnsRequest(AlterTableDropColumnsRequest
request) {
Preconditions.checkArgument(request != null, "Request body must not be
null");
+ validateVersionSelectors(request.getBranch(), null);
Preconditions.checkArgument(request.getColumns() != null, "columns must
not be null");
Preconditions.checkArgument(
!request.getColumns().isEmpty(), "Columns to drop cannot be empty.");
@@ -371,6 +374,7 @@ public class LanceTableOperations {
private void validateAlterColumnsRequest(AlterTableAlterColumnsRequest
request) {
Preconditions.checkArgument(request != null, "Request body must not be
null");
+ validateVersionSelectors(request.getBranch(), null);
Preconditions.checkArgument(request.getAlterations() != null, "alterations
must not be null");
Preconditions.checkArgument(
!request.getAlterations().isEmpty(), "Columns to alter cannot be
empty.");
@@ -390,6 +394,28 @@ public class LanceTableOperations {
}
}
+ // lance-namespace 0.11.1 added optional `branch` and `tag` selectors to the
describe and
+ // alter requests. Gravitino keeps a single Lance history per table and
implements neither, so a
+ // request naming one is rejected: ignoring it would silently apply a
mutation meant for a branch
+ // to the table itself, and answer a tag-pinned read with the table's
current state. The 0.7.5
+ // models had no such fields, so these payloads used to fail deserialization
instead.
+ //
+ // The alter requests are called with a null tag because in 0.11.1 only
DescribeTableRequest
+ // declares `tag`; AlterTableDropColumnsRequest and
AlterTableAlterColumnsRequest carry `branch`
+ // alone. If a later spec adds `tag` to them, pass it here instead of null,
or the selector goes
+ // through unchecked.
+ //
+ // A present but blank selector is accepted: it names no branch or tag, so
there is nothing to
+ // refuse, and rejecting it would break clients that serialize empty strings
for unset fields.
+ private static void validateVersionSelectors(@Nullable String branch,
@Nullable String tag) {
+ Preconditions.checkArgument(
+ StringUtils.isBlank(branch),
+ "Lance table branches are not supported, got branch: %s",
+ branch);
+ Preconditions.checkArgument(
+ StringUtils.isBlank(tag), "Lance table tags are not supported, got
tag: %s", tag);
+ }
+
private static String normalizeCreateTableMode(String mode) {
if (mode == null) {
return "create";
diff --git
a/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/integration/test/LanceSparkRESTServiceIT.java
b/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/integration/test/LanceSparkRESTServiceIT.java
index 9a2d2d42bd..99e8c873de 100644
---
a/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/integration/test/LanceSparkRESTServiceIT.java
+++
b/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/integration/test/LanceSparkRESTServiceIT.java
@@ -36,7 +36,13 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import java.util.stream.Collectors;
+import org.apache.arrow.memory.RootAllocator;
+import org.apache.arrow.vector.Float4Vector;
+import org.apache.arrow.vector.IntVector;
+import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.commons.io.FileUtils;
import org.apache.gravitino.Catalog;
import org.apache.gravitino.NameIdentifier;
@@ -45,7 +51,10 @@ import org.apache.gravitino.client.GravitinoMetalake;
import org.apache.gravitino.integration.test.util.BaseIT;
import org.apache.gravitino.integration.test.util.GravitinoITUtils;
import org.apache.gravitino.lance.common.utils.LanceConstants;
+import org.apache.gravitino.rel.Column;
import org.apache.gravitino.rel.Table;
+import org.apache.gravitino.rel.expressions.transforms.Transforms;
+import org.apache.gravitino.rel.types.Types;
import
org.apache.gravitino.spark.connector.plugin.restcatalog.GravitinoLakehouseRESTDiscoveryPlugin;
import org.apache.spark.SparkConf;
import org.apache.spark.sql.AnalysisException;
@@ -54,8 +63,14 @@ import org.apache.spark.sql.SparkSession;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import org.lance.Dataset;
+import org.lance.Fragment;
+import org.lance.FragmentMetadata;
+import org.lance.WriteParams;
+import org.lance.operation.Append;
public class LanceSparkRESTServiceIT extends BaseIT {
@@ -71,6 +86,12 @@ public class LanceSparkRESTServiceIT extends BaseIT {
private static final String HISTORY_CATALOG_NAME =
GravitinoITUtils.genRandomName("lance_history_catalog");
private static final String TABLE_COLUMNS = "(id INT, score FLOAT)";
+ // lance-spark bundles that write at their own Lance's default file format
version instead of
+ // the target dataset's, so they cannot write to a dataset Gravitino
created. See
+ // testSparkWritesToGravitinoCreatedTable.
+ private static final Set<String> BUNDLES_IGNORING_DATASET_FORMAT_VERSION =
Set.of("0.2.0");
+ private static final Pattern BUNDLE_VERSION_PATTERN =
+
Pattern.compile("lance-spark-bundle-[^/]*?-(\\d+\\.\\d+\\.\\d+(?:-[\\w.]+)?)\\.jar$");
private static final String LANCE_CLASS_PREFIX = "org.lance.";
private static final String LANCE_NATIVE_LOADER_CLASS_PREFIX =
"io.questdb.jar.jni.";
private static final String LANCE_NATIVE_RESOURCE_PREFIX = "nativelib/";
@@ -287,6 +308,71 @@ public class LanceSparkRESTServiceIT extends BaseIT {
Assertions.assertTrue(rows.isEmpty(), "Expected no rows for a newly
created empty table");
}
+ @Test
+ public void testSparkReadsTableCreatedThroughGravitino() {
+ String schemaName = createSchema("spark_gravitino_created");
+ String tableName = newTableName("orders");
+ String location = createTableThroughGravitinoApi(schemaName, tableName);
+
+ // Anchor the matrix to the lance-core this build embeds: a dataset
created with no blob
+ // column keeps lance-core's own default file format version, which is 2.2
as of 12.0.0 and
+ // was 2.1 on the 6.0.0 this release upgrades from. Without this assertion
nothing in the
+ // test would notice a downgrade of the server's Lance.
+ try (Dataset dataset = Dataset.open().uri(location).build()) {
+ Assertions.assertEquals("2.2", dataset.getLanceFileFormatVersion());
+ }
+
+ // First the manifest on its own: a freshly created dataset holds no data
files, so this only
+ // proves the bundle can open a manifest written by lance-core 12.0.0.
+ Assertions.assertTrue(
+ sql("SELECT id, score FROM %s.%s", schemaName, tableName).isEmpty(),
+ "Expected no rows in a freshly created Lance dataset");
+
+ // Then the data files. Gravitino's API never writes rows, so seed them
here with the same
+ // lance-core the server runs - 12.0.0, at file format version 2.2 - and
read them back
+ // through the bundle. Without this the SELECT above would be the only
read in the test and
+ // the matrix would never decode a byte written by the new writer. Every
bundle in the matrix
+ // reaches this point, including the ones that cannot write such a dataset.
+ appendRowsWithServerLance(location);
+
+ List<Row> seededRows = sql("SELECT id, score FROM %s.%s ORDER BY id",
schemaName, tableName);
+ Assertions.assertEquals(2, seededRows.size());
+ assertRow(seededRows.get(0), 1, 1.5f);
+ assertRow(seededRows.get(1), 2, 2.5f);
+ }
+
+ @Test
+ public void testSparkWritesToGravitinoCreatedTable() {
+ // Writing into a Gravitino-created dataset is where the bundles differ.
lance-spark 0.2.0
+ // passes no data storage version to Lance, so every write goes out at its
own lance-core's
+ // default - 2.0 for lance-core 2.0.0 - whatever the dataset says, and the
commit is refused:
+ // "All data files must have the same version. Detected both 2.2 and 2.0"
once the dataset
+ // holds rows, or "The operation added files with version 2.0. However,
the data storage
+ // version is 2.2." while it is still empty. This is not a change in this
release: the
+ // previous lance-core 6.0.0 pinned the same datasets at 2.1 and refused
the same write.
+ // lance-spark 0.4.0 reads the dataset's version first
(LanceDataset#newWriteBuilder) and is
+ // unaffected, which is why only 0.2.0 is listed below.
+ Assumptions.assumeFalse(
+
BUNDLES_IGNORING_DATASET_FORMAT_VERSION.contains(lanceSparkBundleVersion()),
+ "lance-spark "
+ + lanceSparkBundleVersion()
+ + " writes at its own Lance's default file format version instead
of the dataset's, "
+ + "so it cannot write to a dataset created through the Gravitino
table API");
+
+ String schemaName = createSchema("spark_gravitino_created_write");
+ String tableName = newTableName("orders");
+ String location = createTableThroughGravitinoApi(schemaName, tableName);
+ appendRowsWithServerLance(location);
+
+ sql("INSERT INTO %s.%s VALUES (3, CAST(3.5 AS FLOAT))", schemaName,
tableName);
+
+ List<Row> rows = sql("SELECT id, score FROM %s.%s ORDER BY id",
schemaName, tableName);
+ Assertions.assertEquals(3, rows.size());
+ assertRow(rows.get(0), 1, 1.5f);
+ assertRow(rows.get(1), 2, 2.5f);
+ assertRow(rows.get(2), 3, 3.5f);
+ }
+
@Test
public void testSelectWithFilterViaSpark() {
String schemaName = createSchema("spark_filter_tbl");
@@ -545,6 +631,42 @@ public class LanceSparkRESTServiceIT extends BaseIT {
}
}
+ /** Returns the lance-spark bundle version this run is testing against, from
its jar name. */
+ private static String lanceSparkBundleVersion() {
+ String jarPath = System.getProperty(LANCE_SPARK_BUNDLE_JAR_PATH_PROPERTY,
"");
+ Matcher matcher = BUNDLE_VERSION_PATTERN.matcher(jarPath);
+ return matcher.find() ? matcher.group(1) : "";
+ }
+
+ /**
+ * Creates a table through Gravitino's own table API and returns its dataset
location. Of the
+ * paths that reach {@code LanceTableOperations#createDataset}, this is the
only one a Spark
+ * bundle can be pointed at afterwards: Spark's own CREATE TABLE goes
through `declare`, where
+ * Gravitino writes no dataset at all and the bundle creates it at its own
file format version.
+ */
+ private String createTableThroughGravitinoApi(String schemaName, String
tableName) {
+ catalog
+ .asTableCatalog()
+ .createTable(
+ NameIdentifier.of(schemaName, tableName),
+ new Column[] {
+ Column.of("id", Types.IntegerType.get()), Column.of("score",
Types.FloatType.get())
+ },
+ "created through the Gravitino API",
+ // Deliberately no LANCE_TABLE_DECLARED: that is the `declare`
path, where Gravitino
+ // writes no dataset and the point of these tests is lost.
+ ImmutableMap.of("format", "lance"),
+ Transforms.EMPTY_TRANSFORM,
+ null,
+ null);
+
+ Table createdTable =
+ catalog.asTableCatalog().loadTable(NameIdentifier.of(schemaName,
tableName));
+ String location = createdTable.properties().get(Table.PROPERTY_LOCATION);
+ Assertions.assertNotNull(location, "Expected Gravitino to persist a table
location");
+ return location;
+ }
+
private String createSchema(String schemaNamePrefix) {
String schemaName = newSchemaName(schemaNamePrefix);
sql("CREATE DATABASE %s", schemaName);
@@ -592,6 +714,50 @@ public class LanceSparkRESTServiceIT extends BaseIT {
.collect(Collectors.toList());
}
+ /**
+ * Appends two rows to {@code tableLocation} with the test JVM's lance-core,
which is the version
+ * the Gravitino server itself writes with. The bundle's Lance lives in a
child-first class
+ * loader, so these rows are written by 12.0.0 and read back by whatever
Lance the bundle ships.
+ */
+ private void appendRowsWithServerLance(String tableLocation) {
+ Assertions.assertNotNull(tableLocation, "Expected Gravitino to persist a
table location");
+
+ try (RootAllocator allocator = new RootAllocator();
+ Dataset dataset = Dataset.open().uri(tableLocation).build()) {
+ List<FragmentMetadata> fragments;
+ try (VectorSchemaRoot root =
VectorSchemaRoot.create(dataset.getSchema(), allocator)) {
+ root.allocateNew();
+ IntVector ids = (IntVector) root.getVector("id");
+ Float4Vector scores = (Float4Vector) root.getVector("score");
+ ids.setSafe(0, 1);
+ scores.setSafe(0, 1.5f);
+ ids.setSafe(1, 2);
+ scores.setSafe(1, 2.5f);
+ root.setRowCount(2);
+
+ // No data storage version on the write params: the point is to write
exactly what
+ // lance-core 12.0.0 writes by default.
+ fragments =
+ Fragment.write()
+ .datasetUri(tableLocation)
+ .allocator(allocator)
+ .data(root)
+ .writeParams(new WriteParams.Builder().build())
+ .execute();
+ }
+
+ try (Dataset ignored =
+ dataset
+ .newTransactionBuilder()
+ .operation(Append.builder().fragments(fragments).build())
+ .transactionProperties(Map.of())
+ .build()
+ .commit()) {
+ // The dataset handle returned by the commit is closed once the rows
are durable.
+ }
+ }
+ }
+
private String newSchemaName(String prefix) {
return GravitinoITUtils.genRandomName(prefix);
}
diff --git
a/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/service/rest/TestLanceNamespaceOperations.java
b/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/service/rest/TestLanceNamespaceOperations.java
index 2947bbb3ee..14c9cb6d7a 100644
---
a/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/service/rest/TestLanceNamespaceOperations.java
+++
b/lance/lance-rest-server/src/test/java/org/apache/gravitino/lance/service/rest/TestLanceNamespaceOperations.java
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
import static org.mockito.Mockito.when;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -753,6 +754,150 @@ public class TestLanceNamespaceOperations extends
JerseyTest {
Assertions.assertEquals("", errorResp.getDetail());
}
+ @Test
+ void testDescribeTableResponseCarriesEmptyContext() {
+ Mockito.reset(tableOps);
+ String tableIds = "catalog.scheme.describe_table_new_fields";
+ String delimiter = ".";
+
+ DescribeTableResponse describeTableResponse = new DescribeTableResponse();
+ describeTableResponse.setLocation("/path/to/describe_table_new_fields");
+ when(tableOps.describeTable(any(), any(), any(), anyBoolean(),
anyBoolean()))
+ .thenReturn(describeTableResponse);
+
+ // Sent as raw JSON rather than a built request object, so the assertion
is about the wire
+ // payload a 0.11.1 client produces rather than about the model's getters.
+ String rawRequest =
+
"{\"id\":[\"catalog\",\"scheme\",\"describe_table_new_fields\"],\"version\":3}";
+ Response resp =
+ target(String.format("/v1/table/%s/describe", tableIds))
+ .queryParam("delimiter", delimiter)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.entity(rawRequest, MediaType.APPLICATION_JSON_TYPE));
+
+ Assertions.assertEquals(Response.Status.OK.getStatusCode(),
resp.getStatus());
+ Mockito.verify(tableOps)
+ .describeTable(eq(tableIds), eq(delimiter), eq(Optional.of(3L)),
eq(false), eq(true));
+
+ // The 0.11.1 response models carry a new `context` map. Gravitino never
populates it, but the
+ // generated model defaults it to an empty map, so it is serialized as
`"context":{}` rather
+ // than omitted. That is still compatible with older clients, which ignore
unknown fields
+ // (the 0.7.5 Java client sets FAIL_ON_UNKNOWN_PROPERTIES=false and the
Python model uses
+ // pydantic's default extra="ignore"). Pin down that the field stays
empty, so the response
+ // carries no context the server did not intend to send.
+ String body = resp.readEntity(String.class);
+ Assertions.assertTrue(body.contains("\"context\":{}"), body);
+ }
+
+ @Test
+ void testDescribeTableRejectsBranchAndTagSelectors() {
+ Mockito.reset(tableOps);
+ String tableIds = "catalog.scheme.describe_table_selectors";
+ String delimiter = ".";
+
+ // lance-namespace 0.11.1 added `branch` and `tag` to
DescribeTableRequest. Gravitino resolves
+ // neither, and answering with the table's current state would hand the
caller a different
+ // snapshot than it asked for, so both selectors must be refused. Raw
JSON, because the point
+ // is what an upgraded client puts on the wire.
+ String withBranch =
+
"{\"id\":[\"catalog\",\"scheme\",\"describe_table_selectors\"],\"branch\":\"dev\"}";
+ Response resp =
+ target(String.format("/v1/table/%s/describe", tableIds))
+ .queryParam("delimiter", delimiter)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.entity(withBranch, MediaType.APPLICATION_JSON_TYPE));
+ Assertions.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(),
resp.getStatus());
+ ErrorResponse errorResp = resp.readEntity(ErrorResponse.class);
+ Assertions.assertEquals(
+ "Lance table branches are not supported, got branch: dev",
errorResp.getError());
+
+ String withTag =
+
"{\"id\":[\"catalog\",\"scheme\",\"describe_table_selectors\"],\"tag\":\"v1\"}";
+ resp =
+ target(String.format("/v1/table/%s/describe", tableIds))
+ .queryParam("delimiter", delimiter)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.entity(withTag, MediaType.APPLICATION_JSON_TYPE));
+ Assertions.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(),
resp.getStatus());
+ errorResp = resp.readEntity(ErrorResponse.class);
+ Assertions.assertEquals(
+ "Lance table tags are not supported, got tag: v1",
errorResp.getError());
+
+ // Neither request may reach the backing operations.
+ Mockito.verify(tableOps, never())
+ .describeTable(any(), any(), any(), anyBoolean(), anyBoolean());
+ }
+
+ @Test
+ void testBlankVersionSelectorsAreAccepted() {
+ Mockito.reset(tableOps);
+ String tableIds = "catalog.scheme.describe_table_blank_selectors";
+ String delimiter = ".";
+
+ DescribeTableResponse describeTableResponse = new DescribeTableResponse();
+
describeTableResponse.setLocation("/path/to/describe_table_blank_selectors");
+ when(tableOps.describeTable(any(), any(), any(), anyBoolean(),
anyBoolean()))
+ .thenReturn(describeTableResponse);
+
+ // A client that serializes unset optional fields as empty strings is not
asking for a branch
+ // or a tag, so the selector guard must let it through rather than answer
400. Raw JSON,
+ // because the point is the wire payload: a built request object would
leave the fields null
+ // and never exercise the blank case.
+ String blankSelectors =
+ "{\"id\":[\"catalog\",\"scheme\",\"describe_table_blank_selectors\"],"
+ + "\"branch\":\"\",\"tag\":\"\"}";
+ Response resp =
+ target(String.format("/v1/table/%s/describe", tableIds))
+ .queryParam("delimiter", delimiter)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.entity(blankSelectors,
MediaType.APPLICATION_JSON_TYPE));
+
+ Assertions.assertEquals(Response.Status.OK.getStatusCode(),
resp.getStatus());
+ Mockito.verify(tableOps)
+ .describeTable(eq(tableIds), eq(delimiter), eq(Optional.empty()),
eq(false), eq(true));
+ }
+
+ @Test
+ void testAlterRequestsRejectBranchSelector() {
+ Mockito.reset(tableOps);
+ String tableIds = "catalog.scheme.alter_table_branch_selector";
+ String delimiter = ".";
+
+ // 0.11.1 also added `branch` to the two alter requests Gravitino serves.
A mutation aimed at a
+ // branch must not fall through to the table itself, so assert both the
rejection and that no
+ // alterTable call was made at all.
+ AlterTableDropColumnsRequest dropColumnsRequest = new
AlterTableDropColumnsRequest();
+ dropColumnsRequest.setColumns(List.of("id"));
+ dropColumnsRequest.setBranch("dev");
+ Response resp =
+ target(String.format("/v1/table/%s/drop_columns", tableIds))
+ .queryParam("delimiter", delimiter)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.entity(dropColumnsRequest,
MediaType.APPLICATION_JSON_TYPE));
+ Assertions.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(),
resp.getStatus());
+ ErrorResponse errorResp = resp.readEntity(ErrorResponse.class);
+ Assertions.assertEquals(
+ "Lance table branches are not supported, got branch: dev",
errorResp.getError());
+
+ AlterTableAlterColumnsRequest alterColumnsRequest = new
AlterTableAlterColumnsRequest();
+ AlterColumnsEntry columnAlteration = new AlterColumnsEntry();
+ columnAlteration.setPath("col1");
+ columnAlteration.setRename("col1_new");
+ alterColumnsRequest.setAlterations(List.of(columnAlteration));
+ alterColumnsRequest.setBranch("dev");
+ resp =
+ target(String.format("/v1/table/%s/alter_columns", tableIds))
+ .queryParam("delimiter", delimiter)
+ .request(MediaType.APPLICATION_JSON_TYPE)
+ .post(Entity.entity(alterColumnsRequest,
MediaType.APPLICATION_JSON_TYPE));
+ Assertions.assertEquals(Response.Status.BAD_REQUEST.getStatusCode(),
resp.getStatus());
+ errorResp = resp.readEntity(ErrorResponse.class);
+ Assertions.assertEquals(
+ "Lance table branches are not supported, got branch: dev",
errorResp.getError());
+
+ Mockito.verify(tableOps, never()).alterTable(any(), any(), any());
+ }
+
@Test
void testTableExists() {
String tableIds = "catalog.scheme.table_exists";