[ASTERIXDB-3481][COMP] Query taking more than 30s to compile
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
The issue was occuring due to incorrect de-serialization of
lists containing only nulls while applying constant folding rule.
Ext-ref: MB-63020
Change-Id: Ibd8173ce7d9f48650e6143cb7f3b02901f887d37
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18587
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.1.query.sqlpp
new file mode 100644
index 0000000..3c4bc57
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.1.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+/*
+ * Description: This test case is to verify the fix for ASTERIXDB-3481
+ */
+
+select array_count(n) from [{"n":[null]},{"n":[null,null]}] as l;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.2.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.2.query.sqlpp
new file mode 100644
index 0000000..8bdfcfb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.2.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+/*
+ * Description: This test case is to verify the fix for ASTERIXDB-3481
+ */
+
+select array_count(n) from [{"n":[null, 1]},{"n":[null,null, 2]}] as l;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.3.query.sqlpp
new file mode 100644
index 0000000..c6718c6
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.3.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+/*
+ * Description: This test case is to verify the fix for ASTERIXDB-3481
+ */
+
+select array_count(n) from [{"n":[]},{"n":[]}] as l;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.4.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.4.query.sqlpp
new file mode 100644
index 0000000..5ed68f8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.4.query.sqlpp
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+
+/*
+ * Description: This test case is to verify the fix for ASTERIXDB-3481
+ */
+
+select array_count(n) from [{"n":[null,null,null,null,null,null,null,null,null,null]},{"n":[null,null,null,null,null,null,null,null,null,null]}] as l;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.1.adm
new file mode 100644
index 0000000..ea969a1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.1.adm
@@ -0,0 +1,2 @@
+{ "$1": 0 }
+{ "$1": 0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.2.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.2.adm
new file mode 100644
index 0000000..fbe6803
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.2.adm
@@ -0,0 +1,2 @@
+{ "$1": 1 }
+{ "$1": 1 }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.3.adm
new file mode 100644
index 0000000..ea969a1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.3.adm
@@ -0,0 +1,2 @@
+{ "$1": 0 }
+{ "$1": 0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.4.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.4.adm
new file mode 100644
index 0000000..ea969a1
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/query-ASTERIXDB-3481/query-ASTERIXDB-3481.4.adm
@@ -0,0 +1,2 @@
+{ "$1": 0 }
+{ "$1": 0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index b6db158..845fca3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -7340,6 +7340,11 @@
<output-dir compare="Text">query-ASTERIXDB-3415</output-dir>
</compilation-unit>
</test-case>
+ <test-case FilePath="misc">
+ <compilation-unit name="query-ASTERIXDB-3481">
+ <output-dir compare="Text">query-ASTERIXDB-3481</output-dir>
+ </compilation-unit>
+ </test-case>
</test-group>
<test-group name="multipart-dataverse">
<test-case FilePath="multipart-dataverse">
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AOrderedListSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AOrderedListSerializerDeserializer.java
index e443e13..7c49662 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AOrderedListSerializerDeserializer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AOrderedListSerializerDeserializer.java
@@ -90,6 +90,9 @@
}
}
for (int i = 0; i < numberOfitems; i++) {
+ if (isNullMissingTagWritten(typeTag)) {
+ in.readByte();
+ }
IAObject v = (IAObject) currentDeserializer.deserialize(in);
items.add(v);
}
@@ -101,6 +104,12 @@
}
}
+ private boolean isNullMissingTagWritten(ATypeTag serializedTypeTag) {
+ ATypeTag itemTypeTag = itemType.getTypeTag();
+ boolean toWriteTag = itemTypeTag == ATypeTag.NULL && serializedTypeTag == ATypeTag.NULL;
+ return toWriteTag || (itemTypeTag == ATypeTag.MISSING && serializedTypeTag == ATypeTag.MISSING);
+ }
+
@SuppressWarnings("unchecked")
@Override
public void serialize(AOrderedList instance, DataOutput out) throws HyracksDataException {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AUnorderedListSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AUnorderedListSerializerDeserializer.java
index b5165d2..b8ae18d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AUnorderedListSerializerDeserializer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AUnorderedListSerializerDeserializer.java
@@ -92,6 +92,9 @@
}
}
for (int i = 0; i < numberOfitems; i++) {
+ if (isNullMissingTagWritten(typeTag)) {
+ in.readByte();
+ }
items.add((IAObject) currentDeserializer.deserialize(in));
}
}
@@ -102,6 +105,12 @@
}
}
+ private boolean isNullMissingTagWritten(ATypeTag serializedTypeTag) {
+ ATypeTag itemTypeTag = itemType.getTypeTag();
+ boolean toWriteTag = itemTypeTag == ATypeTag.NULL && serializedTypeTag == ATypeTag.NULL;
+ return toWriteTag || (itemTypeTag == ATypeTag.MISSING && serializedTypeTag == ATypeTag.MISSING);
+ }
+
@SuppressWarnings("unchecked")
@Override
public void serialize(AUnorderedList instance, DataOutput out) throws HyracksDataException {