You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by wy...@apache.org on 2023/12/19 20:12:28 UTC

(asterixdb) branch master updated: [ASTERIXDB-3333][COMP] Do not warn on MISSING fields

This is an automated email from the ASF dual-hosted git repository.

wyk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d609b4210 [ASTERIXDB-3333][COMP] Do not warn on MISSING fields
4d609b4210 is described below

commit 4d609b4210925860a4311e3a191b801c9fa22830
Author: Wail Alkowaileet <wa...@gmail.com>
AuthorDate: Fri Dec 15 12:14:17 2023 -0800

    [ASTERIXDB-3333][COMP] Do not warn on MISSING fields
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    When comparing with missing fields in columnar range-filters,
    warnings should not be issued.
    
    Change-Id: Ie079fa94b625ad7c8de32e199217fa4dc97974fe
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18014
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Wail Alkowaileet <wa...@gmail.com>
    Reviewed-by: Ali Alsuliman <al...@gmail.com>
---
 asterixdb/asterix-app/data/commerce/orders.json    |  9 ++++++
 .../non-existing-fields.001.ddl.sqlpp              | 32 ++++++++++++++++++++++
 .../non-existing-fields.002.update.sqlpp           | 30 ++++++++++++++++++++
 .../non-existing-fields.003.query.sqlpp            | 27 ++++++++++++++++++
 .../non-existing-fields.004.query.sqlpp            | 27 ++++++++++++++++++
 .../non-existing-fields.003.adm                    |  3 ++
 .../non-existing-fields.004.adm                    |  3 ++
 .../src/test/resources/runtimets/sqlpp_queries.xml |  5 ++++
 .../schema/visitor/SchemaClipperVisitor.java       |  5 +++-
 9 files changed, 140 insertions(+), 1 deletion(-)

