This is an automated email from the ASF dual-hosted git repository.
JingsongLi 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 dc4f56c5ee [core] Tolerate retracting an absent secondary index key
(#10280)
dc4f56c5ee is described below
commit dc4f56c5ee0e9c3f6fc4c8da7eb72c544d5781d3
Author: YangJie <[email protected]>
AuthorDate: Thu Oct 1 21:55:17 2026 -0400
[core] Tolerate retracting an absent secondary index key (#10280)
---
.../paimon/lookup/memory/InMemorySetState.java | 7 +++-
.../paimon/lookup/memory/InMemorySetStateTest.java | 49 ++++++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git
a/paimon-core/src/main/java/org/apache/paimon/lookup/memory/InMemorySetState.java
b/paimon-core/src/main/java/org/apache/paimon/lookup/memory/InMemorySetState.java
index f694a57643..adc59f9eff 100644
---
a/paimon-core/src/main/java/org/apache/paimon/lookup/memory/InMemorySetState.java
+++
b/paimon-core/src/main/java/org/apache/paimon/lookup/memory/InMemorySetState.java
@@ -56,7 +56,12 @@ public class InMemorySetState<K, V> extends InMemoryState<K,
V> implements SetSt
@Override
public void retract(K key, V value) throws IOException {
-
values.get(wrapBytes(serializeKey(key))).remove(wrapBytes(serializeValue(value)));
+ Set<ByteArray> set = values.get(wrapBytes(serializeKey(key)));
+ // the key may never have been added, for example when only
predicate-passing
+ // rows are indexed and the retracted row was filtered out
+ if (set != null) {
+ set.remove(wrapBytes(serializeValue(value)));
+ }
}
@Override
diff --git
a/paimon-core/src/test/java/org/apache/paimon/lookup/memory/InMemorySetStateTest.java
b/paimon-core/src/test/java/org/apache/paimon/lookup/memory/InMemorySetStateTest.java
new file mode 100644
index 0000000000..1b1dab1158
--- /dev/null
+++
b/paimon-core/src/test/java/org/apache/paimon/lookup/memory/InMemorySetStateTest.java
@@ -0,0 +1,49 @@
+/*
+ * 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.lookup.memory;
+
+import org.apache.paimon.data.serializer.IntSerializer;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatCode;
+
+/** Tests for {@link InMemorySetState}. */
+class InMemorySetStateTest {
+
+ @Test
+ void testRetractOnAbsentKeyIsNoOp() throws Exception {
+ // predicate-filtered inserts never add the secondary key, but the
refresh
+ // path retracts DELETE/UPDATE_BEFORE rows unconditionally
+ InMemorySetState<Integer, Integer> state =
+ new InMemorySetState<>(IntSerializer.INSTANCE,
IntSerializer.INSTANCE);
+
+ state.add(1, 10);
+ state.add(1, 20);
+
+ assertThatCode(() -> state.retract(2, 10)).doesNotThrowAnyException();
+ assertThatCode(() -> state.retract(1, 99)).doesNotThrowAnyException();
+ assertThat(state.get(1)).containsExactlyInAnyOrder(10, 20);
+ assertThat(state.get(2)).isEmpty();
+
+ state.retract(1, 10);
+ assertThat(state.get(1)).containsExactly(20);
+ }
+}