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

RID missing for cross partition subquery with select clause. #375

Open
simplynaveen20 opened this issue Jun 5, 2019 · 4 comments
Open
Labels
bug Something isn't working needs-investigation QUERY

Comments

@simplynaveen20
Copy link
Member

simplynaveen20 commented Jun 5, 2019

RID missing in the response for cross partition subquery with select clause.
We are getting exception of null RID in OrderByQueryResult while running select subquery clause with orderby using LINQ

Code for repro
################################################
public class ToDoActivity
{
public string id { get; set; }
public int taskNum { get; set; }
public double cost { get; set; }
public string description { get; set; }
public string status { get; set; }
public List children { get; set; }
}

OrderedQueryable linqQueryable = this.Container.CreateItemQuery(allowSynchronousQueryExecution: true);
IQueryable queriableOrderTest = linqQueryable
.Select(f => new { f.id, f.children , SmartChildren = f.children.Where(c => c.taskNum > 42)})
.OrderBy(f => f.id);

List list = queriableOrderTest.ToList();
###############################################
Query getting generated =
"SELECT r0._rid, [{"item": r0["id"]}] AS orderByItems, r0 AS payload
FROM
(SELECT VALUE {"id": root["id"], "children": root["children"], "SmartChildren": v0}
FROM root
JOIN
(SELECT VALUE ARRAY(SELECT VALUE c0
FROM root
JOIN c0 IN root["children"]
WHERE (c0["taskNum"] > 42))
)
AS v0)
AS r0
WHERE ((true) AND IS_DEFINED(r0))
ORDER BY r0["id"] ASC"

Expected behavior
We should able to get the response without exception
Actual behavior
Getting exception when code try to fetch RID in OrderByQueryResult

SDK Version: V3

@j82w j82w added the bug Something isn't working label Jun 6, 2019
@kirankumarkolli
Copy link
Member

Is it anyway related to Azure/azure-cosmos-dotnet-v2#717

@jcocchi jcocchi assigned neildsh and unassigned bchong95 Aug 29, 2023
@jcocchi
Copy link
Contributor

jcocchi commented Aug 29, 2023

@neildsh - this appears to be a duplicate of #3608, can you take a look?

@neildsh
Copy link
Contributor

neildsh commented Sep 8, 2023

@neildsh - this appears to be a duplicate of #3608, can you take a look?

Hi @jcocchi, this is not related to #3608 . This issue is four years old at this point. @simplynaveen20 , can you reproduce in the latest version of the v3 sdk ?

@neildsh neildsh removed their assignment Sep 8, 2023
@cgallimore1
Copy link

cgallimore1 commented Oct 31, 2023

Hi @neildsh, I'm getting the same issue when using a similar query as the one in the original post with v3.36.0 of the sdk.
The request works fine without the OrderBy clause so I'm wondering if the OrderBy is rewriting the subquery to get the _rid as well as the main query based on this comment?

The query I'm using looks something like this (names changed for confidentiality reasons)

public record class Test
{
	public string Id { get; set; }
    public List<string> A { get; set; }
	public List<Test2> B { get; set; }
	public int C { get; set; }
	public int D { get; set; }
}

public record class Test2
{
	public string L { get; set; }
}

container.GetLinqItemQueryable<Test>()
	.Select(t => new Test()
	{
		Id = t.Id,
		A = t.A,
		B = t.B.Select(b => new Test2()
		{
			L = b.L
		}).Where(b => t.A.Contains(b.L)).ToList()
	})
	.OrderByDescending(t => t.C).ThenByDescendng(t => t.D)
	.Take(500);

And the query definition:

SELECT TOP 500 VALUE r1
FROM
	(
		SELECT VALUE {"id": root["id"], "a": root["a"], "b": v0}
		FROM root
		JOIN
		(
			SELECT VALUE ARRAY(
				SELECT VALUE {"l": l0["l"]} FROM root
				JOIN l0 IN root["b"]
				WHERE ARRAY_CONTAINS(root["a"], {"l": l0["l"]}["l"])
			)
		) AS v0
	) AS r1
ORDER BY r1["c"] DESC, r1["d"] DESC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-investigation QUERY
Projects
None yet
Development

No branches or pull requests

8 participants