You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ha...@apache.org on 2021/09/17 09:17:34 UTC

[skywalking-banyandb] branch main updated: Replace sorting key with index rule name (#47)

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

hanahmily pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git


The following commit(s) were added to refs/heads/main by this push:
     new 4dee0de  Replace sorting key with index rule name (#47)
4dee0de is described below

commit 4dee0de9699b26045f778d9721f7f5e027e4b711
Author: Gao Hongtao <ha...@gmail.com>
AuthorDate: Fri Sep 17 17:17:29 2021 +0800

    Replace sorting key with index rule name (#47)
    
    Add test cases to metadata
    
    Signed-off-by: Gao Hongtao <ha...@gmail.com>
---
 api/proto/banyandb/model/v2/query.pb.go | 89 +++++++++++++++++----------------
 api/proto/banyandb/model/v2/query.proto |  8 +--
 banyand/metadata/schema/sw.go           | 25 +++++++--
 banyand/metadata/schema/sw_test.go      | 73 +++++++++++++++++++++++++++
 banyand/stream/stream_query.go          |  1 -
 5 files changed, 142 insertions(+), 54 deletions(-)

diff --git a/api/proto/banyandb/model/v2/query.pb.go b/api/proto/banyandb/model/v2/query.pb.go
index a58ce57..e1cd9a1 100644
--- a/api/proto/banyandb/model/v2/query.pb.go
+++ b/api/proto/banyandb/model/v2/query.pb.go
@@ -331,15 +331,15 @@ func (x *Condition) GetValue() *TagValue {
 	return nil
 }
 
-// QueryOrder means a Sort operation to be done for a given tag.
-// The key_name refers to the key of a Pair.
+// QueryOrder means a Sort operation to be done for a given index rule.
+// The index_rule_name refers to the name of a index rule bound to the subject.
 type QueryOrder struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	KeyName string          `protobuf:"bytes,1,opt,name=key_name,json=keyName,proto3" json:"key_name,omitempty"`
-	Sort    QueryOrder_Sort `protobuf:"varint,2,opt,name=sort,proto3,enum=banyandb.model.v2.QueryOrder_Sort" json:"sort,omitempty"`
+	IndexRuleName string          `protobuf:"bytes,1,opt,name=index_rule_name,json=indexRuleName,proto3" json:"index_rule_name,omitempty"`
+	Sort          QueryOrder_Sort `protobuf:"varint,2,opt,name=sort,proto3,enum=banyandb.model.v2.QueryOrder_Sort" json:"sort,omitempty"`
 }
 
 func (x *QueryOrder) Reset() {
@@ -374,9 +374,9 @@ func (*QueryOrder) Descriptor() ([]byte, []int) {
 	return file_banyandb_model_v2_query_proto_rawDescGZIP(), []int{3}
 }
 
-func (x *QueryOrder) GetKeyName() string {
+func (x *QueryOrder) GetIndexRuleName() string {
 	if x != nil {
-		return x.KeyName
+		return x.IndexRuleName
 	}
 	return ""
 }
@@ -395,7 +395,7 @@ type Projection struct {
 	unknownFields protoimpl.UnknownFields
 
 	// The key_name refers to the key(s) of Pair(s).
-	FagFamilies []*Projection_TagFamily `protobuf:"bytes,1,rep,name=fag_families,json=fagFamilies,proto3" json:"fag_families,omitempty"`
+	TagFamilies []*Projection_TagFamily `protobuf:"bytes,1,rep,name=tag_families,json=tagFamilies,proto3" json:"tag_families,omitempty"`
 }
 
 func (x *Projection) Reset() {
@@ -430,9 +430,9 @@ func (*Projection) Descriptor() ([]byte, []int) {
 	return file_banyandb_model_v2_query_proto_rawDescGZIP(), []int{4}
 }
 
-func (x *Projection) GetFagFamilies() []*Projection_TagFamily {
+func (x *Projection) GetTagFamilies() []*Projection_TagFamily {
 	if x != nil {
-		return x.FagFamilies
+		return x.TagFamilies
 	}
 	return nil
 }
@@ -588,40 +588,41 @@ var file_banyandb_model_v2_query_proto_rawDesc = []byte{
 	0x5f, 0x4f, 0x50, 0x5f, 0x47, 0x45, 0x10, 0x06, 0x12, 0x14, 0x0a, 0x10, 0x42, 0x49, 0x4e, 0x41,
 	0x52, 0x59, 0x5f, 0x4f, 0x50, 0x5f, 0x48, 0x41, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x07, 0x12, 0x18,
 	0x0a, 0x14, 0x42, 0x49, 0x4e, 0x41, 0x52, 0x59, 0x5f, 0x4f, 0x50, 0x5f, 0x4e, 0x4f, 0x54, 0x5f,
-	0x48, 0x41, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x08, 0x22, 0x9a, 0x01, 0x0a, 0x0a, 0x51, 0x75, 0x65,
-	0x72, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x6b, 0x65, 0x79, 0x5f, 0x6e,
-	0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6b, 0x65, 0x79, 0x4e, 0x61,
-	0x6d, 0x65, 0x12, 0x36, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e,
-	0x32, 0x22, 0x2e, 0x62, 0x61, 0x6e, 0x79, 0x61, 0x6e, 0x64, 0x62, 0x2e, 0x6d, 0x6f, 0x64, 0x65,
-	0x6c, 0x2e, 0x76, 0x32, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x2e,
-	0x53, 0x6f, 0x72, 0x74, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x39, 0x0a, 0x04, 0x53, 0x6f,
-	0x72, 0x74, 0x12, 0x14, 0x0a, 0x10, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45,
-	0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x4f, 0x52, 0x54,
-	0x5f, 0x44, 0x45, 0x53, 0x43, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x4f, 0x52, 0x54, 0x5f,
-	0x41, 0x53, 0x43, 0x10, 0x02, 0x22, 0x8d, 0x01, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63,
-	0x74, 0x69, 0x6f, 0x6e, 0x12, 0x4a, 0x0a, 0x0c, 0x66, 0x61, 0x67, 0x5f, 0x66, 0x61, 0x6d, 0x69,
-	0x6c, 0x69, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x62, 0x61, 0x6e,
-	0x79, 0x61, 0x6e, 0x64, 0x62, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x32, 0x2e, 0x50,
-	0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x61, 0x67, 0x46, 0x61, 0x6d,
-	0x69, 0x6c, 0x79, 0x52, 0x0b, 0x66, 0x61, 0x67, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73,
-	0x1a, 0x33, 0x0a, 0x09, 0x54, 0x61, 0x67, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x12, 0x0a,
-	0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d,
-	0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52,
-	0x04, 0x74, 0x61, 0x67, 0x73, 0x22, 0x6b, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x61, 0x6e,
-	0x67, 0x65, 0x12, 0x30, 0x0a, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28,
-	0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-	0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x62,
-	0x65, 0x67, 0x69, 0x6e, 0x12, 0x2c, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28,
-	0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
-	0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x03, 0x65,
-	0x6e, 0x64, 0x42, 0x6c, 0x0a, 0x27, 0x6f, 0x72, 0x67, 0x2e, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65,
-	0x2e, 0x73, 0x6b, 0x79, 0x77, 0x61, 0x6c, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x62, 0x61, 0x6e, 0x79,
-	0x61, 0x6e, 0x64, 0x62, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x32, 0x5a, 0x41, 0x67,
-	0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65,
-	0x2f, 0x73, 0x6b, 0x79, 0x77, 0x61, 0x6c, 0x6b, 0x69, 0x6e, 0x67, 0x2d, 0x62, 0x61, 0x6e, 0x79,
-	0x61, 0x6e, 0x64, 0x62, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x62,
-	0x61, 0x6e, 0x79, 0x61, 0x6e, 0x64, 0x62, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x76, 0x32,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x48, 0x41, 0x56, 0x49, 0x4e, 0x47, 0x10, 0x08, 0x22, 0xa7, 0x01, 0x0a, 0x0a, 0x51, 0x75, 0x65,
+	0x72, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x26, 0x0a, 0x0f, 0x69, 0x6e, 0x64, 0x65, 0x78,
+	0x5f, 0x72, 0x75, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
+	0x52, 0x0d, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x52, 0x75, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12,
+	0x36, 0x0a, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x22, 0x2e,
+	0x62, 0x61, 0x6e, 0x79, 0x61, 0x6e, 0x64, 0x62, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76,
+	0x32, 0x2e, 0x51, 0x75, 0x65, 0x72, 0x79, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x2e, 0x53, 0x6f, 0x72,
+	0x74, 0x52, 0x04, 0x73, 0x6f, 0x72, 0x74, 0x22, 0x39, 0x0a, 0x04, 0x53, 0x6f, 0x72, 0x74, 0x12,
+	0x14, 0x0a, 0x10, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,
+	0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x0d, 0x0a, 0x09, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x44, 0x45,
+	0x53, 0x43, 0x10, 0x01, 0x12, 0x0c, 0x0a, 0x08, 0x53, 0x4f, 0x52, 0x54, 0x5f, 0x41, 0x53, 0x43,
+	0x10, 0x02, 0x22, 0x8d, 0x01, 0x0a, 0x0a, 0x50, 0x72, 0x6f, 0x6a, 0x65, 0x63, 0x74, 0x69, 0x6f,
+	0x6e, 0x12, 0x4a, 0x0a, 0x0c, 0x74, 0x61, 0x67, 0x5f, 0x66, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65,
+	0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x27, 0x2e, 0x62, 0x61, 0x6e, 0x79, 0x61, 0x6e,
+	0x64, 0x62, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x72, 0x6f, 0x6a,
+	0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x54, 0x61, 0x67, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79,
+	0x52, 0x0b, 0x74, 0x61, 0x67, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x69, 0x65, 0x73, 0x1a, 0x33, 0x0a,
+	0x09, 0x54, 0x61, 0x67, 0x46, 0x61, 0x6d, 0x69, 0x6c, 0x79, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61,
+	0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12,
+	0x0a, 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04, 0x74, 0x61,
+	0x67, 0x73, 0x22, 0x6b, 0x0a, 0x09, 0x54, 0x69, 0x6d, 0x65, 0x52, 0x61, 0x6e, 0x67, 0x65, 0x12,
+	0x30, 0x0a, 0x05, 0x62, 0x65, 0x67, 0x69, 0x6e, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a,
+	0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
+	0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x05, 0x62, 0x65, 0x67, 0x69,
+	0x6e, 0x12, 0x2c, 0x0a, 0x03, 0x65, 0x6e, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a,
+	0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
+	0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x03, 0x65, 0x6e, 0x64, 0x42,
+	0x6c, 0x0a, 0x27, 0x6f, 0x72, 0x67, 0x2e, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2e, 0x73, 0x6b,
+	0x79, 0x77, 0x61, 0x6c, 0x6b, 0x69, 0x6e, 0x67, 0x2e, 0x62, 0x61, 0x6e, 0x79, 0x61, 0x6e, 0x64,
+	0x62, 0x2e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x76, 0x32, 0x5a, 0x41, 0x67, 0x69, 0x74, 0x68,
+	0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2f, 0x73, 0x6b,
+	0x79, 0x77, 0x61, 0x6c, 0x6b, 0x69, 0x6e, 0x67, 0x2d, 0x62, 0x61, 0x6e, 0x79, 0x61, 0x6e, 0x64,
+	0x62, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x62, 0x61, 0x6e, 0x79,
+	0x61, 0x6e, 0x64, 0x62, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x2f, 0x76, 0x32, 0x62, 0x06, 0x70,
+	0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -657,7 +658,7 @@ var file_banyandb_model_v2_query_proto_depIdxs = []int32{
 	0,  // 2: banyandb.model.v2.Condition.op:type_name -> banyandb.model.v2.Condition.BinaryOp
 	9,  // 3: banyandb.model.v2.Condition.value:type_name -> banyandb.model.v2.TagValue
 	1,  // 4: banyandb.model.v2.QueryOrder.sort:type_name -> banyandb.model.v2.QueryOrder.Sort
-	8,  // 5: banyandb.model.v2.Projection.fag_families:type_name -> banyandb.model.v2.Projection.TagFamily
+	8,  // 5: banyandb.model.v2.Projection.tag_families:type_name -> banyandb.model.v2.Projection.TagFamily
 	10, // 6: banyandb.model.v2.TimeRange.begin:type_name -> google.protobuf.Timestamp
 	10, // 7: banyandb.model.v2.TimeRange.end:type_name -> google.protobuf.Timestamp
 	8,  // [8:8] is the sub-list for method output_type
diff --git a/api/proto/banyandb/model/v2/query.proto b/api/proto/banyandb/model/v2/query.proto
index 73262a9..599775e 100644
--- a/api/proto/banyandb/model/v2/query.proto
+++ b/api/proto/banyandb/model/v2/query.proto
@@ -62,10 +62,10 @@ message Condition {
     TagValue value = 2;
 }
 
-// QueryOrder means a Sort operation to be done for a given tag.
-// The key_name refers to the key of a Pair.
+// QueryOrder means a Sort operation to be done for a given index rule.
+// The index_rule_name refers to the name of a index rule bound to the subject.
 message QueryOrder {
-    string key_name = 1;
+    string index_rule_name = 1;
     enum Sort {
         SORT_UNSPECIFIED = 0;
         SORT_DESC = 1;
@@ -81,7 +81,7 @@ message Projection {
         repeated string tags = 2;
     }
     // The key_name refers to the key(s) of Pair(s).
-    repeated TagFamily fag_families = 1;
+    repeated TagFamily tag_families = 1;
 }
 
 // TimeRange is a range query for uint64,
diff --git a/banyand/metadata/schema/sw.go b/banyand/metadata/schema/sw.go
index c3e4387..f1dad20 100644
--- a/banyand/metadata/schema/sw.go
+++ b/banyand/metadata/schema/sw.go
@@ -21,6 +21,7 @@ import (
 	"bytes"
 	"context"
 	"embed"
+	"strings"
 
 	"github.com/golang/protobuf/jsonpb"
 
@@ -28,6 +29,8 @@ import (
 	databasev2 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v2"
 )
 
+const indexRuleDir = "data/index_rules"
+
 var (
 	_ Stream    = (*streamRepo)(nil)
 	_ IndexRule = (*indexRuleRepo)(nil)
@@ -58,7 +61,7 @@ func (l *streamRepo) Get(_ context.Context, _ *commonv2.Metadata) (*databasev2.S
 	return l.data, nil
 }
 
-func (l *streamRepo) List(ctx context.Context, _ ListOpt) ([]*databasev2.Stream, error) {
+func (l *streamRepo) List(ctx context.Context, opts ListOpt) ([]*databasev2.Stream, error) {
 	s, err := l.Get(ctx, nil)
 	if err != nil {
 		return nil, err
@@ -77,7 +80,7 @@ func NewIndexRule() (IndexRule, error) {
 }
 
 func (i *indexRuleRepo) Get(_ context.Context, metadata *commonv2.Metadata) (*databasev2.IndexRule, error) {
-	bb, err := i.store.ReadFile("data/index_rules/" + metadata.Name + ".json")
+	bb, err := i.store.ReadFile(indexRuleDir + "/" + metadata.Name + ".json")
 	if err != nil {
 		return nil, err
 	}
@@ -89,12 +92,24 @@ func (i *indexRuleRepo) Get(_ context.Context, metadata *commonv2.Metadata) (*da
 	return indexRule, nil
 }
 
-func (i *indexRuleRepo) List(ctx context.Context, _ ListOpt) ([]*databasev2.IndexRule, error) {
-	t, err := i.Get(ctx, nil)
+func (i *indexRuleRepo) List(ctx context.Context, opt ListOpt) ([]*databasev2.IndexRule, error) {
+	entries, err := i.store.ReadDir(indexRuleDir)
 	if err != nil {
 		return nil, err
 	}
-	return []*databasev2.IndexRule{t}, nil
+	rules := make([]*databasev2.IndexRule, 0, len(entries))
+	for _, entry := range entries {
+		name := strings.TrimSuffix(entry.Name(), ".json")
+		r, errInternal := i.Get(ctx, &commonv2.Metadata{
+			Name:  name,
+			Group: opt.Group,
+		})
+		if errInternal != nil {
+			return nil, errInternal
+		}
+		rules = append(rules, r)
+	}
+	return rules, nil
 }
 
 type indexRuleBindingRepo struct {
diff --git a/banyand/metadata/schema/sw_test.go b/banyand/metadata/schema/sw_test.go
new file mode 100644
index 0000000..c68c2a6
--- /dev/null
+++ b/banyand/metadata/schema/sw_test.go
@@ -0,0 +1,73 @@
+// Licensed to 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. Apache Software Foundation (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.
+
+package schema
+
+import (
+	"context"
+	"testing"
+
+	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
+
+	commonv2 "github.com/apache/skywalking-banyandb/api/proto/banyandb/common/v2"
+)
+
+func Test_IndexRule(t *testing.T) {
+	ast := assert.New(t)
+	is := require.New(t)
+	ir, err := NewIndexRule()
+	is.NoError(err)
+	r, err := ir.Get(context.Background(), &commonv2.Metadata{Name: "duration", Group: "default"})
+	is.NoError(err)
+	ast.NotNil(r)
+	ast.Equal("duration", r.Metadata.Name)
+	is.NoError(err)
+	rules, err := ir.List(context.Background(), ListOpt{})
+	is.NoError(err)
+	ast.NotEmpty(rules)
+}
+
+func Test_Stream(t *testing.T) {
+	ast := assert.New(t)
+	is := require.New(t)
+	s, err := NewStream()
+	is.NoError(err)
+	r, err := s.Get(context.Background(), &commonv2.Metadata{Name: "sw", Group: "default"})
+	is.NoError(err)
+	ast.NotNil(r)
+	ast.Equal("sw", r.Metadata.Name)
+	is.NoError(err)
+	rules, err := s.List(context.Background(), ListOpt{})
+	is.NoError(err)
+	ast.NotEmpty(rules)
+}
+
+func Test_IndexRuleBinding(t *testing.T) {
+	ast := assert.New(t)
+	is := require.New(t)
+	irb, err := NewIndexRuleBinding()
+	is.NoError(err)
+	r, err := irb.Get(context.Background(), &commonv2.Metadata{Name: "sw-index-rule-binding", Group: "default"})
+	is.NoError(err)
+	ast.NotNil(r)
+	ast.Equal("sw-index-rule-binding", r.Metadata.Name)
+	is.NoError(err)
+	rules, err := irb.List(context.Background(), ListOpt{})
+	is.NoError(err)
+	ast.NotEmpty(rules)
+}
diff --git a/banyand/stream/stream_query.go b/banyand/stream/stream_query.go
index 5bd9844..fd0a05c 100644
--- a/banyand/stream/stream_query.go
+++ b/banyand/stream/stream_query.go
@@ -31,7 +31,6 @@ import (
 )
 
 var (
-	ErrTagNotExist       = errors.New("the tag doesn't exist")
 	ErrTagFamilyNotExist = errors.New("tag family doesn't exist")
 )