@Test public void testShowTables() { Set<String> expectedTables = ImmutableSet.copyOf(transform(TpchTable.getTables(), TpchTable::getTableName)); MaterializedResult result = computeActual("SHOW TABLES"); assertTrue(result.getOnlyColumnAsSet().containsAll(expectedTables)); }
@Override public List<Symbol> getOutputSymbols() { ImmutableList.Builder<Symbol> outputSymbolsBuilder = ImmutableList.<Symbol>builder() .addAll(replicateSymbols) .addAll(Iterables.concat(unnestSymbols.values())); ordinalitySymbol.ifPresent(outputSymbolsBuilder::add); return outputSymbolsBuilder.build(); }
@Override public Iterator<T> iterator() { return Iterators.mergeSorted( Iterables.transform(iterables, Iterables.<T>toIterator()), comparator); } };
@Override public PlanNode visitDistinctLimit(DistinctLimitNode node, RewriteContext<Set<Symbol>> context) { Set<Symbol> expectedInputs; if (node.getHashSymbol().isPresent()) { expectedInputs = ImmutableSet.copyOf(concat(node.getDistinctSymbols(), ImmutableList.of(node.getHashSymbol().get()))); } else { expectedInputs = ImmutableSet.copyOf(node.getDistinctSymbols()); } PlanNode source = context.rewrite(node.getSource(), expectedInputs); return new DistinctLimitNode(node.getId(), source, node.getLimit(), node.isPartial(), node.getDistinctSymbols(), node.getHashSymbol()); }
@Override public PhysicalOperation visitIndexSource(IndexSourceNode node, LocalExecutionPlanContext context) checkState(context.getIndexSourceContext().isPresent(), "Must be in an index source context"); IndexSourceContext indexSourceContext = context.getIndexSourceContext().get(); List<Symbol> lookupSymbolSchema = ImmutableList.copyOf(node.getLookupSymbols()); ImmutableList.Builder<Integer> remappedProbeKeyChannelsBuilder = ImmutableList.builder(); ImmutableList.Builder<Set<Integer>> overlappingFieldSetsBuilder = ImmutableList.builder(); for (Symbol lookupSymbol : lookupSymbolSchema) { Set<Integer> potentialProbeInputs = indexLookupToProbeInput.get(lookupSymbol); checkState(!potentialProbeInputs.isEmpty(), "Must have at least one source from the probe input"); if (potentialProbeInputs.size() > 1) { overlappingFieldSetsBuilder.add(potentialProbeInputs.stream().collect(toImmutableSet())); remappedProbeKeyChannelsBuilder.add(Iterables.getFirst(potentialProbeInputs, null)); List<Set<Integer>> overlappingFieldSets = overlappingFieldSetsBuilder.build(); List<Integer> remappedProbeKeyChannels = remappedProbeKeyChannelsBuilder.build(); Function<RecordSet, RecordSet> probeKeyNormalizer = recordSet -> { List<ColumnHandle> lookupSchema = Lists.transform(lookupSymbolSchema, forMap(node.getAssignments())); List<ColumnHandle> outputSchema = Lists.transform(node.getOutputSymbols(), forMap(node.getAssignments())); ConnectorIndex index = indexManager.getIndex(session, node.getIndexHandle(), lookupSchema, outputSchema);
@Parameterized.Parameters public static Iterable<Object[]> constructorFeeder() { return Iterables.transform( Sets.cartesianProduct( ImmutableList.of( ImmutableSet.of(true, false), ImmutableSet.of("", "MISSING VALUE"), ImmutableSet.of(Optional.of(true), Optional.of(false), Optional.empty()) ) ), List::toArray ); }
@Override public StreamProperties visitAssignUniqueId(AssignUniqueId node, List<StreamProperties> inputProperties) { StreamProperties properties = Iterables.getOnlyElement(inputProperties); if (properties.getPartitioningColumns().isPresent()) { // preserve input (possibly preferred) partitioning return properties; } return new StreamProperties(properties.getDistribution(), Optional.of(ImmutableList.of(node.getIdColumn())), properties.isOrdered()); }
@Test public void testListZones() { String cursor = "cursor"; compute = options.getService(); ImmutableList<Zone> zoneList = ImmutableList.of(ZONE, ZONE); Tuple<String, Iterable<com.google.api.services.compute.model.Zone>> result = Tuple.of(cursor, Iterables.transform(zoneList, Zone.TO_PB_FUNCTION)); EasyMock.expect(computeRpcMock.listZones(EMPTY_RPC_OPTIONS)).andReturn(result); EasyMock.replay(computeRpcMock); Page<Zone> page = compute.listZones(); assertEquals(cursor, page.getNextPageToken()); assertArrayEquals(zoneList.toArray(), Iterables.toArray(page.getValues(), Zone.class)); }
@Test public void testGetPartitionNamesUnpartitioned() { try (Transaction transaction = newTransaction()) { ConnectorMetadata metadata = transaction.getMetadata(); ConnectorTableHandle tableHandle = getTableHandle(metadata, tableUnpartitioned); List<ConnectorTableLayoutResult> tableLayoutResults = metadata.getTableLayouts(newSession(), tableHandle, Constraint.alwaysTrue(), Optional.empty()); assertEquals(getAllPartitions(getOnlyElement(tableLayoutResults).getTableLayout().getHandle()).size(), 1); assertExpectedTableLayout(getOnlyElement(tableLayoutResults).getTableLayout(), unpartitionedTableLayout); } }
public void testInvalidGetPartitionsByNames() { Map<String, Optional<Partition>> partitionsByNames = metastore.getPartitionsByNames(BAD_DATABASE, TEST_TABLE, ImmutableList.of(TEST_PARTITION1)); assertEquals(partitionsByNames.size(), 1); Optional<Partition> onlyElement = Iterables.getOnlyElement(partitionsByNames.values()); assertFalse(onlyElement.isPresent()); }
@Test public void testStringStrideDictionary() throws Exception { tester.testRoundTrip(VARCHAR, newArrayList(concat(ImmutableList.of("a"), nCopies(9999, "123"), ImmutableList.of("b"), nCopies(9999, "123")))); }
private ImmutableList<IndexItem<?, Object>> loadSezpozIndices(ClassLoader classLoader) { List<IndexItem<?,Object>> indices = Lists.newArrayList(); for (GuiceExtensionAnnotation<?> gea : extensionAnnotations.values()) { Iterables.addAll(indices, Index.load(gea.annotationType, Object.class, classLoader)); } return ImmutableList.copyOf(indices); }
private static Sequence<Result<SearchResultValue>> makeReturnResult( Segment segment, int limit, Object2IntRBTreeMap<SearchHit> retVal ) { Iterable<SearchHit> source = Iterables.transform( retVal.object2IntEntrySet(), new Function<Object2IntMap.Entry<SearchHit>, SearchHit>() { @Override public SearchHit apply(Object2IntMap.Entry<SearchHit> input) { SearchHit hit = input.getKey(); return new SearchHit(hit.getDimension(), hit.getValue(), input.getIntValue()); } } ); return Sequences.simple( ImmutableList.of( new Result<>( segment.getDataInterval().getStart(), new SearchResultValue( Lists.newArrayList(new FunctionalIterable<>(source).limit(limit)) ) ) ) ); } }
/** * Returns a fetch of transformers applicable to the given constructor. * * @param constructor constructor * @return transformers */ public static Iterable<Function<Object[], Object[]>> getTransformers(Constructor<?> constructor) { Iterable<ArgumentTransformer> transformers = Lists.newArrayList( new PrimitiveAwareVarArgsTransformer(constructor), new PrimitiveTransformer(constructor), new VarArgsTransformer(constructor)); return ImmutableList .<Function<Object[], Object[]>>copyOf(filter(transformers, applicableFilter)); }
private ColumnStatisticsAggregation createAggregation(QualifiedName functionName, SymbolReference input, Type inputType, Type outputType) { Signature signature = metadata.getFunctionRegistry().resolveFunction(functionName, TypeSignatureProvider.fromTypes(ImmutableList.of(inputType))); Type resolvedType = metadata.getType(getOnlyElement(signature.getArgumentTypes())); verify(resolvedType.equals(inputType), "resolved function input type does not match the input type: %s != %s", resolvedType, inputType); return new ColumnStatisticsAggregation( new AggregationNode.Aggregation( new FunctionCall(functionName, ImmutableList.of(input)), signature, Optional.empty()), outputType); }
.intervals(QueryRunnerTestHelper.emptyInterval) .aggregators( Lists.newArrayList( Iterables.concat( commonAggregators, Lists.newArrayList( new DoubleMaxAggregatorFactory("maxIndex", "index"), new DoubleMinAggregatorFactory("minIndex", "index"), .build(); List<Result<TopNResultValue>> expectedResults = ImmutableList.of( new Result<>( DateTimes.of("2020-04-02T00:00:00.000Z"), new TopNResultValue(ImmutableList.of())