Esempio n. 1
0
        public async Task <TryCatch <PartitionedQueryExecutionInfo> > TryGetQueryPlanAsync(
            SqlQuerySpec sqlQuerySpec,
            Documents.ResourceType resourceType,
            PartitionKeyDefinition partitionKeyDefinition,
            QueryFeatures supportedQueryFeatures,
            bool hasLogicalPartitionKey,
            bool useSystemPrefix,
            CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            if (sqlQuerySpec == null)
            {
                throw new ArgumentNullException($"{nameof(sqlQuerySpec)}");
            }

            if (partitionKeyDefinition == null)
            {
                throw new ArgumentNullException($"{nameof(partitionKeyDefinition)}");
            }

            TryCatch <PartitionedQueryExecutionInfo> tryGetQueryInfo = await this.TryGetQueryInfoAsync(
                sqlQuerySpec,
                resourceType,
                partitionKeyDefinition,
                hasLogicalPartitionKey,
                useSystemPrefix,
                cancellationToken);

            if (!tryGetQueryInfo.Succeeded)
            {
                return(tryGetQueryInfo);
            }

            if (QueryPlanExceptionFactory.TryGetUnsupportedException(
                    tryGetQueryInfo.Result.QueryInfo,
                    supportedQueryFeatures,
                    out Exception queryPlanHandlerException))
            {
                return(TryCatch <PartitionedQueryExecutionInfo> .FromException(queryPlanHandlerException));
            }

            return(tryGetQueryInfo);
        }
Esempio n. 2
0
            public static void ThrowIfNotSupported(
                QueryInfo queryInfo,
                QueryFeatures supportedQueryFeatures)
            {
                Lazy <List <Exception> > exceptions = new Lazy <List <Exception> >(() => { return(new List <Exception>()); });

                QueryPlanExceptionFactory.AddExceptionsForAggregateQueries(
                    queryInfo,
                    supportedQueryFeatures,
                    exceptions);

                QueryPlanExceptionFactory.AddExceptionsForDistinctQueries(
                    queryInfo,
                    supportedQueryFeatures,
                    exceptions);

                QueryPlanExceptionFactory.AddExceptionsForTopQueries(
                    queryInfo,
                    supportedQueryFeatures,
                    exceptions);

                QueryPlanExceptionFactory.AddExceptionsForOrderByQueries(
                    queryInfo,
                    supportedQueryFeatures,
                    exceptions);

                QueryPlanExceptionFactory.AddExceptionsForOffsetLimitQueries(
                    queryInfo,
                    supportedQueryFeatures,
                    exceptions);

                if (exceptions.IsValueCreated)
                {
                    throw new QueryPlanHandlerException(exceptions.Value);
                }
            }