This is an automated email from the ASF dual-hosted git repository.
lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/paimon.git
The following commit(s) were added to refs/heads/master by this push:
new 6ce59616f9 [lance] Fix read lance with range position (#6301)
6ce59616f9 is described below
commit 6ce59616f93578c977293b2da48ac2ac07f875bb
Author: Zouxxyy <[email protected]>
AuthorDate: Tue Sep 23 10:04:23 2025 +0800
[lance] Fix read lance with range position (#6301)
---
.../paimon/format/lance/LanceRecordsReader.java | 6 +++-
.../apache/paimon/spark/sql/LanceFormatTest.scala | 39 ++++++++++++++++++++++
paimon-spark/pom.xml | 7 ++++
pom.xml | 1 +
4 files changed, 52 insertions(+), 1 deletion(-)
diff --git
a/paimon-lance/src/main/java/org/apache/paimon/format/lance/LanceRecordsReader.java
b/paimon-lance/src/main/java/org/apache/paimon/format/lance/LanceRecordsReader.java
index d11afee5ef..97e4350eec 100644
---
a/paimon-lance/src/main/java/org/apache/paimon/format/lance/LanceRecordsReader.java
+++
b/paimon-lance/src/main/java/org/apache/paimon/format/lance/LanceRecordsReader.java
@@ -93,8 +93,12 @@ public class LanceRecordsReader implements
FileRecordReader<InternalRow> {
@Nullable
@Override
public InternalRow next() {
+ if (!rows.hasNext()) {
+ return null;
+ }
+
positionGenerator.next();
- return rows.hasNext() ? rows.next() : null;
+ return rows.next();
}
@Override
diff --git
a/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/LanceFormatTest.scala
b/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/LanceFormatTest.scala
new file mode 100644
index 0000000000..820f173901
--- /dev/null
+++
b/paimon-spark/paimon-spark-ut/src/test/scala/org/apache/paimon/spark/sql/LanceFormatTest.scala
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+package org.apache.paimon.spark.sql
+
+import org.apache.paimon.spark.PaimonSparkTestBase
+
+import org.apache.spark.sql.Row
+
+class LanceFormatTest extends PaimonSparkTestBase {
+
+ test("Lance format: read and write") {
+ withTable("t") {
+ sql(
+ "CREATE TABLE t (a INT, b STRING, scores ARRAY<DOUBLE>) TBLPROPERTIES
('file.format' = 'lance')")
+ sql(
+ "INSERT INTO t VALUES (1, 'a', ARRAY(CAST(90.5 as double), CAST(88.0
as double))), (2, 'b', ARRAY(CAST(90.6 as double), CAST(88.1 as double)))")
+ checkAnswer(sql("SELECT * FROM t LIMIT 1"), Seq(Row(1, "a", Array(90.5,
88.0))))
+ checkAnswer(
+ sql("SELECT * FROM t LIMIT 10"),
+ Seq(Row(1, "a", Array(90.5, 88.0)), Row(2, "b", Array(90.6, 88.1))))
+ }
+ }
+}
diff --git a/paimon-spark/pom.xml b/paimon-spark/pom.xml
index 8795e442c1..d423b83797 100644
--- a/paimon-spark/pom.xml
+++ b/paimon-spark/pom.xml
@@ -275,6 +275,13 @@ under the License.
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.paimon</groupId>
+ <artifactId>paimon-lance</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
<dependency>
<groupId>org.apache.paimon</groupId>
<artifactId>paimon-s3</artifactId>
diff --git a/pom.xml b/pom.xml
index ef8fa91300..18a11d4753 100644
--- a/pom.xml
+++ b/pom.xml
@@ -428,6 +428,7 @@ under the License.
<scala.version>${scala213.version}</scala.version>
<paimon-spark-common.spark.version>4.0.1</paimon-spark-common.spark.version>
<paimon-sparkx-common>paimon-spark4-common_2.13</paimon-sparkx-common>
+ <arrow.version>18.1.0</arrow.version>
<test.spark.main.version>4.0</test.spark.main.version>
<test.spark.version>4.0.1</test.spark.version>
</properties>