[NO ISSUE][COMP] Temporarily disable some property matching

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

Details:
- ORDERED_PARTITIONED can only satisfy UNORDERED_PARTITIONED
  if both use the same partitioning function. Currently there is no
  mechanism for reasoning about partitioning functions so this case
  has to be disabled until it is in place.

Change-Id: I7f280505f4fa02283fc14a0398760162e1150dc9
Reviewed-on: https://asterix-gerrit.ics.uci.edu/3532
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/p_sort_join/p_sort_join.sqlpp b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/p_sort_join/p_sort_join.sqlpp
new file mode 100644
index 0000000..59581aa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/p_sort_join/p_sort_join.sqlpp
@@ -0,0 +1,50 @@
+/*
+ * 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: Test structural property matching when a parent operator
+ *              requires UNORDERED_PARTITIONED and its child operators
+ *              deliver ORDERED_PARTITIONED
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create type TestType as
+{
+  id:   int,
+  id2:  int,
+  f1:   int
+};
+
+create  dataset TestDS1(TestType) primary key id;
+
+create  dataset TestDS2(TestType) primary key id;
+
+set `compiler.sort.parallel` "true";
+
+select t1.id2 from
+  ( select id, id2 from TestDS1 /*+ range [5] */ order by id2 ) t1
+  join
+  ( select id, id2 from TestDS2 /*+ range [15] */ order by id2 ) t2
+  on t1.id2 = t2.id2
+group by t1.id2
+order by t1.id2;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/optimizerts/results/p_sort_join/p_sort_join.plan b/asterixdb/asterix-app/src/test/resources/optimizerts/results/p_sort_join/p_sort_join.plan
new file mode 100644
index 0000000..9e0a13c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/optimizerts/results/p_sort_join/p_sort_join.plan
@@ -0,0 +1,76 @@
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    -- STREAM_PROJECT  |PARTITIONED|
+      -- ASSIGN  |PARTITIONED|
+        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+          -- STABLE_SORT [$$id2(ASC)]  |PARTITIONED|
+            -- RANGE_PARTITION_EXCHANGE [$$id2(ASC)]  |PARTITIONED|
+              -- FORWARD  |PARTITIONED|
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  -- REPLICATE  |PARTITIONED|
+                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                      -- SORT_GROUP_BY[$$81]  |PARTITIONED|
+                              {
+                                -- AGGREGATE  |LOCAL|
+                                  -- NESTED_TUPLE_SOURCE  |LOCAL|
+                              }
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          -- STREAM_PROJECT  |PARTITIONED|
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              -- HYBRID_HASH_JOIN [$$81][$$84]  |PARTITIONED|
+                                -- HASH_PARTITION_EXCHANGE [$$81]  |PARTITIONED|
+                                  -- STABLE_SORT [$$81(ASC)]  |PARTITIONED|
+                                    -- RANGE_PARTITION_EXCHANGE [$$81(ASC)] RANGE_MAP:{SPLIT:1}  |PARTITIONED|
+                                      -- STREAM_PROJECT  |PARTITIONED|
+                                        -- ASSIGN  |PARTITIONED|
+                                          -- STREAM_PROJECT  |PARTITIONED|
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                -- HASH_PARTITION_EXCHANGE [$$84]  |PARTITIONED|
+                                  -- STABLE_SORT [$$84(ASC)]  |PARTITIONED|
+                                    -- RANGE_PARTITION_EXCHANGE [$$84(ASC)] RANGE_MAP:{SPLIT:1}  |PARTITIONED|
+                                      -- STREAM_PROJECT  |PARTITIONED|
+                                        -- ASSIGN  |PARTITIONED|
+                                          -- STREAM_PROJECT  |PARTITIONED|
+                                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                              -- DATASOURCE_SCAN  |PARTITIONED|
+                                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                -- BROADCAST_EXCHANGE  |PARTITIONED|
+                  -- AGGREGATE  |UNPARTITIONED|
+                    -- RANDOM_MERGE_EXCHANGE  |PARTITIONED|
+                      -- AGGREGATE  |PARTITIONED|
+                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                          -- REPLICATE  |PARTITIONED|
+                            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                              -- SORT_GROUP_BY[$$81]  |PARTITIONED|
+                                      {
+                                        -- AGGREGATE  |LOCAL|
+                                          -- NESTED_TUPLE_SOURCE  |LOCAL|
+                                      }
+                                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                  -- STREAM_PROJECT  |PARTITIONED|
+                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                      -- HYBRID_HASH_JOIN [$$81][$$84]  |PARTITIONED|
+                                        -- HASH_PARTITION_EXCHANGE [$$81]  |PARTITIONED|
+                                          -- STABLE_SORT [$$81(ASC)]  |PARTITIONED|
+                                            -- RANGE_PARTITION_EXCHANGE [$$81(ASC)] RANGE_MAP:{SPLIT:1}  |PARTITIONED|
+                                              -- STREAM_PROJECT  |PARTITIONED|
+                                                -- ASSIGN  |PARTITIONED|
+                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
+                                        -- HASH_PARTITION_EXCHANGE [$$84]  |PARTITIONED|
+                                          -- STABLE_SORT [$$84(ASC)]  |PARTITIONED|
+                                            -- RANGE_PARTITION_EXCHANGE [$$84(ASC)] RANGE_MAP:{SPLIT:1}  |PARTITIONED|
+                                              -- STREAM_PROJECT  |PARTITIONED|
+                                                -- ASSIGN  |PARTITIONED|
+                                                  -- STREAM_PROJECT  |PARTITIONED|
+                                                    -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                      -- DATASOURCE_SCAN  |PARTITIONED|
+                                                        -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                                                          -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.1.ddl.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.1.ddl.sqlpp
new file mode 100644
index 0000000..e1d1c7b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.1.ddl.sqlpp
@@ -0,0 +1,40 @@
+/*
+ * 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: Test structural property matching when a parent operator
+ *              requires UNORDERED_PARTITIONED and its child operators
+ *              deliver ORDERED_PARTITIONED
+ */
+
+drop dataverse test if exists;
+create dataverse test;
+
+use test;
+
+create type TestType as
+{
+  id:   int,
+  id2:  int,
+  f1:   int
+};
+
+create  dataset TestDS1(TestType) primary key id;
+
+create  dataset TestDS2(TestType) primary key id;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.2.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.2.update.sqlpp
new file mode 100644
index 0000000..3362399
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.2.update.sqlpp
@@ -0,0 +1,68 @@
+/*
+ * 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 TestDS1
+([
+{"id":1, "id2":1, "f1":40},
+{"id":2, "id2":2, "f1":40},
+{"id":3, "id2":3, "f1":40},
+{"id":4, "id2":4, "f1":41},
+{"id":5, "id2":5, "f1":42},
+{"id":6, "id2":6, "f1":42},
+{"id":7, "id2":7, "f1":40},
+{"id":8, "id2":8, "f1":41},
+{"id":9, "id2":9, "f1":41},
+{"id":10, "id2":10, "f1":42},
+{"id":11, "id2":11, "f1":40},
+{"id":12, "id2":12, "f1":41},
+{"id":13, "id2":13, "f1":42},
+{"id":14, "id2":14, "f1":41},
+{"id":15, "id2":15, "f1":40},
+{"id":16, "id2":16, "f1":42},
+{"id":17, "id2":17, "f1":42},
+{"id":18, "id2":18, "f1":41},
+{"id":19, "id2":19, "f1":42},
+{"id":20, "id2":20, "f1":41}
+]);
+
+INSERT INTO TestDS2
+([
+{"id":1, "id2":1, "f1":40},
+{"id":2, "id2":2, "f1":40},
+{"id":3, "id2":3, "f1":40},
+{"id":4, "id2":4, "f1":41},
+{"id":5, "id2":5, "f1":42},
+{"id":6, "id2":6, "f1":42},
+{"id":7, "id2":7, "f1":40},
+{"id":8, "id2":8, "f1":41},
+{"id":9, "id2":9, "f1":41},
+{"id":10, "id2":10, "f1":42},
+{"id":11, "id2":11, "f1":40},
+{"id":12, "id2":12, "f1":41},
+{"id":13, "id2":13, "f1":42},
+{"id":14, "id2":14, "f1":41},
+{"id":15, "id2":15, "f1":40},
+{"id":16, "id2":16, "f1":42},
+{"id":17, "id2":17, "f1":42},
+{"id":18, "id2":18, "f1":41},
+{"id":19, "id2":19, "f1":42},
+{"id":20, "id2":20, "f1":41}
+]);
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.3.query.sqlpp
new file mode 100644
index 0000000..cdc9670
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/misc/p_sort_join/p_sort_join.3.query.sqlpp
@@ -0,0 +1,36 @@
+/*
+ * 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: Test structural property matching when a parent operator
+ *              requires UNORDERED_PARTITIONED and its child operators
+ *              deliver ORDERED_PARTITIONED
+ */
+
+use test;
+
+set `compiler.sort.parallel` "true";
+
+select t1.id2 from
+  ( select id, id2 from TestDS1 /*+ range [5] */ order by id2 ) t1
+  join
+  ( select id, id2 from TestDS2 /*+ range [15] */ order by id2 ) t2
+  on t1.id2 = t2.id2
+group by t1.id2
+order by t1.id2;
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/p_sort_join/p_sort_join.3.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/p_sort_join/p_sort_join.3.adm
new file mode 100644
index 0000000..c15f00c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/misc/p_sort_join/p_sort_join.3.adm
@@ -0,0 +1,20 @@
+{ "id2": 1 }
+{ "id2": 2 }
+{ "id2": 3 }
+{ "id2": 4 }
+{ "id2": 5 }
+{ "id2": 6 }
+{ "id2": 7 }
+{ "id2": 8 }
+{ "id2": 9 }
+{ "id2": 10 }
+{ "id2": 11 }
+{ "id2": 12 }
+{ "id2": 13 }
+{ "id2": 14 }
+{ "id2": 15 }
+{ "id2": 16 }
+{ "id2": 17 }
+{ "id2": 18 }
+{ "id2": 19 }
+{ "id2": 20 }
\ No newline at end of file
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 8da6725..91c86f2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -6016,6 +6016,11 @@
       </compilation-unit>
     </test-case>
     <test-case FilePath="misc">
