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

Unable to Call DOCUMENTID(root) from LINQ provider #2607

Closed
Matthewsre opened this issue Jul 12, 2021 · 2 comments · Fixed by #4489
Closed

Unable to Call DOCUMENTID(root) from LINQ provider #2607

Matthewsre opened this issue Jul 12, 2021 · 2 comments · Fixed by #4489
Assignees
Labels
feature-request New feature or request LINQ QUERY

Comments

@Matthewsre
Copy link

Matthewsre commented Jul 12, 2021

Unable to select the results from DOCUMENTID()

This is a valid SQL query that can be run against CosmosDB:

SELECT DOCUMENTID(c) FROM c

When trying to match up the projection with an example like this it fails as unsupported:

var projection = query.Select(r => DOCUMENTID(r));

This is mapped up and used in the tests:

But is failing as not implemented:

   at Microsoft.Azure.Cosmos.Linq.BuiltinFunctionVisitor.VisitBuiltinFunctionCall(MethodCallExpression methodCallExpression, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitNonSubqueryScalarExpression(Expression expression, ReadOnlyCollection`1 parameters, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitScalarExpression(Expression expression, ReadOnlyCollection`1 parameters, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.CreateInitializers(ReadOnlyCollection`1 arguments, ReadOnlyCollection`1 members, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitNew(NewExpression inputExpression, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitNonSubqueryScalarExpression(Expression expression, ReadOnlyCollection`1 parameters, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitScalarExpression(Expression expression, ReadOnlyCollection`1 parameters, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitSelect(ReadOnlyCollection`1 arguments, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitMethodCall(MethodCallExpression inputExpression, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.Translate(Expression inputExpression, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.TranslateQuery(Expression inputExpression, IDictionary`2 parameters, CosmosLinqSerializerOptions linqSerializerOptions)
   at Microsoft.Azure.Cosmos.Linq.SqlTranslator.TranslateQuery(Expression inputExpression, CosmosLinqSerializerOptions linqSerializerOptions, IDictionary`2 parameters)
   at Microsoft.Azure.Cosmos.Linq.CosmosLinqQuery`1.ToQueryDefinition(IDictionary`2 parameters)
   at Microsoft.Azure.Cosmos.Linq.CosmosLinqExtensions.ToQueryDefinition[T](IQueryable`1 query)

I have also tried this approach with no success:

var projection = query.Select(r => r.DocumentId());

Here is the result:

   {{
	  "code": "",
	  "message": "Method 'DocumentId' is not supported., Windows/10.0.19043 cosmos-netstandard-sdk/3.17.1"
	}}
   
   Method 'DocumentId' is not supported., Windows/10.0.19043 cosmos-netstandard-sdk/3.17.1
   
   at Microsoft.Azure.Cosmos.Linq.BuiltinFunctionVisitor.VisitBuiltinFunctionCall(MethodCallExpression methodCallExpression, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitNonSubqueryScalarExpression(Expression expression, ReadOnlyCollection`1 parameters, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitScalarExpression(Expression expression, ReadOnlyCollection`1 parameters, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitSelect(ReadOnlyCollection`1 arguments, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.VisitMethodCall(MethodCallExpression inputExpression, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.Translate(Expression inputExpression, TranslationContext context)
   at Microsoft.Azure.Cosmos.Linq.ExpressionToSql.TranslateQuery(Expression inputExpression, IDictionary`2 parameters, CosmosLinqSerializerOptions linqSerializerOptions)
   at Microsoft.Azure.Cosmos.Linq.SqlTranslator.TranslateQuery(Expression inputExpression, CosmosLinqSerializerOptions linqSerializerOptions, IDictionary`2 parameters)
   at Microsoft.Azure.Cosmos.Linq.CosmosLinqQuery`1.ToQueryDefinition(IDictionary`2 parameters)
   at Microsoft.Azure.Cosmos.Linq.CosmosLinqExtensions.ToQueryDefinition[T](IQueryable`1 query)
@j82w
Copy link
Contributor

j82w commented Jul 12, 2021

I'm not a LINQ expert, but from what I can tell this isn't supported in LINQ currently. There is no extension methods exposing the functionality. I couldn't find any tests actually validating the DOCUMENTID being used in a e2e linq test. The test you pointed out is only unit testing a specific part of the LINQ logic.

@j82w j82w added feature-request New feature or request and removed needs-investigation labels Jul 12, 2021
@j82w
Copy link
Contributor

j82w commented Jul 12, 2021

@timsander1 please correct me if I'm wrong and this is a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request LINQ QUERY
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants