This is an automated email from the ASF dual-hosted git repository. mblow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/asterixdb.git
commit 9d2873678e5223ad2a46c242686215b21574d033 Author: Peeyush Gupta <[email protected]> AuthorDate: Wed Aug 14 13:35:36 2024 -0700 [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 <[email protected]> Integration-Tests: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> --- .../query-ASTERIXDB-3481.1.query.sqlpp | 24 ++++++++++++++++++++++ .../query-ASTERIXDB-3481.2.query.sqlpp | 24 ++++++++++++++++++++++ .../query-ASTERIXDB-3481.3.query.sqlpp | 24 ++++++++++++++++++++++ .../query-ASTERIXDB-3481.4.query.sqlpp | 24 ++++++++++++++++++++++ .../query-ASTERIXDB-3481.1.adm | 2 ++ .../query-ASTERIXDB-3481.2.adm | 2 ++ .../query-ASTERIXDB-3481.3.adm | 2 ++ .../query-ASTERIXDB-3481.4.adm | 2 ++ .../test/resources/runtimets/testsuite_sqlpp.xml | 5 +++++ .../serde/AOrderedListSerializerDeserializer.java | 9 ++++++++ .../AUnorderedListSerializerDeserializer.java | 9 ++++++++ 11 files changed, 127 insertions(+) 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 0000000000..3c4bc57f37 --- /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 0000000000..8bdfcfbd8c --- /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 0000000000..c6718c6fa1 --- /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 0000000000..5ed68f8227 --- /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 0000000000..ea969a149a --- /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 0000000000..fbe680381d --- /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 0000000000..ea969a149a --- /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 0000000000..ea969a149a --- /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 b6db158ff2..845fca395a 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 e443e132f9..7c49662b2a 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 @@ public class AOrderedListSerializerDeserializer implements ISerializerDeserializ } } 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 @@ public class AOrderedListSerializerDeserializer implements ISerializerDeserializ } } + 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 b5165d2827..b8ae18db7b 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 @@ public class AUnorderedListSerializerDeserializer implements ISerializerDeserial } } for (int i = 0; i < numberOfitems; i++) { + if (isNullMissingTagWritten(typeTag)) { + in.readByte(); + } items.add((IAObject) currentDeserializer.deserialize(in)); } } @@ -102,6 +105,12 @@ public class AUnorderedListSerializerDeserializer implements ISerializerDeserial } } + 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 {
