Skip to content

Commit 2a9edb1

Browse files
author
Minh Le
committed
update test
1 parent a930afd commit 2a9edb1

File tree

3 files changed

+76
-26
lines changed

3 files changed

+76
-26
lines changed

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationBaselineTests.TestFullTextScoreOrderByRankFunction.xml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,52 +66,52 @@ ORDER BY RANK FullTextScore(root["StringField"], "test1", "test2", "test3")]]></
6666
<Result>
6767
<Input>
6868
<Description><![CDATA[FullTextScore in WHERE clause]]></Description>
69-
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1"}) != null))]]></Expression>
69+
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1"}) != 123))]]></Expression>
7070
</Input>
7171
<Output>
7272
<SqlQuery><![CDATA[
7373
SELECT VALUE root
7474
FROM root
75-
WHERE (FullTextScore(root["StringField"], "test1") != null)]]></SqlQuery>
75+
WHERE (FullTextScore(root["StringField"], "test1") != 123)]]></SqlQuery>
7676
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":35,"end":78},"code":"SC2240","message":"The FullTextScore function is only allowed in the ORDER BY RANK clause."}]},0x800A0B00]]></ErrorMessage>
7777
</Output>
7878
</Result>
7979
<Result>
8080
<Input>
8181
<Description><![CDATA[FullTextScore in WHERE clause 2]]></Description>
82-
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1", "test2", "test3"}) != null))]]></Expression>
82+
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1", "test2", "test3"}) != 123))]]></Expression>
8383
</Input>
8484
<Output>
8585
<SqlQuery><![CDATA[
8686
SELECT VALUE root
8787
FROM root
88-
WHERE (FullTextScore(root["StringField"], "test1", "test2", "test3") != null)]]></SqlQuery>
88+
WHERE (FullTextScore(root["StringField"], "test1", "test2", "test3") != 123)]]></SqlQuery>
8989
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":35,"end":96},"code":"SC2240","message":"The FullTextScore function is only allowed in the ORDER BY RANK clause."}]},0x800A0B00]]></ErrorMessage>
9090
</Output>
9191
</Result>
9292
<Result>
9393
<Input>
9494
<Description><![CDATA[FullTextScore in WHERE clause]]></Description>
95-
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1"}) != null))]]></Expression>
95+
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1"}) != 123))]]></Expression>
9696
</Input>
9797
<Output>
9898
<SqlQuery><![CDATA[
9999
SELECT VALUE root
100100
FROM root
101-
WHERE (FullTextScore(root["StringField"], "test1") != null)]]></SqlQuery>
101+
WHERE (FullTextScore(root["StringField"], "test1") != 123)]]></SqlQuery>
102102
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":35,"end":78},"code":"SC2240","message":"The FullTextScore function is only allowed in the ORDER BY RANK clause."}]},0x800A0B00]]></ErrorMessage>
103103
</Output>
104104
</Result>
105105
<Result>
106106
<Input>
107107
<Description><![CDATA[FullTextScore in WHERE clause 2]]></Description>
108-
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1", "test2", "test3"}) != null))]]></Expression>
108+
<Expression><![CDATA[query.Where(doc => (doc.StringField.FullTextScore(new [] {"test1", "test2", "test3"}) != 123))]]></Expression>
109109
</Input>
110110
<Output>
111111
<SqlQuery><![CDATA[
112112
SELECT VALUE root
113113
FROM root
114-
WHERE (FullTextScore(root["StringField"], "test1", "test2", "test3") != null)]]></SqlQuery>
114+
WHERE (FullTextScore(root["StringField"], "test1", "test2", "test3") != 123)]]></SqlQuery>
115115
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":35,"end":96},"code":"SC2240","message":"The FullTextScore function is only allowed in the ORDER BY RANK clause."}]},0x800A0B00]]></ErrorMessage>
116116
</Output>
117117
</Result>

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/BaselineTest/TestBaseline/LinqTranslationBaselineTests.TestRRFOrderByRankFunction.xml

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,77 @@ ORDER BY RANK RRF(FullTextScore(root["StringField"], "test1"))]]></SqlQuery>
4747
<Result>
4848
<Input>
4949
<Description><![CDATA[RRF in WHERE clause]]></Description>
50-
<Expression><![CDATA[query.Where(doc => (RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"})}) != null))]]></Expression>
50+
<Expression><![CDATA[query.Where(doc => (RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"})}) != 123))]]></Expression>
5151
</Input>
5252
<Output>
5353
<SqlQuery><![CDATA[
5454
SELECT VALUE root
5555
FROM root
56-
WHERE (RRF(FullTextScore(root["StringField"], "test1")) != null)]]></SqlQuery>
56+
WHERE (RRF(FullTextScore(root["StringField"], "test1")) != 123)]]></SqlQuery>
5757
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":39,"end":82},"code":"SC2240","message":"The FullTextScore function is only allowed in the ORDER BY RANK clause."},{"severity":"Error","location":{"start":35,"end":38},"code":"SC2005","message":"'RRF' is not a recognized built-in function name."}]},0x800A0B00]]></ErrorMessage>
5858
</Output>
5959
</Result>
6060
<Result>
6161
<Input>
6262
<Description><![CDATA[RRF in WHERE clause 2]]></Description>
63-
<Expression><![CDATA[query.Where(doc => (RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), doc.StringField2.FullTextScore(new [] {"test1", "test2", "test3"})}) != null))]]></Expression>
63+
<Expression><![CDATA[query.Where(doc => (RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), doc.StringField2.FullTextScore(new [] {"test1", "test2", "test3"})}) != 123))]]></Expression>
6464
</Input>
6565
<Output>
6666
<SqlQuery><![CDATA[
6767
SELECT VALUE root
6868
FROM root
69-
WHERE (RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["StringField2"], "test1", "test2", "test3")) != null)]]></SqlQuery>
69+
WHERE (RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["StringField2"], "test1", "test2", "test3")) != 123)]]></SqlQuery>
7070
<ErrorMessage><![CDATA[Status Code: BadRequest,{"errors":[{"severity":"Error","location":{"start":39,"end":82},"code":"SC2240","message":"The FullTextScore function is only allowed in the ORDER BY RANK clause."},{"severity":"Error","location":{"start":84,"end":146},"code":"SC2240","message":"The FullTextScore function is only allowed in the ORDER BY RANK clause."},{"severity":"Error","location":{"start":35,"end":38},"code":"SC2005","message":"'RRF' is not a recognized built-in function name."}]},0x800A0B00]]></ErrorMessage>
7171
</Output>
7272
</Result>
73+
<Result>
74+
<Input>
75+
<Description><![CDATA[RRF with non scoring function]]></Description>
76+
<Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), 123}))]]></Expression>
77+
</Input>
78+
<Output>
79+
<SqlQuery><![CDATA[]]></SqlQuery>
80+
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
81+
</Output>
82+
</Result>
83+
<Result>
84+
<Input>
85+
<Description><![CDATA[RRF with non scoring function 2]]></Description>
86+
<Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), (doc.IntField * 1)}))]]></Expression>
87+
</Input>
88+
<Output>
89+
<SqlQuery><![CDATA[]]></SqlQuery>
90+
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
91+
</Output>
92+
</Result>
93+
<Result>
94+
<Input>
95+
<Description><![CDATA[RRF with non scoring function 3]]></Description>
96+
<Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), Convert(doc.StringField2.Length, Double)}))]]></Expression>
97+
</Input>
98+
<Output>
99+
<SqlQuery><![CDATA[]]></SqlQuery>
100+
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
101+
</Output>
102+
</Result>
103+
<Result>
104+
<Input>
105+
<Description><![CDATA[RRF with non scoring function 4]]></Description>
106+
<Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), Convert(doc.ArrayField.Count(), Double)}))]]></Expression>
107+
</Input>
108+
<Output>
109+
<SqlQuery><![CDATA[]]></SqlQuery>
110+
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
111+
</Output>
112+
</Result>
113+
<Result>
114+
<Input>
115+
<Description><![CDATA[RRF with RRF]]></Description>
116+
<Expression><![CDATA[query.OrderByRank(doc => RRF(new [] {doc.StringField.FullTextScore(new [] {"test1"}), RRF(new [] {doc.StringField2.FullTextScore(new [] {"test1", "test2", "test3"}), doc.StringField.FullTextScore(new [] {"test1", "test2"})})}))]]></Expression>
117+
</Input>
118+
<Output>
119+
<SqlQuery><![CDATA[]]></SqlQuery>
120+
<ErrorMessage><![CDATA[Query expression is invalid, method call RRF is not allowed at this context. Allowed methods are FullTextScore.]]></ErrorMessage>
121+
</Output>
122+
</Result>
73123
</Results>

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Contracts/DotNetSDKAPI.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6344,6 +6344,18 @@
63446344
],
63456345
"MethodInfo": "Boolean RegexMatch(System.Object, System.String);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
63466346
},
6347+
"Double FullTextScore[TSource](TSource, System.String[])[System.Runtime.CompilerServices.ExtensionAttribute()]": {
6348+
"Type": "Method",
6349+
"Attributes": [
6350+
"ExtensionAttribute"
6351+
],
6352+
"MethodInfo": "Double FullTextScore[TSource](TSource, System.String[]);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:True;IsConstructor:False;IsFinal:False;"
6353+
},
6354+
"Double RRF(Double[])": {
6355+
"Type": "Method",
6356+
"Attributes": [],
6357+
"MethodInfo": "Double RRF(Double[]);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:False;IsConstructor:False;IsFinal:False;"
6358+
},
63476359
"Int32 DocumentId(System.Object)[System.Runtime.CompilerServices.ExtensionAttribute()]": {
63486360
"Type": "Method",
63496361
"Attributes": [
@@ -6372,24 +6384,12 @@
63726384
],
63736385
"MethodInfo": "Microsoft.Azure.Cosmos.QueryDefinition ToQueryDefinition[T](System.Linq.IQueryable`1[T]);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:True;IsConstructor:False;IsFinal:False;"
63746386
},
6375-
"System.Func`2[TSource,System.Object] FullTextScore[TSource](TSource, System.String[])[System.Runtime.CompilerServices.ExtensionAttribute()]": {
6376-
"Type": "Method",
6377-
"Attributes": [
6378-
"ExtensionAttribute"
6379-
],
6380-
"MethodInfo": "System.Func`2[TSource,System.Object] FullTextScore[TSource](TSource, System.String[]);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:True;IsConstructor:False;IsFinal:False;"
6381-
},
6382-
"System.Func`2[TSource,System.Object] RRF[TSource](System.Func`2[TSource,System.Object][])": {
6383-
"Type": "Method",
6384-
"Attributes": [],
6385-
"MethodInfo": "System.Func`2[TSource,System.Object] RRF[TSource](System.Func`2[TSource,System.Object][]);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:True;IsConstructor:False;IsFinal:False;"
6386-
},
6387-
"System.Linq.IOrderedQueryable`1[TSource] OrderByRank[TSource](System.Linq.IQueryable`1[TSource], System.Linq.Expressions.Expression`1[System.Func`2[TSource,System.Object]])[System.Runtime.CompilerServices.ExtensionAttribute()]": {
6387+
"System.Linq.IOrderedQueryable`1[TSource] OrderByRank[TSource,TKey](System.Linq.IQueryable`1[TSource], System.Linq.Expressions.Expression`1[System.Func`2[TSource,TKey]])[System.Runtime.CompilerServices.ExtensionAttribute()]": {
63886388
"Type": "Method",
63896389
"Attributes": [
63906390
"ExtensionAttribute"
63916391
],
6392-
"MethodInfo": "System.Linq.IOrderedQueryable`1[TSource] OrderByRank[TSource](System.Linq.IQueryable`1[TSource], System.Linq.Expressions.Expression`1[System.Func`2[TSource,System.Object]]);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:True;IsConstructor:False;IsFinal:False;"
6392+
"MethodInfo": "System.Linq.IOrderedQueryable`1[TSource] OrderByRank[TSource,TKey](System.Linq.IQueryable`1[TSource], System.Linq.Expressions.Expression`1[System.Func`2[TSource,TKey]]);IsAbstract:False;IsStatic:True;IsVirtual:False;IsGenericMethod:True;IsConstructor:False;IsFinal:False;"
63936393
},
63946394
"System.Threading.Tasks.Task`1[Microsoft.Azure.Cosmos.Response`1[System.Decimal]] AverageAsync(System.Linq.IQueryable`1[System.Decimal], System.Threading.CancellationToken)[System.Runtime.CompilerServices.ExtensionAttribute()]": {
63956395
"Type": "Method",

0 commit comments

Comments
 (0)