diff --git a/asterixdb/asterix-app/data/commerce/orders.json b/asterixdb/asterix-app/data/commerce/orders.json
new file mode 100644
index 0000000000..b983f6cfb2
--- /dev/null
+++ b/asterixdb/asterix-app/data/commerce/orders.json
@@ -0,0 +1,9 @@
+{ "orderno": 1001, "custid": "C41", "order_date": "2017-04-29", "ship_date": "2017-05-03", "items": [ { "itemno": 347, "qty": 5, "price": 19.99 }, { "itemno": 193, "qty": 2, "price": 28.89 } ] }
+{ "orderno": 1002, "custid": "C13", "order_date": "2017-05-01", "ship_date": "2017-05-03", "items": [ { "itemno": 460, "qty": 95, "price": 100.99 }, { "itemno": 680, "qty": 150, "price": 8.75 } ] }
+{ "orderno": 1003, "custid": "C31", "order_date": "2017-06-15", "ship_date": "2017-06-16", "items": [ { "itemno": 120, "qty": 2, "price": 88.99 }, { "itemno": 460, "qty": 3, "price": 99.99 } ] }
+{ "orderno": 1004, "custid": "C35", "order_date": "2017-07-10", "ship_date": "2017-07-15", "items": [ { "itemno": 680, "qty": 6, "price": 9.99 }, { "itemno": 195, "qty": 4, "price": 35.00 } ] }
+{ "orderno": 1005, "custid": "C37", "order_date": "2017-08-30", "items": [ { "itemno": 460, "qty": 2, "price": 99.98 }, { "itemno": 347, "qty": 120, "price": 22.00 }, { "itemno": 780, "qty": 1, "price": 1500.00  }, { "itemno": 375, "qty": 2, "price": 149.98 } ] }
+{ "orderno": 1006, "custid": "C41", "order_date": "2017-09-02", "ship_date": "2017-09-04", "items": [ { "itemno": 680, "qty": 51, "price": 25.98 }, { "itemno": 120, "qty": 65, "price": 85.00 }, { "itemno": 460, "qty": 120, "price": 99.98 } ] }
+{ "orderno": 1007, "custid": "C13", "order_date": "2017-09-13", "ship_date": "2017-09-20", "items": [ { "itemno": 185, "qty": 5, "price": 21.99 }, { "itemno": 680, "qty": 1, "price": 20.50 } ] }
+{ "orderno": 1008, "custid": "C13", "order_date": "2017-10-13", "items": [ { "itemno": 460, "qty": 20, "price": 99.99 } ] }
+{ "orderno": 1009, "custid": "C13", "order_date": "2017-10-13", "items": [ ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.001.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.001.ddl.sqlpp
new file mode 100644
index 0000000000..51f3412f87
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.001.ddl.sqlpp
@@ -0,0 +1,32 @@
+/*
+ * 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 DATASET OrdersColumn
+PRIMARY KEY (orderno: int) WITH {
+    "storage-format":{"format": "column"}
+};
+
+CREATE DATASET OrdersRow
+PRIMARY KEY (orderno: int) WITH {
+    "storage-format":{"format": "row"}
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.002.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.002.update.sqlpp
new file mode 100644
index 0000000000..d1dd7d38b7
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.002.update.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;
+
+LOAD DATASET OrdersColumn USING localfs (
+    ("path"="asterix_nc1://data/commerce/orders.json"),
+    ("format"="json")
+);
+
+LOAD DATASET OrdersRow USING localfs (
+    ("path"="asterix_nc1://data/commerce/orders.json"),
+    ("format"="json")
+);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.003.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.003.query.sqlpp
new file mode 100644
index 0000000000..aa9afbf644
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.003.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+-- param max-warnings:json=1000
+USE test;
+
+-- items can be empty
+FROM OrdersColumn AS o, o.items AS i
+LET revenue = i.qty * i.price
+WHERE revenue > 5000
+SELECT o.orderno, i.itemno, revenue
+ORDER by revenue desc;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.004.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.004.query.sqlpp
new file mode 100644
index 0000000000..809ba55c06
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.004.query.sqlpp
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+-- param max-warnings:json=1000
+USE test;
+
+-- items can be empty
+FROM OrdersRow AS o, o.items AS i
+LET revenue = i.qty * i.price
+WHERE revenue > 5000
+SELECT o.orderno, i.itemno, revenue
+ORDER by revenue desc;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.003.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.003.adm
new file mode 100644
index 0000000000..cf6aa33cdb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.003.adm
@@ -0,0 +1,3 @@
+{ "orderno": 1006, "itemno": 460, "revenue": 11997.6 }
+{ "orderno": 1002, "itemno": 460, "revenue": 9594.05 }
+{ "orderno": 1006, "itemno": 120, "revenue": 5525.0 }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.004.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.004.adm
new file mode 100644
index 0000000000..cf6aa33cdb
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.004.adm
@@ -0,0 +1,3 @@
+{ "orderno": 1006, "itemno": 460, "revenue": 11997.6 }
+{ "orderno": 1002, "itemno": 460, "revenue": 9594.05 }
+{ "orderno": 1006, "itemno": 120, "revenue": 5525.0 }
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 86f2b0bc4a..9287df20c1 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -16373,6 +16373,11 @@
         <output-dir compare="Text">filter/not-in_every</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="column" check-warnings="true">
+      <compilation-unit name="filter/non-existing-fields">
+        <output-dir compare="Text">filter/non-existing-fields</output-dir>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="column">
       <compilation-unit name="big-object">
         <output-dir compare="Text">big-object</output-dir>
diff --git a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/SchemaClipperVisitor.java b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/SchemaClipperVisitor.java
index 2d21ff2f0e..7164304f5d 100644
--- a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/SchemaClipperVisitor.java
+++ b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/SchemaClipperVisitor.java
@@ -139,6 +139,9 @@ public class SchemaClipperVisitor implements IATypeVisitor<AbstractSchemaNode, A
     }
 
     private boolean isNotCompatible(IAType requestedType, AbstractSchemaNode schemaNode) {
+        if (schemaNode.getTypeTag() == ATypeTag.MISSING) {
+            return true;
+        }
         ATypeTag requestedTypeTag = requestedType.getTypeTag();
         if (requestedTypeTag != schemaNode.getTypeTag()) {
             if (schemaNode.getTypeTag() != ATypeTag.UNION) {
@@ -164,7 +167,7 @@ public class SchemaClipperVisitor implements IATypeVisitor<AbstractSchemaNode, A
         if (ATypeHierarchy.isCompatible(requestedType.getTypeTag(), schemaNode.getTypeTag())) {
             return;
         }
-        if (warningCollector.shouldWarn()) {
+        if (warningCollector.shouldWarn() && functionCallInfoMap.containsKey(requestedType.getTypeName())) {
             Warning warning = functionCallInfoMap.get(requestedType.getTypeName())
                     .createWarning(requestedType.getTypeTag(), schemaNode.getTypeTag());
             if (warning != null) {