You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2023/01/23 13:40:54 UTC

[doris] 01/03: [Bug](predicate) add double predicate creator (#15762)

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

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git

commit fce353ddaae31b2d3cb41bcdc021b87084614fd5
Author: AlexYue <yj...@gmail.com>
AuthorDate: Fri Jan 13 18:34:09 2023 +0800

    [Bug](predicate) add double predicate creator (#15762)
    
    Add one double predicator the same as integer predicate creator.
---
 be/src/olap/predicate_creator.h                           | 15 ++++++++++++++-
 regression-test/data/query_p0/limit/sql/withOrderBy.out   | 13 +++++++++++++
 regression-test/suites/query_p0/limit/sql/withOrderBy.sql |  4 ++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/be/src/olap/predicate_creator.h b/be/src/olap/predicate_creator.h
index 12d10e109f..95fd13f8a2 100644
--- a/be/src/olap/predicate_creator.h
+++ b/be/src/olap/predicate_creator.h
@@ -58,7 +58,14 @@ public:
 private:
     static CppType convert(const std::string& condition) {
         CppType value = 0;
-        std::from_chars(condition.data(), condition.data() + condition.size(), value);
+        // because std::from_chars can't compile on macOS
+        if constexpr (std::is_same_v<CppType, double>) {
+            value = std::stod(condition, nullptr);
+        } else if constexpr (std::is_same_v<CppType, float>) {
+            value = std::stof(condition, nullptr);
+        } else {
+            std::from_chars(condition.data(), condition.data() + condition.size(), value);
+        }
         return value;
     }
 };
@@ -157,6 +164,12 @@ inline std::unique_ptr<PredicateCreator<ConditionType>> get_creator(const FieldT
     case OLAP_FIELD_TYPE_LARGEINT: {
         return std::make_unique<IntegerPredicateCreator<TYPE_LARGEINT, PT, ConditionType>>();
     }
+    case OLAP_FIELD_TYPE_FLOAT: {
+        return std::make_unique<IntegerPredicateCreator<TYPE_FLOAT, PT, ConditionType>>();
+    }
+    case OLAP_FIELD_TYPE_DOUBLE: {
+        return std::make_unique<IntegerPredicateCreator<TYPE_DOUBLE, PT, ConditionType>>();
+    }
     case OLAP_FIELD_TYPE_DECIMAL: {
         return std::make_unique<CustomPredicateCreator<TYPE_DECIMALV2, PT, ConditionType>>(
                 [](const std::string& condition) {
diff --git a/regression-test/data/query_p0/limit/sql/withOrderBy.out b/regression-test/data/query_p0/limit/sql/withOrderBy.out
new file mode 100644
index 0000000000..70772b5fd7
--- /dev/null
+++ b/regression-test/data/query_p0/limit/sql/withOrderBy.out
@@ -0,0 +1,13 @@
+-- This file is automatically generated. You should know what you did if you want to edit this
+-- !withOrderBy --
+1.05
+1.2
+1.27
+1.43
+1.48
+1.63
+1.69
+1.87
+2.02
+2.04
+
diff --git a/regression-test/suites/query_p0/limit/sql/withOrderBy.sql b/regression-test/suites/query_p0/limit/sql/withOrderBy.sql
new file mode 100644
index 0000000000..96ba0d81dd
--- /dev/null
+++ b/regression-test/suites/query_p0/limit/sql/withOrderBy.sql
@@ -0,0 +1,4 @@
+SELECT ref_0.`supplycost`
+FROM regression_test_query_p0_limit.tpch_tiny_partsupp AS ref_0
+ORDER BY ref_0.`supplycost`
+LIMIT 10;
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org