Skip to content

Commit 50e29c8

Browse files
author
Minh Le
committed
Update error message.
1 parent 2a9edb1 commit 50e29c8

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

Microsoft.Azure.Cosmos/src/Linq/BuiltinFunctions/OtherBuiltinSystemFunctions.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,20 @@ protected override SqlScalarExpression VisitImplicit(MethodCallExpression method
3838
{
3939
if (!(argument is MethodCallExpression functionCallExpression))
4040
{
41-
throw new DocumentQueryException(string.Format(CultureInfo.CurrentCulture, ClientResources.ExpressionTypeIsNotSupported, argument.Type));
41+
throw new ArgumentException(
42+
string.Format(
43+
CultureInfo.CurrentCulture,
44+
"Expressions of type {0} is not supported as an argument to CosmosLinqExtensions.RRF. Supported expressions are method calls to {1}.",
45+
argument.Type,
46+
nameof(CosmosLinqExtensions.FullTextScore)));
4247
}
4348

4449
if (functionCallExpression.Method.Name != nameof(CosmosLinqExtensions.FullTextScore))
4550
{
4651
throw new ArgumentException(
4752
string.Format(
4853
CultureInfo.CurrentCulture,
49-
ClientResources.BadQuery_InvalidMethodCall,
54+
"Method {0} is not supported as an argument to CosmosLinqExtensions.RRF. Supported methods are {1}.",
5055
functionCallExpression.Method.Name,
5156
nameof(CosmosLinqExtensions.FullTextScore)));
5257
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ WHERE (RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["Stri
7777
</Input>
7878
<Output>
7979
<SqlQuery><![CDATA[]]></SqlQuery>
80-
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
80+
<ErrorMessage><![CDATA[Expressions of type System.Double is not supported as an argument to CosmosLinqExtensions.RRF. Supported expressions are method calls to FullTextScore.]]></ErrorMessage>
8181
</Output>
8282
</Result>
8383
<Result>
@@ -87,7 +87,7 @@ WHERE (RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["Stri
8787
</Input>
8888
<Output>
8989
<SqlQuery><![CDATA[]]></SqlQuery>
90-
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
90+
<ErrorMessage><![CDATA[Expressions of type System.Double is not supported as an argument to CosmosLinqExtensions.RRF. Supported expressions are method calls to FullTextScore.]]></ErrorMessage>
9191
</Output>
9292
</Result>
9393
<Result>
@@ -97,7 +97,7 @@ WHERE (RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["Stri
9797
</Input>
9898
<Output>
9999
<SqlQuery><![CDATA[]]></SqlQuery>
100-
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
100+
<ErrorMessage><![CDATA[Expressions of type System.Double is not supported as an argument to CosmosLinqExtensions.RRF. Supported expressions are method calls to FullTextScore.]]></ErrorMessage>
101101
</Output>
102102
</Result>
103103
<Result>
@@ -107,7 +107,7 @@ WHERE (RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["Stri
107107
</Input>
108108
<Output>
109109
<SqlQuery><![CDATA[]]></SqlQuery>
110-
<ErrorMessage><![CDATA[Expression with NodeType 'System.Double' is not supported.]]></ErrorMessage>
110+
<ErrorMessage><![CDATA[Expressions of type System.Double is not supported as an argument to CosmosLinqExtensions.RRF. Supported expressions are method calls to FullTextScore.]]></ErrorMessage>
111111
</Output>
112112
</Result>
113113
<Result>
@@ -117,7 +117,7 @@ WHERE (RRF(FullTextScore(root["StringField"], "test1"), FullTextScore(root["Stri
117117
</Input>
118118
<Output>
119119
<SqlQuery><![CDATA[]]></SqlQuery>
120-
<ErrorMessage><![CDATA[Query expression is invalid, method call RRF is not allowed at this context. Allowed methods are FullTextScore.]]></ErrorMessage>
120+
<ErrorMessage><![CDATA[Method RRF is not supported as an argument to CosmosLinqExtensions.RRF. Supported methods are FullTextScore.]]></ErrorMessage>
121121
</Output>
122122
</Result>
123123
</Results>

0 commit comments

Comments
 (0)