+      <compilation-unit name="p_sort_join">
+        <output-dir compare="Text">p_sort_join</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="misc">
       <compilation-unit name="p_sort_seq_merge">
         <output-dir compare="Text">p_sort_seq_merge</output-dir>
       </compilation-unit>
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/PropertiesUtil.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/PropertiesUtil.java
index 2c708c5..1ebaeeb 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/PropertiesUtil.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/PropertiesUtil.java
@@ -142,17 +142,20 @@
                             return (ud.getColumnSet().equals(ur.getColumnSet()));
                         }
                     }
+                    /*
+                    //TODO: revisit this once we start reasoning about different partitioning functions (hash vs range)
                     case ORDERED_PARTITIONED: {
                         UnorderedPartitionedProperty ur = (UnorderedPartitionedProperty) reqd;
                         OrderedPartitionedProperty od = (OrderedPartitionedProperty) dlvd;
+                        List<LogicalVariable> dlvdSortColumns = orderColumnsToVariables(od.getOrderColumns());
                         if (mayExpandProperties) {
-                            List<LogicalVariable> dlvdSortColumns = orderColumnsToVariables(od.getOrderColumns());
                             return isPrefixOf(dlvdSortColumns.iterator(), ur.getColumnSet().iterator());
                         } else {
-                            return ur.getColumnSet().containsAll(od.getOrderColumns())
-                                    && od.getOrderColumns().containsAll(ur.getColumnSet());
+                            return ur.getColumnSet().containsAll(dlvdSortColumns)
+                                    && dlvdSortColumns.containsAll(ur.getColumnSet());
                         }
                     }
+                    */
                     default: {
                         return false;
                     }