>From Rithwik Koul <[email protected]>:
Rithwik Koul has uploaded this change for review. (
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21392?usp=email )
Change subject: [ASTERIXDB-3787]Bug fix for query getting stuck forever due to
column filter evaluation - user model changes: no - storage format changes: no
- interface changes: no
......................................................................
[ASTERIXDB-3787]Bug fix for query getting stuck forever due to column filter
evaluation
- user model changes: no
- storage format changes: no
- interface changes: no
Change-Id: Ib4c961272a6eea730efeb7d75c95cd9ea72e9aaa
---
M
asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitor.java
A
asterixdb/asterix-column/src/test/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitorTest.java
2 files changed, 107 insertions(+), 2 deletions(-)
git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb
refs/changes/92/21392/1
diff --git
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitor.java
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitor.java
index 1b63361..c6e6a1d 100644
---
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitor.java
+++
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitor.java
@@ -34,6 +34,7 @@
import org.apache.asterix.column.values.IColumnValuesReaderFactory;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.util.annotations.AiProvenance;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
@@ -138,7 +139,14 @@
}
private int[] getReversedDelimiters() {
- Collections.reverse(delimiters);
- return delimiters.toIntArray();
+ // toIntArray() returns a fresh copy; reverse the copy so the shared
delimiters list is left intact for the
+ // next reader built from the same path (e.g., each branch of a
union-typed leaf).
+ int[] reversed = delimiters.toIntArray();
+ for (int i = 0, j = reversed.length - 1; i < j; i++, j--) {
+ int tmp = reversed[i];
+ reversed[i] = reversed[j];
+ reversed[j] = tmp;
+ }
+ return reversed;
}
}
diff --git
a/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitorTest.java
b/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitorTest.java
new file mode 100644
index 0000000..53b89cc
--- /dev/null
+++
b/asterixdb/asterix-column/src/test/java/org/apache/asterix/column/metadata/schema/visitor/PathExtractorVisitorTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.asterix.column.metadata.schema.visitor;
+
+import java.io.DataInput;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.asterix.column.metadata.schema.ObjectSchemaNode;
+import org.apache.asterix.column.metadata.schema.UnionSchemaNode;
+import org.apache.asterix.column.metadata.schema.collection.ArraySchemaNode;
+import org.apache.asterix.column.metadata.schema.primitive.PrimitiveSchemaNode;
+import org.apache.asterix.column.values.IColumnValuesReader;
+import org.apache.asterix.column.values.IColumnValuesReaderFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.util.annotations.AiProvenance;
+import org.junit.Assert;
+import org.junit.Test;
+
+@AiProvenance(agent = AiProvenance.Agent.CLAUDE_OPUS_4_8, tool =
AiProvenance.Tool.CLAUDE_CODE_UI, contributionKind =
AiProvenance.ContributionKind.TEST_GENERATED, notes = "Regression test for the
shared-delimiters double-reverse that hung nested-array column filters")
+public class PathExtractorVisitorTest {
+
+ /**
+ * A filter path that reaches a mixed-type (UNION) leaf through two nested
arrays produces one column reader per
+ * union branch. Each branch must receive the same delimiter ordering;
reversing the shared delimiters list in
+ * place used to flip it back on the second branch, corrupting the
repeated reader and hanging evaluation.
+ */
+ @Test
+ public void unionLeafUnderNestedArraysGetsConsistentDelimiters() throws
HyracksDataException {
+ // { field0: [ [ <int | double> ] ] } -- two array levels, mixed-type
leaf
+ PrimitiveSchemaNode intLeaf = new PrimitiveSchemaNode(1,
ATypeTag.BIGINT, false);
+ PrimitiveSchemaNode doubleLeaf = new PrimitiveSchemaNode(2,
ATypeTag.DOUBLE, false);
+ UnionSchemaNode union = new UnionSchemaNode(intLeaf, doubleLeaf);
+
+ ArraySchemaNode innerArray = new ArraySchemaNode();
+ innerArray.setItemNode(union);
+ ArraySchemaNode outerArray = new ArraySchemaNode();
+ outerArray.setItemNode(innerArray);
+ ObjectSchemaNode root = new ObjectSchemaNode();
+ root.addChild(0, outerArray);
+
+ Map<Integer, int[]> capturedDelimiters = new HashMap<>();
+ IColumnValuesReaderFactory factory = new
CapturingReaderFactory(capturedDelimiters);
+
+ PathExtractorVisitor visitor = new PathExtractorVisitor(factory);
+ visitor.getOrCreateReaders(root, new ArrayList<>());
+
+ // Two array levels at path levels 0 and 1, reversed to
outermost-first for the repeated reader.
+ int[] expected = { 1, 0 };
+ Assert.assertArrayEquals(expected,
capturedDelimiters.get(intLeaf.getColumnIndex()));
+ Assert.assertArrayEquals(expected,
capturedDelimiters.get(doubleLeaf.getColumnIndex()));
+ }
+
+ private static final class CapturingReaderFactory implements
IColumnValuesReaderFactory {
+ private final Map<Integer, int[]> capturedDelimiters;
+
+ private CapturingReaderFactory(Map<Integer, int[]> capturedDelimiters)
{
+ this.capturedDelimiters = capturedDelimiters;
+ }
+
+ @Override
+ public IColumnValuesReader createValueReader(ATypeTag typeTag, int
columnIndex, int maxLevel,
+ int[] delimiters) {
+ capturedDelimiters.put(columnIndex, delimiters.clone());
+ return null;
+ }
+
+ @Override
+ public IColumnValuesReader createValueReader(ATypeTag typeTag, int
columnIndex, int maxLevel,
+ boolean primaryKey) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public IColumnValuesReader createValueReader(DataInput input) {
+ throw new UnsupportedOperationException();
+ }
+ }
+}
--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/21392?usp=email
To unsubscribe, or for help writing mail filters, visit
https://asterix-gerrit.ics.uci.edu/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Ib4c961272a6eea730efeb7d75c95cd9ea72e9aaa
Gerrit-Change-Number: 21392
Gerrit-PatchSet: 1
Gerrit-Owner: Rithwik Koul <[email protected]>