Azure / azure-cosmos-table-dotnet

.NET SDK for Azure Cosmos Table API
14 stars 6 forks source link

Query with filter returns StorageException #40

Closed trevonmckay closed 4 years ago

trevonmckay commented 4 years ago

SDK version: 1.0.6

var continuationToken = new TableContinuationToken();
var tableQuery = new TableQuery<EmployeeTimeSummary>()
                .Where(q.Filter)
                .Select(q.Select)
                .Take(q.Take);
var querySegment = await table.ExecuteQuerySegmentedAsync(tableQuery, continuationToken);

Consistent issue Environment: Visual Studio 2019 - Windows 10 (x64) Stack Trace

Microsoft.Azure.Cosmos.Table.StorageException: Method 'Visit' in type 'QueryTokenVisitor' from assembly 'Microsoft.Azure.Cosmos.Table, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. ---> System.TypeLoadException: Method 'Visit' in type 'QueryTokenVisitor' from assembly 'Microsoft.Azure.Cosmos.Table, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. at Microsoft.Azure.Cosmos.Tables.SharedFiles.ODataFilterTranslator.ToSql(String odataV4FilterString, Boolean isTableQuery, Boolean enableTimestampQuery) at Microsoft.Azure.Cosmos.Tables.SharedFiles.QueryTranslator.GetSqlQuery(String selectList, String odataV4FilterString, Boolean isLinqExpression, Boolean isTableQuery, IList1 orderByItems, String tombstoneKey, Boolean enableTimestampQuery) at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionQueryHelper.QueryDocumentsAsync[TResult](Nullable1 maxItemCount, String filterString, IList1 selectColumns, TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver1 resolver, TableRequestOptions requestOptions, OperationContext operationContext, Boolean isLinqExpression, IList1 orderByItems, String tombstoneKey) at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionExecutor.<>c__DisplayClass24_02.<b0>d.MoveNext() --- End of inner exception stack trace --- at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionExecutor.<>cDisplayClass24_02.<<ExecuteQuerySegmentedInternalAsync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionRetryPolicy.ExecuteUnderRetryPolicy[TResult](Func1 executionMethod, CancellationToken cancellationToken, OperationContext operationContext, TableRequestOptions requestOptions) at DGS.EnterpriseAPI.WebApi.Controllers.TimeSummaryController.GetAsync(ODataQueryCollectionOptions q) in C:\Users\trevo\source\repos\dgs\DGS.EnterpriseAPI\src\DGS.EnterpriseAPI.WebApi\Controllers\TimeSummaryController.cs:line 72 at lambda_method(Closure , Object ) at Microsoft.Extensions.Internal.ObjectMethodExecutorAwaitable.Awaiter.GetResult() at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.AwaitableObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gLogged|12_1(ControllerActionInvoker invoker) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.gAwaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Logged|17_1(ResourceInvoker invoker) at Microsoft.AspNetCore.Routing.EndpointMiddleware.gAwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) Request Information RequestID: RequestCharge:0 RequestDate: StatusMessage:Server encountered an internal error.Please try again after some time. ErrorCode: ErrorMessage:Method 'Visit' in type 'QueryTokenVisitor' from assembly 'Microsoft.Azure.Cosmos.Table, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

Badabum commented 4 years ago

Same issue with Microsoft.Azure.Cosmos.Table v1.0.7

iant-ee commented 4 years ago

I am also seeing this when I use Microsoft.OData.Core (and related packages Microsoft.OData.Edm and Microsoft.Spatial) version 7.6.1 and above. Using 7.6.0 I do not have this problem.

Badabum commented 4 years ago

@iant-ee that's right, in my case it was Microsoft.OData.Core 7.6.4

iant-ee commented 4 years ago

@Badabum Are you saying that it was working for you with 7.6.3? Or just that you first saw it when upgrading to 7.6.4 (from some older version, presumably earlier than 7.6.1)? I'm currently looking at the changelog for 7.6.1 to see I can spot the change the caused this.

Badabum commented 4 years ago

It was 7.6.0 -> 7.6.4 update

iant-ee commented 4 years ago

Looking at the changes in 7.6.1: https://github.com/OData/odata.net/compare/7.6.0...7.6.1

The breaking change appears to be https://github.com/OData/odata.net/pull/1488 & https://github.com/OData/odata.net/pull/1532 Support nested query options ($filter, $orderby, $top, $skip, $count, $search, $select, $compute) in $select clause.

sakash279 commented 4 years ago

@trevonmckay We've updated the OData dependency versions to 7.6.4 in Tables v1.0.8 and made some fixes around this issue. Please give it a try, and re-open this issue with any repro steps if you still see the problem.

pw-nable commented 3 years ago

@sakash279 - after upgrading oData from 7.6.4 to 7.9 I started getting this error again: Microsoft.Azure.Cosmos.Table.StorageException: Method 'Visit' in type 'QueryTokenVisitor' from assembly 'Microsoft.Azure.Cosmos.Table, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.

iant-ee commented 2 years ago

This has not been fixed. I assume there must be a particular other dependency or similar we've got that's causing the problem, because this makes the project unusable and there aren't loads of people shouting about it.

Our code:

var cloudTable = GetTable(); var query = new TableQuery<T>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, partitionKey)); return cloudTable.ExecuteQuery(query).ToList();

Which throws:

Error : Method 'Visit' in type 'QueryTokenVisitor' from assembly 'Microsoft.Azure.Cosmos.Table, Version=1.0.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation. Trace: at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionExecutor.<>cDisplayClass24_02.<<ExecuteQuerySegmentedInternalAsync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionRetryPolicy.<ExecuteUnderRetryPolicy>d__21.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Azure.Cosmos.Table.Extensions.TableExtensionExecutor.ExecuteQuerySegmented[TResult,TInput](TableQuery1 query, TableContinuationToken token, CloudTableClient client, CloudTable table, EntityResolver1 resolver, TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.Azure.Cosmos.Table.TableQuery1.ExecuteQuerySegmentedInternal(TableContinuationToken token, CloudTableClient client, CloudTable table, TableRequestOptions requestOptions, OperationContext operationContext) at Microsoft.Azure.Cosmos.Table.TableQuery1.<>c__DisplayClass42_0.b0(TableContinuationToken continuationToken) at Microsoft.Azure.Cosmos.Table.CommonUtility.d__21.MoveNext() at System.Collections.Generic.List1..ctor(IEnumerable1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source)

I'll investigate further tomorrow.

See also https://github.com/OData/AspNetCoreOData/issues/263

sakash279 commented 2 years ago

@iant-ee - Yes, please update with your findings here. It must be a specific dependency in your projects that's causing this conflict I'd guess.

In addition, please consider evaluating this client library for your needs going forward. https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/tables/Azure.Data.Tables/README.md

It'll require a rewrite given interfaces have changed. This will be the future direction of the Tables SDK, and the code is also open sourced in github.

iant-ee commented 2 years ago

@sakash279 Thanks for your advice. We're not doing anything particularly complicated with Azure Tables, so I was able to migrate to Azure.Data.Tables. The migration took me about 2 - 3 hours, which is less than the time I've spent debugging the old version.

I don't see this error after the migration to Azure.Data.Tables.