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

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

commit 044ff43684cdfa3cd6314a44be7b1b3305d223d8
Author: preetham0202 <[email protected]>
AuthorDate: Wed Apr 9 19:39:13 2025 +0530

    [ASTERIXDB-3596][STO] Fix double comparison in range filters
    
     - user model changes: no
     - storage format changes: no
     - interface changes: no
    
    Details:
    When doubles are compared in range filters, denormalize it and compare as 
the normalization of doubles don't follow the natural order.
    Ext-ref: MB-66208
    
    Change-Id: I64ebbfe3852e3521d6238314d1fe59dfd3695708
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19637
    Integration-Tests: Jenkins <[email protected]>
    Reviewed-by: <[email protected]>
    Reviewed-by: Ritik Raj <[email protected]>
    Tested-by: Jenkins <[email protected]>
---
 .../double-precision.001.ddl.sqlpp                 | 30 ++++++++
 .../double-precision.002.update.sqlpp              | 39 ++++++++++
 .../double-precision.003.query.sqlpp               | 25 +++++++
 .../column/filter/double/double.001.ddl.sqlpp      | 30 ++++++++
 .../column/filter/double/double.002.update.sqlpp   | 86 ++++++++++++++++++++++
 .../column/filter/double/double.003.query.sqlpp    | 25 +++++++
 .../double-precision/double-precision.003.adm      | 12 +++
 .../results/column/filter/double/double.003.adm    |  3 +
 .../src/test/resources/runtimets/sqlpp_queries.xml | 10 +++
 .../runtimets/testsuite_single_partition_sqlpp.xml | 10 +++
 .../AbstractColumnFilterComparatorFactory.java     |  5 ++
 .../compartor/GEColumnFilterEvaluatorFactory.java  |  5 ++
 .../compartor/GTColumnFilterEvaluatorFactory.java  |  5 ++
 .../compartor/LEColumnFilterEvaluatorFactory.java  |  5 ++
 .../compartor/LTColumnFilterEvaluatorFactory.java  |  5 ++
 .../utils/filter/ColumnRangeFilterBuilder.java     |  8 ++
 16 files changed, 303 insertions(+)

diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.001.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.001.ddl.sqlpp
new file mode 100644
index 0000000000..de0388157e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.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 DATASET dsUntyped 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/double-precision/double-precision.002.update.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.002.update.sqlpp
new file mode 100644
index 0000000000..6e750a48e3
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.002.update.sqlpp
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+-- Closest possible values to zero that can be represented in double-precision
+
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:0", 'c_double':double(0.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:1", 'c_double':double(-0.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:2", 'c_double':double(-4.9e-324)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:3", 'c_double':double(-9.9e-324)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:4", 'c_double':double(-1.5e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:5", 'c_double':double(-2.0e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:6", 'c_double':double(-2.5e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:7", 'c_double':double(-3.0e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:8", 'c_double':double(-4.0e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:9", 'c_double':double(4.9e-324)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:10", 'c_double':double(9.9e-324)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:11", 'c_double':double(1.5e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:12", 'c_double':double(2.0e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:13", 'c_double':double(2.5e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:14", 'c_double':double(3.0e-323)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:15", 'c_double':double(4.0e-323)} );
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.003.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.003.query.sqlpp
new file mode 100644
index 0000000000..9842965e00
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double-precision/double-precision.003.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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 VALUE c_double
+FROM dsUntyped
+WHERE (c_double) <= double(1.5e-323) ORDER BY c_double;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.001.ddl.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.001.ddl.sqlpp
new file mode 100644
index 0000000000..de0388157e
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.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 DATASET dsUntyped 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/double/double.002.update.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.002.update.sqlpp
new file mode 100644
index 0000000000..0277980418
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.002.update.sqlpp
@@ -0,0 +1,86 @@
+/*
+ * 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 dsUntyped ( { 'id': "dsUntyped:0", 'c_double':double(-3.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:1", 'c_double':double(-3.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:2", 'c_double':double(-3.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:3", 'c_double':double(-3.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:4", 'c_double':double(-3.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:5", 'c_double':double(-2.875)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:6", 'c_double':double(-2.75)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:7", 'c_double':double(-2.625)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:8", 'c_double':null} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:9", 'c_double':double(-2.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:10", 'c_double':double(-2.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:11", 'c_double':double(-2.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:12", 'c_double':double(-2.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:13", 'c_double':double(-2.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:14", 'c_double':double(-1.875)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:15", 'c_double':double(-1.75)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:16", 'c_double':double('INF')} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:17", 'c_double':double(-1.625)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:18", 'c_double':double(-1.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:19", 'c_double':double(-1.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:20", 'c_double':double(-1.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:21", 'c_double':double(-1.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:22", 'c_double':double(-1.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:23", 'c_double':double(-0.875)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:24", 'c_double':double('-INF')} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:25", 'c_double':double(-0.75)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:26", 'c_double':double(-0.625)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:27", 'c_double':double(-0.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:28", 'c_double':double(-0.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:29", 'c_double':double(-0.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:30", 'c_double':double(-0.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:31", 'c_double':double(0.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:32", 'c_double':null} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:33", 'c_double':double(0.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:34", 'c_double':double(0.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:35", 'c_double':double(0.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:36", 'c_double':double(0.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:37", 'c_double':double(0.625)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:38", 'c_double':double(0.75)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:39", 'c_double':double(0.875)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:40", 'c_double':double('INF')} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:41", 'c_double':double(1.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:42", 'c_double':double(1.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:43", 'c_double':double(1.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:44", 'c_double':double(1.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:45", 'c_double':double(1.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:46", 'c_double':double(1.625)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:47", 'c_double':double(1.75)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:48", 'c_double':double('-INF')} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:49", 'c_double':double(1.875)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:50", 'c_double':double(2.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:51", 'c_double':double(2.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:52", 'c_double':double(2.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:53", 'c_double':double(2.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:54", 'c_double':double(2.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:55", 'c_double':double(2.625)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:56", 'c_double':null} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:57", 'c_double':double(2.75)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:58", 'c_double':double(2.875)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:59", 'c_double':double(3.0)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:60", 'c_double':double(3.125)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:61", 'c_double':double(3.25)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:62", 'c_double':double(3.375)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:63", 'c_double':double(3.5)} );
+INSERT INTO dsUntyped ( { 'id': "dsUntyped:64", 'c_double':double('INF')} );
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.003.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.003.query.sqlpp
new file mode 100644
index 0000000000..da3519d4a9
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/column/filter/double/double.003.query.sqlpp
@@ -0,0 +1,25 @@
+/*
+ * 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 VALUE c_double
+FROM dsUntyped
+WHERE (c_double) <= double(-3.5) ORDER BY c_double;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double-precision/double-precision.003.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double-precision/double-precision.003.adm
new file mode 100644
index 0000000000..6d7c209421
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double-precision/double-precision.003.adm
@@ -0,0 +1,12 @@
+-4.0E-323
+-3.0E-323
+-2.5E-323
+-2.0E-323
+-1.5E-323
+-9.9E-324
+-4.9E-324
+-0.0
+0.0
+4.9E-324
+9.9E-324
+1.5E-323
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double/double.003.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double/double.003.adm
new file mode 100644
index 0000000000..b32e800375
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/column/filter/double/double.003.adm
@@ -0,0 +1,3 @@
+-INF
+-INF
+-3.5
\ 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 ac237d5eed..10e8302c06 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/sqlpp_queries.xml
@@ -16556,6 +16556,16 @@
         <output-dir compare="Text">filter/ASTERIXDB-3582-2</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="column">
+      <compilation-unit name="filter/double">
+        <output-dir compare="Text">filter/double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="column">
+      <compilation-unit name="filter/double-precision">
+        <output-dir compare="Text">filter/double-precision</output-dir>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="column">
       <compilation-unit name="delete/001">
         <output-dir compare="Text">delete/001</output-dir>
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml
 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml
index dc35948db7..d2fb6c1a9e 100644
--- 
a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_single_partition_sqlpp.xml
@@ -94,6 +94,16 @@
         <output-dir compare="Text">filter/ASTERIXDB-3502</output-dir>
       </compilation-unit>
     </test-case>
+    <test-case FilePath="column">
+      <compilation-unit name="filter/double">
+        <output-dir compare="Text">filter/double</output-dir>
+      </compilation-unit>
+    </test-case>
+    <test-case FilePath="column">
+      <compilation-unit name="filter/double-precision">
+        <output-dir compare="Text">filter/double-precision</output-dir>
+      </compilation-unit>
+    </test-case>
     <test-case FilePath="column">
       <compilation-unit name="delete/001">
         <output-dir compare="Text">delete/001</output-dir>
diff --git 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/AbstractColumnFilterComparatorFactory.java
 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/AbstractColumnFilterComparatorFactory.java
index fa9abdae1c..e0d927ef28 100644
--- 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/AbstractColumnFilterComparatorFactory.java
+++ 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/AbstractColumnFilterComparatorFactory.java
@@ -49,11 +49,16 @@ abstract class AbstractColumnFilterComparatorFactory 
implements IColumnRangeFilt
 
         ATypeTag leftTypeTag = leftAccessor.getTypeTag();
         ATypeTag rightTypeTag = rightAccessor.getTypeTag();
+        // We should not skip different types if they are compatible.
+        // However, we avoid applying range filters on incompatible types as 
normalization logic
+        // differs between types.
+        // Example: For queries on DOUBLE, we should not skip BIGINT.
         if (isNoOp(leftAccessor, rightAccessor)
                 || leftTypeTag != rightTypeTag && 
ATypeHierarchy.isCompatible(leftTypeTag, rightTypeTag)) {
             // Cannot compare comparable values with different types. Bail out.
             return TrueColumnFilterEvaluator.INSTANCE;
         } else if (cannotCompare(leftTypeTag, rightTypeTag)) {
+            // Columns with non-comparable types (e.g., DOUBLE and STRING) can 
be safely skipped.
             return FalseColumnFilterEvaluator.INSTANCE;
         }
         return createComparator(leftAccessor, rightAccessor);
diff --git 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java
 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java
index 0edee657f7..e61e7db8d8 100644
--- 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java
+++ 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GEColumnFilterEvaluatorFactory.java
@@ -21,6 +21,7 @@ package org.apache.asterix.column.filter.range.compartor;
 import org.apache.asterix.column.filter.IColumnFilterEvaluator;
 import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor;
 import 
org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory;
+import org.apache.asterix.om.types.ATypeTag;
 
 public class GEColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparatorFactory {
     private static final long serialVersionUID = 6879193736347174789L;
@@ -36,6 +37,10 @@ public class GEColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparat
         return new AbstractComparator(left, right) {
             @Override
             public boolean evaluate() {
+                if (left.getTypeTag() == ATypeTag.DOUBLE) {
+                    return Double.longBitsToDouble(left.getNormalizedValue()) 
>= Double
+                            .longBitsToDouble(right.getNormalizedValue());
+                }
                 return left.getNormalizedValue() >= right.getNormalizedValue();
             }
         };
diff --git 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java
 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java
index 7a21bd1ffb..2115d810f2 100644
--- 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java
+++ 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/GTColumnFilterEvaluatorFactory.java
@@ -21,6 +21,7 @@ package org.apache.asterix.column.filter.range.compartor;
 import org.apache.asterix.column.filter.IColumnFilterEvaluator;
 import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor;
 import 
org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory;
+import org.apache.asterix.om.types.ATypeTag;
 
 public class GTColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparatorFactory {
     private static final long serialVersionUID = -3104103170926445020L;
@@ -36,6 +37,10 @@ public class GTColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparat
         return new AbstractComparator(left, right) {
             @Override
             public boolean evaluate() {
+                if (left.getTypeTag() == ATypeTag.DOUBLE) {
+                    return Double.longBitsToDouble(left.getNormalizedValue()) 
> Double
+                            .longBitsToDouble(right.getNormalizedValue());
+                }
                 return left.getNormalizedValue() > right.getNormalizedValue();
             }
         };
diff --git 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java
 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java
index 7cef6ab868..99e1a39dd8 100644
--- 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java
+++ 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LEColumnFilterEvaluatorFactory.java
@@ -21,6 +21,7 @@ package org.apache.asterix.column.filter.range.compartor;
 import org.apache.asterix.column.filter.IColumnFilterEvaluator;
 import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor;
 import 
org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory;
+import org.apache.asterix.om.types.ATypeTag;
 
 public class LEColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparatorFactory {
     private static final long serialVersionUID = 1068661809768620550L;
@@ -36,6 +37,10 @@ public class LEColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparat
         return new AbstractComparator(left, right) {
             @Override
             public boolean evaluate() {
+                if (left.getTypeTag() == ATypeTag.DOUBLE) {
+                    return Double.longBitsToDouble(left.getNormalizedValue()) 
<= Double
+                            .longBitsToDouble(right.getNormalizedValue());
+                }
                 return left.getNormalizedValue() <= right.getNormalizedValue();
             }
         };
diff --git 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java
 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java
index 2848d57ca3..429be80d1c 100644
--- 
a/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java
+++ 
b/asterixdb/asterix-column/src/main/java/org/apache/asterix/column/filter/range/compartor/LTColumnFilterEvaluatorFactory.java
@@ -21,6 +21,7 @@ package org.apache.asterix.column.filter.range.compartor;
 import org.apache.asterix.column.filter.IColumnFilterEvaluator;
 import org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessor;
 import 
org.apache.asterix.column.filter.range.IColumnRangeFilterValueAccessorFactory;
+import org.apache.asterix.om.types.ATypeTag;
 
 public class LTColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparatorFactory {
     private static final long serialVersionUID = -4066709771630858677L;
@@ -36,6 +37,10 @@ public class LTColumnFilterEvaluatorFactory extends 
AbstractColumnFilterComparat
         return new AbstractComparator(left, right) {
             @Override
             public boolean evaluate() {
+                if (left.getTypeTag() == ATypeTag.DOUBLE) {
+                    return Double.longBitsToDouble(left.getNormalizedValue()) 
< Double
+                            .longBitsToDouble(right.getNormalizedValue());
+                }
                 return left.getNormalizedValue() < right.getNormalizedValue();
             }
         };
diff --git 
a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java
 
b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java
index 894394edb6..c77ca578c7 100644
--- 
a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java
+++ 
b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/utils/filter/ColumnRangeFilterBuilder.java
@@ -194,6 +194,14 @@ public class ColumnRangeFilterBuilder {
     private static IColumnRangeFilterEvaluatorFactory 
createEvaluator(ComparisonKind comparisonKind,
             IColumnRangeFilterValueAccessorFactory min, 
IColumnRangeFilterValueAccessorFactory constVal,
             IColumnRangeFilterValueAccessorFactory max) {
+
+        /*
+        * For a filter condition of the form col < const, the page will be 
read only if const >= min(col).
+        *  Similarly, for col <= const, the page will be read only if const > 
min(col).
+        *  for col > const, the page will be read only if const < max(col).
+        *  for col >= const, the page will be read only if const <= max(col).
+        * */
+
         if (comparisonKind == ComparisonKind.LT) {
             return new GTColumnFilterEvaluatorFactory(constVal, min);
         } else if (comparisonKind == ComparisonKind.LE) {

Reply via email to