>From Wail Alkowaileet <wael....@gmail.com>:

Wail Alkowaileet has uploaded this change for review. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/18014 )


Change subject: [ASTERIXDB-3333][COMP] Do not warn on MISSING fields
......................................................................

[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
---
A asterixdb/asterix-app/data/commerce/orders.json
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.004.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.003.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.004.query.sqlpp
M asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.002.update.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/non-existing-fields/non-existing-fields.003.adm
M 
asterixdb/asterix-column/src/main/java/org/apache/asterix/column/metadata/schema/visitor/SchemaClipperVisitor.java
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/non-existing-fields/non-existing-fields.001.ddl.sqlpp
9 files changed, 157 insertions(+), 1 deletion(-)



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

diff --git a/asterixdb/asterix-app/data/commerce/orders.json 
b/asterixdb/asterix-app/data/commerce/orders.json
new file mode 100644
index 0000000..b983f6c
--- /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 0000000..51f3412
--- /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 0000000..d1dd7d3
--- /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 0000000..aa9afbf
--- /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 0000000..809ba55
--- /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 0000000..cf6aa33
--- /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 0000000..cf6aa33
--- /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 86f2b0b..9287df2 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 2d21ff2..7164304 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 @@
     }

     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 @@
         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) {

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

Gerrit-Project: asterixdb
Gerrit-Branch: master
Gerrit-Change-Id: Ie079fa94b625ad7c8de32e199217fa4dc97974fe
Gerrit-Change-Number: 18014
Gerrit-PatchSet: 1
Gerrit-Owner: Wail Alkowaileet <wael....@gmail.com>
Gerrit-MessageType: newchange

Reply via email to