/// <summary> /// Used in the compute gateway to support legacy gateways query execution pattern. /// </summary> public async Task <(PartitionedQueryExecutionInfo, bool)> GetQueryInfoAndIfSupportedAsync( QueryFeatures supportedQueryFeatures, SqlQuerySpec sqlQuerySpec, PartitionKeyDefinition partitionKeyDefinition, bool hasLogicalPartitionKey, CancellationToken cancellationToken = default(CancellationToken)) { if (sqlQuerySpec == null) { throw new ArgumentNullException(nameof(sqlQuerySpec)); } if (partitionKeyDefinition == null) { throw new ArgumentNullException(nameof(partitionKeyDefinition)); } cancellationToken.ThrowIfCancellationRequested(); PartitionedQueryExecutionInfo partitionedQueryExecutionInfo = await this.GetQueryInfoAsync( sqlQuerySpec, partitionKeyDefinition, hasLogicalPartitionKey, cancellationToken); QueryFeatures neededQueryFeatures = QueryPlanSupportChecker.GetNeededQueryFeatures( partitionedQueryExecutionInfo.QueryInfo, supportedQueryFeatures); return(partitionedQueryExecutionInfo, neededQueryFeatures == QueryFeatures.None); }
public static bool TryGetUnsupportedException( QueryInfo queryInfo, QueryFeatures supportedQueryFeatures, out Exception queryPlanHandlerException) { QueryFeatures neededQueryFeatures = QueryPlanSupportChecker.GetNeededQueryFeatures( queryInfo, supportedQueryFeatures); if (neededQueryFeatures != QueryFeatures.None) { List <Exception> queryPlanHandlerExceptions = new List <Exception>(); foreach (QueryFeatures queryFeature in QueryPlanExceptionFactory.QueryFeatureList) { if ((neededQueryFeatures & queryFeature) == queryFeature) { Exception unsupportedFeatureException = QueryPlanExceptionFactory.FeatureToUnsupportedException[queryFeature]; queryPlanHandlerExceptions.Add(unsupportedFeatureException); } } queryPlanHandlerException = new QueryPlanHandlerException(queryPlanHandlerExceptions); return(true); } queryPlanHandlerException = default; return(false); }
/// <summary> /// Used in the compute gateway to support legacy gateways query execution pattern. /// </summary> public async Task <TryCatch <(PartitionedQueryExecutionInfo queryPlan, bool supported)> > TryGetQueryInfoAndIfSupportedAsync( QueryFeatures supportedQueryFeatures, SqlQuerySpec sqlQuerySpec, Documents.ResourceType resourceType, PartitionKeyDefinition partitionKeyDefinition, bool hasLogicalPartitionKey, bool useSystemPrefix, CancellationToken cancellationToken = default) { if (sqlQuerySpec == null) { throw new ArgumentNullException(nameof(sqlQuerySpec)); } if (partitionKeyDefinition == null) { throw new ArgumentNullException(nameof(partitionKeyDefinition)); } cancellationToken.ThrowIfCancellationRequested(); TryCatch <PartitionedQueryExecutionInfo> tryGetQueryInfo = await this.TryGetQueryInfoAsync( sqlQuerySpec, resourceType, partitionKeyDefinition, hasLogicalPartitionKey, useSystemPrefix, cancellationToken); if (tryGetQueryInfo.Failed) { return(TryCatch <(PartitionedQueryExecutionInfo, bool)> .FromException(tryGetQueryInfo.Exception)); } QueryFeatures neededQueryFeatures = QueryPlanSupportChecker.GetNeededQueryFeatures( tryGetQueryInfo.Result.QueryInfo, supportedQueryFeatures); return(TryCatch <(PartitionedQueryExecutionInfo, bool)> .FromResult((tryGetQueryInfo.Result, neededQueryFeatures == QueryFeatures.None))); }
public static void ThrowIfNotSupported( QueryInfo queryInfo, QueryFeatures supportedQueryFeatures) { QueryFeatures neededQueryFeatures = QueryPlanSupportChecker.GetNeededQueryFeatures( queryInfo, supportedQueryFeatures); if (neededQueryFeatures != QueryFeatures.None) { List <Exception> queryPlanHandlerExceptions = new List <Exception>(); foreach (QueryFeatures queryFeature in QueryPlanExceptionFactory.QueryFeatureList) { if ((neededQueryFeatures & queryFeature) == queryFeature) { Exception unsupportedFeatureException = QueryPlanExceptionFactory.FeatureToUnsupportedException[queryFeature]; queryPlanHandlerExceptions.Add(unsupportedFeatureException); } } throw new QueryPlanHandlerException(queryPlanHandlerExceptions); } }
/// <summary> /// Used in the compute gateway to support legacy gateways query execution pattern. /// </summary> public async Task <((Exception, PartitionedQueryExecutionInfo), bool)> TryGetQueryInfoAndIfSupportedAsync( QueryFeatures supportedQueryFeatures, SqlQuerySpec sqlQuerySpec, PartitionKeyDefinition partitionKeyDefinition, bool hasLogicalPartitionKey, CancellationToken cancellationToken = default) { if (sqlQuerySpec == null) { throw new ArgumentNullException(nameof(sqlQuerySpec)); } if (partitionKeyDefinition == null) { throw new ArgumentNullException(nameof(partitionKeyDefinition)); } cancellationToken.ThrowIfCancellationRequested(); TryCatch <PartitionedQueryExecutionInfo> tryGetQueryInfo = await this.TryGetQueryInfoAsync( sqlQuerySpec, partitionKeyDefinition, hasLogicalPartitionKey, cancellationToken); if (!tryGetQueryInfo.Succeeded) { // Failed to get QueryInfo, so vacously not supported. return((tryGetQueryInfo.Exception, null), false); } QueryFeatures neededQueryFeatures = QueryPlanSupportChecker.GetNeededQueryFeatures( tryGetQueryInfo.Result.QueryInfo, supportedQueryFeatures); return((null, tryGetQueryInfo.Result), neededQueryFeatures == QueryFeatures.None); }