Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query: Adds LINQ extension method for ORDER BY RANK, FullTextScore and RRF #4993

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

leminh98
Copy link
Contributor

@leminh98 leminh98 commented Feb 3, 2025

Pull Request Template

Description

This PR adds extension methods for ORDER BY RANK, FullTextScore, and RRF to the LINQ extension method support.

Type of change

Please delete options that are not relevant.

  • [] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [] This change requires a documentation update

Closing issues

To automatically close an issue: closes #IssueNumber

@leminh98 leminh98 added the auto-merge Enables automation to merge PRs label Feb 3, 2025
/// </example>
public static Func<TSource, object> FullTextScore<TSource>(this TSource obj, string[] terms)
{
throw new NotImplementedException(ClientResources.TypeCheckExtensionFunctionsNotImplemented); //Todo: change this to LINQNotImplemented once the FTContains PR is checked in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//Todo: change this to LINQNotImplemented once the FTContains PR is checked in

Leaving a comment as a friendly reminder.

/// </example>
public static Func<TSource, object> RRF<TSource>(this object obj, params Func<TSource, object>[] scoringFunctions)
{
throw new NotImplementedException(ClientResources.TypeCheckExtensionFunctionsNotImplemented); //Todo: change this to LINQNotImplemented once the FTContains PR is checked in
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//Todo: change this to LINQNotImplemented once the FTContains PR is checked in

Same.

@@ -1159,8 +1159,9 @@ private static Collection VisitMethodCall(MethodCallExpression inputExpression,
context.PushMethod(inputExpression);

Type declaringType = inputExpression.Method.DeclaringType;
if ((declaringType != typeof(Queryable) && declaringType != typeof(Enumerable))
|| !inputExpression.Method.IsStatic)
if ((declaringType != typeof(Queryable) && declaringType != typeof(Enumerable) /*LINQ Methods*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

declaringType != typeof(Enumerable)

Consider linebreak before.

if ((declaringType != typeof(Queryable) && declaringType != typeof(Enumerable))
|| !inputExpression.Method.IsStatic)
if ((declaringType != typeof(Queryable) && declaringType != typeof(Enumerable) /*LINQ Methods*/
&& declaringType != typeof(CosmosLinqExtensions) /*OrderByRank*/)
Copy link
Contributor

@adityasa adityasa Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OrderByRank

Isn't it better to check specific method name?

#else
internal
#endif
sealed class SqlOrderByRankClause : SqlObject
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SqlOrderByRankClause

Instead of defining a new type, can we reuse SqlOrderByClause and add a boolean property similar to backend DOM?

Copy link
Contributor

@adityasa adityasa Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this class needs to stay (let's discuss if that's the case since it's not desirable to introduce another type for this small a change in the model), there should be a common base class between SqlOrderByClause and SqlOrderByRankClause.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to have parity with the BE. Let me check how the DOM is there and i will reflect it in this change

@@ -59,14 +59,15 @@ public ParameterExpression Alias

private SqlSelectClause selectClause;
private SqlWhereClause whereClause;
private SqlOrderByClause orderByClause;
private SqlOrderByClause orderByClause;
private SqlOrderByRankClause orderbyRankClause;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that these are mutually exclusive, we should have a single type SqlOrderByClause representing both.

//protected override SqlScalarExpression VisitExplicit(MethodCallExpression methodCallExpression, TranslationContext context)
//{
// return null;
//}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove if not needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge Enables automation to merge PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants