diff --git a/src/executor/query/IndexScanExecutor.cpp b/src/executor/query/IndexScanExecutor.cpp index 2d270d313..7fce3bd45 100644 --- a/src/executor/query/IndexScanExecutor.cpp +++ b/src/executor/query/IndexScanExecutor.cpp @@ -6,6 +6,8 @@ #include "executor/query/IndexScanExecutor.h" +#include + #include "planner/plan/PlanNode.h" #include "context/QueryContext.h" #include "service/GraphFlags.h" @@ -28,8 +30,16 @@ folly::Future IndexScanExecutor::indexScan() { DataSet dataSet({"dummy"}); return finish(ResultBuilder().value(Value(std::move(dataSet))).finish()); } + + const auto &ictxs = lookup->queryContext(); + auto iter = std::find_if( + ictxs.begin(), ictxs.end(), [](auto &ictx) { return !ictx.index_id_ref().is_set(); }); + if (ictxs.empty() || iter != ictxs.end()) { + return Status::Error("There is no index to use at runtime"); + } + return storageClient->lookupIndex(lookup->space(), - lookup->queryContext(), + ictxs, lookup->isEdge(), lookup->schemaId(), lookup->returnColumns()) diff --git a/tests/tck/features/lookup/LookUp.IntVid.feature b/tests/tck/features/lookup/LookUp.IntVid.feature index 1ec7040c9..3628a5cd4 100644 --- a/tests/tck/features/lookup/LookUp.IntVid.feature +++ b/tests/tck/features/lookup/LookUp.IntVid.feature @@ -1,6 +1,6 @@ Feature: LookUpTest_Vid_Int - Scenario: LookupTest IntVid VertexIndexHint + Background: Given an empty graph And create a space with following options: | partition_num | 9 | @@ -8,7 +8,9 @@ Feature: LookUpTest_Vid_Int | vid_type | int64 | | charset | utf8 | | collate | utf8_bin | - And having executed: + + Scenario: LookupTest IntVid VertexIndexHint + Given having executed: """ CREATE TAG lookup_tag_1(col1 int, col2 int, col3 int); CREATE TAG lookup_tag_2(col1 bool, col2 int, col3 double, col4 bool); @@ -45,14 +47,7 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid EdgeIndexHint - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | - And having executed: + Given having executed: """ CREATE EDGE lookup_edge_1(col1 int, col2 int, col3 int); CREATE EDGE lookup_edge_2(col1 bool,col2 int, col3 double, col4 bool); @@ -86,14 +81,7 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid VertexConditionScan - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | - And having executed: + Given having executed: """ CREATE TAG lookup_tag_2(col1 bool, col2 int, col3 double, col4 bool); CREATE TAG INDEX t_index_2 ON lookup_tag_2(col2, col3, col4); @@ -244,14 +232,7 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid EdgeConditionScan - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | - And having executed: + Given having executed: """ CREATE EDGE lookup_edge_2(col1 bool,col2 int, col3 double, col4 bool); CREATE EDGE INDEX e_index_2 ON lookup_edge_2(col2, col3, col4); @@ -395,14 +376,7 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid FunctionExprTest - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | - And having executed: + Given having executed: """ CREATE TAG lookup_tag_2(col1 bool, col2 int, col3 double, col4 bool); CREATE TAG INDEX t_index_2 ON lookup_tag_2(col2, col3, col4); @@ -532,13 +506,6 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid YieldClauseTest - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | When executing query: """ CREATE TAG student(number int, age int) @@ -590,13 +557,6 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid OptimizerTest - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | When executing query: """ CREATE TAG t1(c1 int, c2 int, c3 int, c4 int, c5 int) @@ -681,13 +641,6 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid OptimizerWithStringFieldTest - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | When executing query: """ CREATE TAG t1_str(c1 int, c2 int, c3 string, c4 string) @@ -762,13 +715,6 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid StringFieldTest - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | When executing query: """ CREATE TAG tag_with_str(c1 int, c2 string, c3 string) @@ -848,13 +794,6 @@ Feature: LookUpTest_Vid_Int Then drop the used space Scenario: LookupTest IntVid ConditionTest - Given an empty graph - And create a space with following options: - | partition_num | 9 | - | replica_factor | 1 | - | vid_type | int64 | - | charset | utf8 | - | collate | utf8_bin | When executing query: """ create tag identity (BIRTHDAY int, NATION string, BIRTHPLACE_CITY string) @@ -887,3 +826,21 @@ Feature: LookUpTest_Vid_Int Then the result should be, in any order: | VertexID | Then drop the used space + + Scenario: LookupTest no index to use at runtime + Given having executed: + """ + CREATE TAG player(name string, age int); + """ + And wait 6 seconds + When executing query: + """ + INSERT VERTEX player(name, age) VALUES hash('Tim'):('Tim', 20); + """ + Then the execution should be successful + When executing query: + """ + LOOKUP ON player WHERE player.name == 'Tim' + """ + Then an ExecutionError should be raised at runtime: There is no index to use at runtime + Then drop the used space diff --git a/tests/tck/features/lookup/LookUp.feature b/tests/tck/features/lookup/LookUp.feature index 5ab0caef6..6afca5f52 100644 --- a/tests/tck/features/lookup/LookUp.feature +++ b/tests/tck/features/lookup/LookUp.feature @@ -957,3 +957,21 @@ Feature: LookUpTest_Vid_String | VertexID | | '202' | Then drop the used space + + Scenario: LookupTest no index to use at runtime + Given having executed: + """ + CREATE TAG player(name string, age int); + """ + And wait 6 seconds + When executing query: + """ + INSERT VERTEX player(name, age) VALUES 'Tim':('Tim', 20); + """ + Then the execution should be successful + When executing query: + """ + LOOKUP ON player WHERE player.name == 'Tim' + """ + Then an ExecutionError should be raised at runtime: There is no index to use at runtime + Then drop the used space