diff --git a/src/optimizer/OptimizerUtils.h b/src/optimizer/OptimizerUtils.h index 98e1200907450f53f8e7a4513fd372c5a42f7c4e..661429e4da86d1bc3844a9a5622c735e371d7d3a 100644 --- a/src/optimizer/OptimizerUtils.h +++ b/src/optimizer/OptimizerUtils.h @@ -38,8 +38,6 @@ public: static Value boundValueWithMin(const meta::cpp2::ColumnDef& col); static Value normalizeValue(const meta::cpp2::ColumnDef& col, const Value& v); - - static constexpr double kEpsilon = 0.0000000000000001; }; } // namespace graph diff --git a/src/optimizer/test/IndexBoundValueTest.cpp b/src/optimizer/test/IndexBoundValueTest.cpp index 3e63fa62a227f302f59f1ef0d71775d562787f76..10503642ba394e23f1b44499037657837791dea3 100644 --- a/src/optimizer/test/IndexBoundValueTest.cpp +++ b/src/optimizer/test/IndexBoundValueTest.cpp @@ -115,14 +115,14 @@ TEST(IndexBoundValueTest, DoubleTest) { EXPECT_EQ(0.0, OptimizerUtils::boundValue(col, OP::LESS_THAN, Value(-minDouble)).getFloat()); - EXPECT_EQ(maxDouble - 0.0000000000000001, + EXPECT_EQ(maxDouble - kEpsilon, OptimizerUtils::boundValue(col, OP::LESS_THAN, Value(maxDouble)).getFloat()); EXPECT_EQ(-minDouble, OptimizerUtils::boundValue(col, OP::LESS_THAN, Value(0.0)).getFloat()); - EXPECT_EQ(5.1 - 0.0000000000000001, + EXPECT_EQ(5.1 - kEpsilon, OptimizerUtils::boundValue(col, OP::LESS_THAN, Value(5.1))); - EXPECT_EQ(-(5.1 + 0.0000000000000001), + EXPECT_EQ(-(5.1 + kEpsilon), OptimizerUtils::boundValue(col, OP::LESS_THAN, Value(-5.1))); EXPECT_EQ(maxDouble, @@ -132,10 +132,10 @@ TEST(IndexBoundValueTest, DoubleTest) { EXPECT_EQ(minDouble, OptimizerUtils::boundValue(col, OP::GREATER_THAN, Value(0.0)).getFloat()); - EXPECT_EQ(5.1 + 0.0000000000000001, + EXPECT_EQ(5.1 + kEpsilon, OptimizerUtils::boundValue(col, OP::GREATER_THAN, Value(5.1)).getFloat()); - EXPECT_EQ(-(5.1 - 0.0000000000000001), + EXPECT_EQ(-(5.1 - kEpsilon), OptimizerUtils::boundValue(col, OP::GREATER_THAN, Value(-5.1)).getFloat()); } diff --git a/src/optimizer/test/IndexScanRuleTest.cpp b/src/optimizer/test/IndexScanRuleTest.cpp index 1ddc2b967a2b0caffd2fe73262e2bc9143bfb6db..b47cd28f063e2b182762c213cad3cb3bdebd1d63 100644 --- a/src/optimizer/test/IndexScanRuleTest.cpp +++ b/src/optimizer/test/IndexScanRuleTest.cpp @@ -378,6 +378,20 @@ TEST(IndexScanRuleTest, BoundValueRangeTest) { EXPECT_EQ(-std::numeric_limits<double>::max(), *hint.begin_value_ref()); EXPECT_EQ(1, *hint.end_value_ref()); } + { + std::vector<storage::cpp2::IndexColumnHint> hints; + // col_double <= 3.0 + IndexScanRule::FilterItems items; + items.addItem("col_double", RelationalExpression::Kind::kRelLE, Value(3.0)); + auto status = instance->appendColHint(hints, items, col); + EXPECT_TRUE(status.ok()); + EXPECT_EQ(1, hints.size()); + const auto& hint = hints[0]; + EXPECT_EQ("col_double", *hint.column_name_ref()); + EXPECT_EQ(storage::cpp2::ScanType::RANGE, *hint.scan_type_ref()); + EXPECT_EQ(-std::numeric_limits<double>::max(), *hint.begin_value_ref()); + EXPECT_EQ(3 + kEpsilon, *hint.end_value_ref()); + } { std::vector<storage::cpp2::IndexColumnHint> hints; // col_double >= 1.0 @@ -404,8 +418,8 @@ TEST(IndexScanRuleTest, BoundValueRangeTest) { const auto& hint = hints[0]; EXPECT_EQ("col_double", *hint.column_name_ref()); EXPECT_EQ(storage::cpp2::ScanType::RANGE, *hint.scan_type_ref()); - EXPECT_EQ(1 + OptimizerUtils::kEpsilon, *hint.begin_value_ref()); - EXPECT_EQ(5 - OptimizerUtils::kEpsilon, *hint.end_value_ref()); + EXPECT_EQ(1 + kEpsilon, *hint.begin_value_ref()); + EXPECT_EQ(5 + kEpsilon, *hint.end_value_ref()); } } { diff --git a/tests/tck/features/lookup/LookUp.IntVid.feature b/tests/tck/features/lookup/LookUp.IntVid.feature index 3d444e428b6adee56eaa560fc8b13c254027f624..6af2529c4a1ce3b3c933d08ddea5f4354612f404 100644 --- a/tests/tck/features/lookup/LookUp.IntVid.feature +++ b/tests/tck/features/lookup/LookUp.IntVid.feature @@ -302,19 +302,19 @@ Feature: LookUpTest_Vid_Int """ Then the result should be, in any order: | VertexID | - # FIXME(aiee): should not contain vid 220 When executing query: """ - LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col3 > 100.5 + LOOKUP ON lookup_tag_2 + WHERE lookup_tag_2.col3 > 100.5 + YIELD lookup_tag_2.col3 AS col3 """ Then the result should be, in any order: - | VertexID | - | 220 | - | 221 | - | 222 | - | 223 | - | 224 | - | 225 | + | VertexID | col3 | + | 221 | 200.5 | + | 222 | 300.5 | + | 223 | 400.5 | + | 224 | 500.5 | + | 225 | 600.5 | When executing query: """ LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col3 == 100.5 @@ -328,15 +328,17 @@ Feature: LookUpTest_Vid_Int """ Then the result should be, in any order: | VertexID | - # FIXME(aiee): should contain vid 222 When executing query: """ - LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col3 >= 100.5 AND lookup_tag_2.col3 <= 300.5 + LOOKUP ON lookup_tag_2 + WHERE lookup_tag_2.col3 >= 100.5 AND lookup_tag_2.col3 <= 300.5 + YIELD lookup_tag_2.col3 AS col3 """ Then the result should be, in any order: - | VertexID | - | 220 | - | 221 | + | VertexID | col3 | + | 220 | 100.5 | + | 221 | 200.5 | + | 222 | 300.5 | Then drop the used space Scenario: LookupTest IntVid EdgeConditionScan @@ -452,18 +454,18 @@ Feature: LookUpTest_Vid_Int """ Then the result should be, in any order: | SrcVID | DstVID | Ranking | - # FIXME(aiee): should not contains first line When executing query: """ - LOOKUP ON lookup_edge_2 WHERE lookup_edge_2.col3 > 100.5 + LOOKUP ON lookup_edge_2 + WHERE lookup_edge_2.col3 > 100.5 + YIELD lookup_edge_2.col3 AS col3 """ Then the result should be, in any order: - | SrcVID | DstVID | Ranking | - | 220 | 221 | 0 | - | 220 | 222 | 0 | - | 220 | 223 | 0 | - | 220 | 224 | 0 | - | 220 | 225 | 0 | + | SrcVID | DstVID | Ranking | col3 | + | 220 | 222 | 0 | 200.5 | + | 220 | 223 | 0 | 300.5 | + | 220 | 224 | 0 | 400.5 | + | 220 | 225 | 0 | 500.5 | When executing query: """ LOOKUP ON lookup_edge_2 WHERE lookup_edge_2.col3 == 100.5 @@ -477,16 +479,17 @@ Feature: LookUpTest_Vid_Int """ Then the result should be, in any order: | SrcVID | DstVID | Ranking | - # FIXME(aiee): should contain 220->223 When executing query: """ - LOOKUP ON lookup_edge_2 WHERE lookup_edge_2.col3 >= 100.5 - AND lookup_edge_2.col3 <= 300.5 + LOOKUP ON lookup_edge_2 + WHERE lookup_edge_2.col3 >= 100.5 AND lookup_edge_2.col3 <= 300.5 + YIELD lookup_edge_2.col3 AS col3 """ Then the result should be, in any order: - | SrcVID | DstVID | Ranking | - | 220 | 221 | 0 | - | 220 | 222 | 0 | + | SrcVID | DstVID | Ranking | col3 | + | 220 | 221 | 0 | 100.5 | + | 220 | 222 | 0 | 200.5 | + | 220 | 223 | 0 | 300.5 | Then drop the used space Scenario: LookupTest IntVid FunctionExprTest diff --git a/tests/tck/features/lookup/LookUp.feature b/tests/tck/features/lookup/LookUp.feature index 4d6bc852bc7dec58677aa9e14d569bf013672e0e..4963928140cebdb63336c3b1f250ea54a750e8c1 100644 --- a/tests/tck/features/lookup/LookUp.feature +++ b/tests/tck/features/lookup/LookUp.feature @@ -270,19 +270,19 @@ Feature: LookUpTest_Vid_String """ Then the result should be, in any order: | VertexID | - # FIXME(aiee): should not contains vid 220 When executing query: """ - LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col3 > 100.5 + LOOKUP ON lookup_tag_2 + WHERE lookup_tag_2.col3 > 100.5 + YIELD lookup_tag_2.col3 AS col3 """ Then the result should be, in any order: - | VertexID | - | "220" | - | "221" | - | "222" | - | "223" | - | "224" | - | "225" | + | VertexID | col3 | + | "221" | 200.5 | + | "222" | 300.5 | + | "223" | 400.5 | + | "224" | 500.5 | + | "225" | 600.5 | When executing query: """ LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col3 == 100.5 @@ -296,15 +296,17 @@ Feature: LookUpTest_Vid_String """ Then the result should be, in any order: | VertexID | - # FIXME(aiee): should contain vid 222 When executing query: """ - LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col3 >= 100.5 AND lookup_tag_2.col3 <= 300.5 + LOOKUP ON lookup_tag_2 + WHERE lookup_tag_2.col3 >= 100.5 AND lookup_tag_2.col3 <= 300.5 + YIELD lookup_tag_2.col3 AS col3 """ Then the result should be, in any order: - | VertexID | - | "220" | - | "221" | + | VertexID | col3 | + | "220" | 100.5 | + | "221" | 200.5 | + | "222" | 300.5 | Then drop the used space Scenario: LookupTest EdgeConditionScan @@ -413,18 +415,18 @@ Feature: LookUpTest_Vid_String """ Then the result should be, in any order: | SrcVID | DstVID | Ranking | - # FIXME(aiee): shouble not contain first line When executing query: """ - LOOKUP ON lookup_edge_2 WHERE lookup_edge_2.col3 > 100.5 + LOOKUP ON lookup_edge_2 + WHERE lookup_edge_2.col3 > 100.5 + YIELD lookup_edge_2.col3 AS col3 """ Then the result should be, in any order: - | SrcVID | DstVID | Ranking | - | "220" | "221" | 0 | - | "220" | "222" | 0 | - | "220" | "223" | 0 | - | "220" | "224" | 0 | - | "220" | "225" | 0 | + | SrcVID | DstVID | Ranking | col3 | + | "220" | "222" | 0 | 200.5 | + | "220" | "223" | 0 | 300.5 | + | "220" | "224" | 0 | 400.5 | + | "220" | "225" | 0 | 500.5 | When executing query: """ LOOKUP ON lookup_edge_2 WHERE lookup_edge_2.col3 == 100.5 @@ -438,16 +440,17 @@ Feature: LookUpTest_Vid_String """ Then the result should be, in any order: | SrcVID | DstVID | Ranking | - # FIXME(aiee): should contain edge 200->223 When executing query: """ - LOOKUP ON lookup_edge_2 WHERE lookup_edge_2.col3 >= 100.5 - AND lookup_edge_2.col3 <= 300.5 + LOOKUP ON lookup_edge_2 + WHERE lookup_edge_2.col3 >= 100.5 AND lookup_edge_2.col3 <= 300.5 + YIELD lookup_edge_2.col3 AS col3 """ Then the result should be, in any order: - | SrcVID | DstVID | Ranking | - | "220" | "221" | 0 | - | "220" | "222" | 0 | + | SrcVID | DstVID | Ranking | col3 | + | "220" | "221" | 0 | 100.5 | + | "220" | "222" | 0 | 200.5 | + | "220" | "223" | 0 | 300.5 | Then drop the used space Scenario: LookupTest FunctionExprTest @@ -560,12 +563,6 @@ Feature: LookUpTest_Vid_String # """ # Then the result should be, in any order: # | VertexID | - # When executing query: - # """ - # LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col4 == strcasecmp("HelLo", "hello") - # """ - # Then the result should be, in any order: - # | VertexID | When executing query: """ LOOKUP ON lookup_tag_2 WHERE lookup_tag_2.col2 != lookup_tag_2.col3