Converts extractionFn to a QueryGranularity, if possible. This is the inverse of
{@link #fromQueryGranularity(Granularity)}.

@param extractionFn function

@return query granularity, or null if extractionFn cannot be translated
350624
public static Granularity toQueryGranularity(final ExtractionFn extractionFn)
  {
    if (extractionFn instanceof TimeFormatExtractionFn) {
      final TimeFormatExtractionFn fn = (TimeFormatExtractionFn) extractionFn;
      if (fn.getFormat() == null && fn.getTimeZone() == null && fn.getLocale() == null && fn.isAsMillis()) {
        return fn.getGranularity();
      }
    }

    return null;
  }
89088
@SuppressWarnings("unchecked")
    public static <T> Expression<T> extract(Expression<T> expr) {
        if (expr != null) {
            final Class<?> clazz = expr.getClass();
            if (clazz == PathImpl.class || clazz == PredicateOperation.class || clazz == ConstantImpl.class) {
                return expr;
            } else {
                return (Expression<T>) expr.accept(ExtractorVisitor.DEFAULT, null);
            }
        } else {
            return null;
        }
    }
929887
public static ExtractFromRow extractorWith( final Collection<ExtractFromRow> extractors ) {
        final int len = extractors.size();
        assert len > 0;
        // There are a few cases where specific row extractor implementations would be better ...
        if (len == 1) {
            return extractors.iterator().next();
        }
        if (len == 2) {
            Iterator<ExtractFromRow> iter = extractors.iterator();
            ExtractFromRow first = iter.next();
            ExtractFromRow second = iter.next();
            return extractorWith(first, second);
        }
        if (len == 3) {
            Iterator<ExtractFromRow> iter = extractors.iterator();
            ExtractFromRow first = iter.next();
            ExtractFromRow second = iter.next();
            ExtractFromRow third = iter.next();
            return extractorWith(first, second, third);
        }
        if (len == 4) {
            Iterator<ExtractFromRow> iter = extractors.iterator();
            ExtractFromRow first = iter.next();
            ExtractFromRow second = iter.next();
            ExtractFromRow third = iter.next();
            ExtractFromRow fourth = iter.next();
            return extractorWith(first, second, third, fourth);
        }
        // Okay, there are at least 4 extractors, so we need to return a general-case row extractor ...
        Collection<TypeFactory<?>> types = new ArrayList<TypeFactory<?>>();
        final ExtractFromRow[] extracts = new ExtractFromRow[len];
        int i = 0;
        for (ExtractFromRow extractor : extractors) {
            extracts[i++] = extractor;
            types.add(extractor.getType());
        }
        final TypeFactory<?> type = Tuples.typeFactory(types);
        return new ExtractFromRow() {
            @Override
            public TypeFactory<?> getType() {
                return type;
            }

            @Override
            public Object getValueInRow( RowAccessor row ) {
                Object[] values = new Object[len];
                for (int i = 0; i != len; ++i) {
                    values[i] = extracts[i].getValueInRow(row);
                }
                return Tuples.tuple(values);
            }
        };
    }
185522
public static <F> AbstractJointConverter<F> of(final SerializableFunction<? super F, String> to,
			                                    final SerializableFunction<String, ? extends F> from) {
		return new AbstractJointConverter<F>() {
			@Override
			public String convertToString(F value, Locale locale) {
				return to.apply(value);
			}
			
			@Override
			public F convertToObject(String value, Locale locale) throws ConversionException {
				return from.apply(value);
			}
		};
	}
27121
private <T> QueryRequest<T> query(String fql, JavaType type) {
		this.checkForBatchExecution();
		
		if (this.multiqueryRequest == null) {
			this.multiqueryRequest = new MultiqueryRequest(mapper, this.createUnmappedChain());
			this.graphRequests.add(this.multiqueryRequest);
		}
		
		// There is a circular reference between the extractor and request, so construction of the chain
		// is a little complicated
		QueryNodeExtractor extractor = new QueryNodeExtractor(this.multiqueryRequest);
		
		String name = "__q" + this.generatedQueryNameIndex++;
		QueryRequest<T> q =
			new QueryRequest<T>(fql, name,
				new MapperWrapper<T>(type, this.mapper,
						extractor));
		
		extractor.setRequest(q);
		
		this.multiqueryRequest.addQuery(q);
		return q;
	}
620878
private ImmutableMultimap<RelationDefinition, ExtensionalDataNode> extractDataNodeMap(IntermediateQuery query,
                                                                                          InnerJoinNode joinNode) {
        return query.getChildren(joinNode).stream()
                .filter(c -> c instanceof ExtensionalDataNode)
                .map(c -> (ExtensionalDataNode) c)
                .map(c -> Maps.immutableEntry(c.getProjectionAtom().getPredicate().getRelationDefinition(), c))
                .collect(ImmutableCollectors.toMultimap());
    }
689241
static SQLTransform getNetTransform(TypeName typeName) {
		if (URL.class.getName().equals(typeName.toString())) {
			return new UrlSQLTransform();
		}

		return null;
	}
1047217
@VisibleForTesting
    public static ParametricAggregation parseFunctionDefinitionWithTypesConstraint(Class<?> clazz, TypeSignature returnType, List<TypeSignature> argumentTypes)
    {
        requireNonNull(returnType, "returnType is null");
        requireNonNull(argumentTypes, "argumentTypes is null");
        for (ParametricAggregation aggregation : parseFunctionDefinitions(clazz)) {
            if (aggregation.getSignature().getReturnType().equals(returnType) &&
                    aggregation.getSignature().getArgumentTypes().equals(argumentTypes)) {
                return aggregation;
            }
        }
        throw new IllegalArgumentException(String.format("No method with return type %s and arguments %s", returnType, argumentTypes));
    }
542420
public static <R> FuncN<R> fromFunc(final Func0<? extends R> f) {
        return new FuncN<R>() {

            @Override
            public R call(Object... args) {
                if (args.length != 0) {
                    throw new RuntimeException("Func0 expecting 0 arguments.");
                }
                return f.call();
            }

        };
    }
403336
private static Map<String, Collection<String>> extractQueryMap(final String queryString) {
        final Map<String, Collection<String>> map = new HashMap<>();

        for (final String nvp : queryString.split("&")) {
            final String[] pair = nvp.split("=");
            map.computeIfAbsent(pair[0], k -> {
                List<String> list = new LinkedList<>();
                list.add(pair[1]);
                return list;
            });
        }

        return map;
    }
902312
public static Aggregation translateAggregateCall(
      final PlannerContext plannerContext,
      final DruidQuerySignature querySignature,
      final RexBuilder rexBuilder,
      final Project project,
      final List<Aggregation> existingAggregations,
      final String name,
      final AggregateCall call,
      final boolean finalizeAggregations
  )
  {
    final DimFilter filter;

    if (call.filterArg >= 0) {
      // AGG(xxx) FILTER(WHERE yyy)
      if (project == null) {
        // We need some kind of projection to support filtered aggregations.
        return null;
      }

      final RexNode expression = project.getChildExps().get(call.filterArg);
      final DimFilter nonOptimizedFilter = Expressions.toFilter(plannerContext, querySignature, expression);
      if (nonOptimizedFilter == null) {
        return null;
      } else {
        filter = Filtration.create(nonOptimizedFilter).optimizeFilterOnly(querySignature).getDimFilter();
      }
    } else {
      filter = null;
    }

    final SqlAggregator sqlAggregator = plannerContext.getOperatorTable()
                                                      .lookupAggregator(call.getAggregation());

    if (sqlAggregator == null) {
      return null;
    }

    // Compute existingAggregations for SqlAggregator impls that want it.
    final List<Aggregation> existingAggregationsWithSameFilter = new ArrayList<>();
    for (Aggregation existingAggregation : existingAggregations) {
      if (filter == null) {
        final boolean doesMatch = existingAggregation.getAggregatorFactories().stream().noneMatch(
            factory -> factory instanceof FilteredAggregatorFactory
        );

        if (doesMatch) {
          existingAggregationsWithSameFilter.add(existingAggregation);
        }
      } else {
        final boolean doesMatch = existingAggregation.getAggregatorFactories().stream().allMatch(
            factory -> factory instanceof FilteredAggregatorFactory &&
                       ((FilteredAggregatorFactory) factory).getFilter().equals(filter)
        );

        if (doesMatch) {
          existingAggregationsWithSameFilter.add(
              Aggregation.create(
                  existingAggregation.getVirtualColumns(),
                  existingAggregation.getAggregatorFactories().stream()
                                     .map(factory -> ((FilteredAggregatorFactory) factory).getAggregator())
                                     .collect(Collectors.toList()),
                  existingAggregation.getPostAggregator()
              )
          );
        }
      }
    }

    final Aggregation retVal = sqlAggregator.toDruidAggregation(
        plannerContext,
        querySignature,
        rexBuilder,
        name, call, project, existingAggregationsWithSameFilter,
        finalizeAggregations
    );

    if (retVal == null) {
      return null;
    } else {
      // Check if this refers to the existingAggregationsWithSameFilter. If so, no need to apply the filter.
      if (isUsingExistingAggregation(retVal, existingAggregationsWithSameFilter)) {
        return retVal;
      } else {
        return retVal.filter(querySignature, filter);
      }
    }
  }
438379
public function alterQueryForTranslation(
        QueryObjectModelFactoryInterface $qomf,
        SourceInterface &$selector,
        ConstraintInterface &$constraint = null,
        $alias,
        $locale
    ) {
        $childAlias = "_{$locale}_{$alias}";

        $selector = $qomf->join(
            $selector,
            $qomf->selector($childAlias, 'nt:base'),
            QueryObjectModelConstantsInterface::JCR_JOIN_TYPE_RIGHT_OUTER,
            $qomf->childNodeJoinCondition($childAlias, $alias)
        );

        $languageConstraint = $qomf->comparison(
            $qomf->nodeName($childAlias),
            QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
            $qomf->literal(Translation::LOCALE_NAMESPACE.":$locale")
        );

        if ($constraint) {
            $constraint = $qomf->andConstraint(
                $constraint,
                $languageConstraint
            );
        } else {
            $constraint = $languageConstraint;
        }
    }
1070420
public String getAliasNameIfRelevant(GroovyExpression expr) {
        if(!(expr instanceof FunctionCallExpression)) {
            return null;
        }
        FunctionCallExpression fc = (FunctionCallExpression)expr;
        if(! fc.getFunctionName().equals(AS_METHOD)) {
            return null;
        }
       LiteralExpression aliasName =  (LiteralExpression)fc.getArguments().get(0);
       return aliasName.getValue().toString();

    }
314796
def _extract(self, resource):
    """"""
    if isinstance(resource, six.string_types):
      resource = resource_lib.Resource(path=resource)
    path = resource.path
    extract_method = resource.extract_method
    if extract_method == resource_lib.ExtractMethod.NO_EXTRACT:
      logging.info('Skipping extraction for %s (method=NO_EXTRACT).', path)
      return promise.Promise.resolve(path)
    method_name = resource_lib.ExtractMethod(extract_method).name
    extract_path = os.path.join(self._extract_dir,
                                '%s.%s' % (method_name, os.path.basename(path)))
    if not self._force_extraction and tf.io.gfile.exists(extract_path):
      logging.info('Reusing extraction of %s at %s.', path, extract_path)
      return promise.Promise.resolve(extract_path)
    return self._extractor.extract(path, extract_method, extract_path)
554146
public <T> JDOQuery<T> selectFrom(EntityPath<T> expr) {
        return select(expr).from(expr);
    }
83363
def verify_full_extraction():
    
    path = functions.get_path_from_query_string(request)

    if request.method == 'POST':
        rqtasks.extraction_data_statistics(path)

    with functions.DBContextManager(path) as session:
        extraction = session.query(models.Extraction).first()
        return jsonify(extraction.data_statistics)
212175
public Query<S> query(String filter) throws FetchException {
        synchronized (mStringToQuery) {
            Query<S> query = mStringToQuery.get(filter);
            if (query == null) {
                if (filter == null) {
                    throw new IllegalArgumentException("Query filter must not be null");
                }
                query = query(Filter.filterFor(mType, filter), null);
                mStringToQuery.put(filter, query);
            }
            return query;
        }
    }