You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@asterixdb.apache.org by AsterixDB Code Review <do...@asterix-gerrit.ics.uci.edu> on 2024/09/12 20:15:33 UTC

Change in asterixdb[goldfish]: [ASTERIXDB-3502][STO] Incorrectly treating two expressions as commuta...

From Ritik Raj <ra...@gmail.com>:

Ritik Raj has uploaded this change for review. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18868 )


Change subject: [ASTERIXDB-3502][STO] Incorrectly treating two expressions as commutative
......................................................................

[ASTERIXDB-3502][STO] Incorrectly treating two expressions as commutative

- user model changes: no
- storage format changes: no
- interface changes: no

- Incorrectly considering two different expression as commutative

Ext-ref: MB-63481

Change-Id: Idc5a78e85d7c8ca3d8e41e6bcbd46a2792015ba7
---
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.002.update.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
A asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.adm
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.query.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.adm
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.001.ddl.sqlpp
A asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.query.sqlpp
M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
8 files changed, 153 insertions(+), 0 deletions(-)



  git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/68/18868/1

diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.001.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.001.ddl.sqlpp
new file mode 100644
index 0000000..f215b9f
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.001.ddl.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+DROP DATAVERSE test IF EXISTS;
+CREATE DATAVERSE test;
+
+USE test;
+
+CREATE collection sample_collection PRIMARY KEY (primary_key_id: string)
+WITH {
+    "storage-format": {
+        "format": "column"
+     }
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.002.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.002.update.sqlpp
new file mode 100644
index 0000000..1033154
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.002.update.sqlpp
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+USE test;
+insert into sample_collection (
+[
+  {
+    "primary_key_id": "1",
+    "int_field1": 69114320,
+    "decimal_field1": 9610,
+    "datetime_field1": "2005-11-08 00:00:00",
+    "bool_field1": True,
+    "varchar_field1": "abcdefgh",
+    "char_field1": "C"
+  }
+]
+);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.query.sqlpp
new file mode 100644
index 0000000..fffaffb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.query.sqlpp
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+USE test;
+SELECT * FROM sample_collection
+WHERE
+(
+    ( NOT ( bool_field1 ) ) ) AND ( ( bool_field1 )
+)
+OR
+(
+    ( bool_field1 ) ) AND ( ( bool_field1 = true )
+);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.query.sqlpp
new file mode 100644
index 0000000..14fd1a8
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.query.sqlpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+
+USE test;
+
+SELECT * FROM sample_collection
+WHERE
+(
+    UPPER(varchar_field1) = varchar_field1 AND int_field1 = 69114320
+) OR
+(
+    LOWER(varchar_field1) = varchar_field1 AND int_field1 = 69114320
+);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.adm
new file mode 100644
index 0000000..e91d79e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.003.adm
@@ -0,0 +1 @@
+{ "sample_collection": { "primary_key_id": "1", "int_field1": 69114320, "decimal_field1": 9610, "datetime_field1": "2005-11-08 00:00:00", "bool_field1": true, "varchar_field1": "abcdefgh", "char_field1": "C" } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.adm
new file mode 100644
index 0000000..e91d79e
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/ASTERIXDB-3502/ASTERIXDB-3502.004.adm
@@ -0,0 +1 @@
+{ "sample_collection": { "primary_key_id": "1", "int_field1": 69114320, "decimal_field1": 9610, "datetime_field1": "2005-11-08 00:00:00", "bool_field1": true, "varchar_field1": "abcdefgh", "char_field1": "C" } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
index 6abfddc..66692c9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -16334,6 +16334,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="column">
+      <compilation-unit name="filter/ASTERIXDB-3502">
+        <output-dir compare="Text">filter/ASTERIXDB-3502</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="column">
       <compilation-unit name="delete/001">
         <output-dir compare="Text">delete/001</output-dir>
       </compilation-unit>
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
index ffd2089..e463808 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/util/FunctionUtil.java
@@ -391,6 +391,13 @@
         List<Mutable<ILogicalExpression>> args1 = funcExpr1.getArguments();
         List<Mutable<ILogicalExpression>> args2 = funcExpr2.getArguments();
 
+        FunctionIdentifier fid1 = funcExpr1.getFunctionIdentifier();
+        FunctionIdentifier fid2 = funcExpr2.getFunctionIdentifier();
+
+        if (!fid1.equals(fid2) || funcExpr1.getArguments().size() != funcExpr2.getArguments().size()) {
+            return false;
+        }
+
         BitSet childrenSet = new BitSet();
         int numberOfMatches = 0;
         for (Mutable<ILogicalExpression> arg1 : args1) {

-- 
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18868
To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings

Gerrit-Project: asterixdb
Gerrit-Branch: goldfish
Gerrit-Change-Id: Idc5a78e85d7c8ca3d8e41e6bcbd46a2792015ba7
Gerrit-Change-Number: 18868
Gerrit-PatchSet: 1
Gerrit-Owner: Ritik Raj <ra...@gmail.com>
Gerrit-MessageType: newchange