Search in sources :

Example 31 with Row

use of com.google.api.ads.admanager.axis.v202111.Row in project googleads-java-lib by googleads.

the class PqlTest method testGetRowStringValues.

@Test
public void testGetRowStringValues() {
    Row row = new Row();
    row.setValues(new Value[] { textValue1, booleanValue1, numberValue2, numberSetValue });
    assertEquals(Lists.newArrayList(new String[] { "value1", "false", "1.02", "1,-1" }), Pql.getRowStringValues(row));
}
Also used : Row(com.google.api.ads.admanager.axis.v202202.Row) Test(org.junit.Test)

Example 32 with Row

use of com.google.api.ads.admanager.axis.v202111.Row in project googleads-java-lib by googleads.

the class PqlTest method testCombineResultSet.

@Test
public void testCombineResultSet() {
    Row row1 = new Row();
    row1.setValues(new Value[] { textValue1, booleanValue1, numberValue1 });
    Row row2 = new Row();
    row2.setValues(new Value[] { textValue2, booleanValue2, numberValue2 });
    Row row3 = new Row();
    row3.setValues(new Value[] { textValue3, booleanValue3, numberValue3 });
    ResultSet resultSet1 = new ResultSet();
    resultSet1.setColumnTypes(new ColumnType[] { column1, column2, column3 });
    resultSet1.setRows(new Row[] { row1, row2 });
    ResultSet resultSet2 = new ResultSet();
    resultSet2.setColumnTypes(new ColumnType[] { column1, column2, column3 });
    resultSet2.setRows(new Row[] { row3 });
    ResultSet combinedResultSet = Pql.combineResultSets(resultSet1, resultSet2);
    assertEquals(3, combinedResultSet.getRows().length);
    assertArrayEquals(new ColumnType[] { column1, column2, column3 }, combinedResultSet.getColumnTypes());
    assertArrayEquals(new Value[] { textValue1, booleanValue1, numberValue1 }, combinedResultSet.getRows()[0].getValues());
    assertArrayEquals(new Value[] { textValue2, booleanValue2, numberValue2 }, combinedResultSet.getRows()[1].getValues());
    assertArrayEquals(new Value[] { textValue3, booleanValue3, numberValue3 }, combinedResultSet.getRows()[2].getValues());
}
Also used : ResultSet(com.google.api.ads.admanager.axis.v202111.ResultSet) Row(com.google.api.ads.admanager.axis.v202111.Row) Test(org.junit.Test)

Example 33 with Row

use of com.google.api.ads.admanager.axis.v202111.Row in project googleads-java-lib by googleads.

the class PqlTest method testCombineResultSet_badColumns.

@Test
public void testCombineResultSet_badColumns() {
    Row row1 = new Row();
    row1.setValues(new Value[] { textValue1, booleanValue1, numberValue1 });
    Row row2 = new Row();
    row2.setValues(new Value[] { textValue2, booleanValue2, numberValue2 });
    Row row3 = new Row();
    row3.setValues(new Value[] { textValue3, booleanValue3 });
    ResultSet resultSet1 = new ResultSet();
    resultSet1.setColumnTypes(new ColumnType[] { column1, column2, column3 });
    resultSet1.setRows(new Row[] { row1, row2 });
    ResultSet resultSet2 = new ResultSet();
    resultSet2.setColumnTypes(new ColumnType[] { column1, column2 });
    resultSet2.setRows(new Row[] { row3 });
    thrown.expect(IllegalArgumentException.class);
    Pql.combineResultSets(resultSet1, resultSet2);
}
Also used : ResultSet(com.google.api.ads.admanager.axis.v202111.ResultSet) Row(com.google.api.ads.admanager.axis.v202111.Row) Test(org.junit.Test)

Example 34 with Row

use of com.google.api.ads.admanager.axis.v202111.Row in project googleads-java-lib by googleads.

the class PqlTest method testGetRowStringValues.

@Test
public void testGetRowStringValues() {
    Row row = new Row();
    row.setValues(new Value[] { textValue1, booleanValue1, numberValue2, numberSetValue });
    assertEquals(Lists.newArrayList(new String[] { "value1", "false", "1.02", "1,-1" }), Pql.getRowStringValues(row));
}
Also used : Row(com.google.api.ads.admanager.axis.v202111.Row) Test(org.junit.Test)

Example 35 with Row

use of com.google.api.ads.admanager.axis.v202111.Row in project beam by apache.

the class BigtableIOTest method testReadingWithRuntimeParameterizedFilter.

/**
 * Tests reading rows using a filter provided through ValueProvider.
 */
@Test
public void testReadingWithRuntimeParameterizedFilter() throws Exception {
    final String table = "TEST-FILTER-TABLE";
    final int numRows = 1001;
    List<Row> testRows = makeTableData(table, numRows);
    String regex = ".*17.*";
    final KeyMatchesRegex keyPredicate = new KeyMatchesRegex(regex);
    Iterable<Row> filteredRows = testRows.stream().filter(input -> {
        verifyNotNull(input, "input");
        return keyPredicate.apply(input.getKey());
    }).collect(Collectors.toList());
    RowFilter filter = RowFilter.newBuilder().setRowKeyRegexFilter(ByteString.copyFromUtf8(regex)).build();
    service.setupSampleRowKeys(table, 5, 10L);
    runReadTest(defaultRead.withTableId(table).withRowFilter(StaticValueProvider.of(filter)), Lists.newArrayList(filteredRows));
}
Also used : ExpectedLogs(org.apache.beam.sdk.testing.ExpectedLogs) Mutation(com.google.bigtable.v2.Mutation) Arrays(java.util.Arrays) PipelineExecutionException(org.apache.beam.sdk.Pipeline.PipelineExecutionException) Matchers.hasItems(org.hamcrest.Matchers.hasItems) BoundedReader(org.apache.beam.sdk.io.BoundedSource.BoundedReader) Create(org.apache.beam.sdk.transforms.Create) Map(java.util.Map) Window(org.apache.beam.sdk.transforms.windowing.Window) GlobalWindow(org.apache.beam.sdk.transforms.windowing.GlobalWindow) Wait(org.apache.beam.sdk.transforms.Wait) Predicates(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Predicates) ValueProvider(org.apache.beam.sdk.options.ValueProvider) KvCoder(org.apache.beam.sdk.coders.KvCoder) GcpOptions(org.apache.beam.sdk.extensions.gcp.options.GcpOptions) Matchers.allOf(org.hamcrest.Matchers.allOf) Family(com.google.bigtable.v2.Family) StandardCharsets(java.nio.charset.StandardCharsets) Serializable(java.io.Serializable) CompletionStage(java.util.concurrent.CompletionStage) Verify.verifyNotNull(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Verify.verifyNotNull) MutateRowResponse(com.google.bigtable.v2.MutateRowResponse) TestStream(org.apache.beam.sdk.testing.TestStream) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) SourceTestUtils.assertSplitAtFractionSucceedsAndConsistent(org.apache.beam.sdk.testing.SourceTestUtils.assertSplitAtFractionSucceedsAndConsistent) DisplayDataMatchers.hasDisplayItem(org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasDisplayItem) DisplayDataMatchers.hasLabel(org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasLabel) Preconditions.checkNotNull(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkNotNull) KV(org.apache.beam.sdk.values.KV) TypeDescriptor(org.apache.beam.sdk.values.TypeDescriptor) Duration(org.joda.time.Duration) RunWith(org.junit.runner.RunWith) ArrayList(java.util.ArrayList) DisplayDataMatchers.hasValue(org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasValue) TestPipeline(org.apache.beam.sdk.testing.TestPipeline) Preconditions.checkArgument(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkArgument) Matchers.lessThan(org.hamcrest.Matchers.lessThan) SetCell(com.google.bigtable.v2.Mutation.SetCell) Matchers.hasSize(org.hamcrest.Matchers.hasSize) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) DoFn(org.apache.beam.sdk.transforms.DoFn) PAssert(org.apache.beam.sdk.testing.PAssert) IterableCoder(org.apache.beam.sdk.coders.IterableCoder) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) TreeMap(java.util.TreeMap) BoundedWindow(org.apache.beam.sdk.transforms.windowing.BoundedWindow) SourceTestUtils.assertSplitAtFractionExhaustive(org.apache.beam.sdk.testing.SourceTestUtils.assertSplitAtFractionExhaustive) IntervalWindow(org.apache.beam.sdk.transforms.windowing.IntervalWindow) Assert.assertEquals(org.junit.Assert.assertEquals) ByteKeyRange(org.apache.beam.sdk.io.range.ByteKeyRange) BulkOptions(com.google.cloud.bigtable.config.BulkOptions) SampleRowKeysResponse(com.google.bigtable.v2.SampleRowKeysResponse) SerializableFunction(org.apache.beam.sdk.transforms.SerializableFunction) Column(com.google.bigtable.v2.Column) Description(org.apache.beam.sdk.options.Description) RowFilter(com.google.bigtable.v2.RowFilter) PipelineRunMissingException(org.apache.beam.sdk.testing.TestPipeline.PipelineRunMissingException) SourceTestUtils.assertSourcesEqualReferenceSource(org.apache.beam.sdk.testing.SourceTestUtils.assertSourcesEqualReferenceSource) Cell(com.google.bigtable.v2.Cell) Row(com.google.bigtable.v2.Row) VarLongCoder(org.apache.beam.sdk.coders.VarLongCoder) Collectors(java.util.stream.Collectors) ByteString(com.google.protobuf.ByteString) BigtableSource(org.apache.beam.sdk.io.gcp.bigtable.BigtableIO.BigtableSource) List(java.util.List) ParDo(org.apache.beam.sdk.transforms.ParDo) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) ImmutableList(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.ImmutableList) SortedMap(java.util.SortedMap) RetryOptions(com.google.cloud.bigtable.config.RetryOptions) ByteKey(org.apache.beam.sdk.io.range.ByteKey) Coder(org.apache.beam.sdk.coders.Coder) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) PipelineOptionsFactory(org.apache.beam.sdk.options.PipelineOptionsFactory) DisplayDataMatchers.hasKey(org.apache.beam.sdk.transforms.display.DisplayDataMatchers.hasKey) StringUtf8Coder(org.apache.beam.sdk.coders.StringUtf8Coder) ByteStringCoder(org.apache.beam.sdk.extensions.protobuf.ByteStringCoder) SourceTestUtils.assertSplitAtFractionFails(org.apache.beam.sdk.testing.SourceTestUtils.assertSplitAtFractionFails) ProtoCoder(org.apache.beam.sdk.extensions.protobuf.ProtoCoder) CredentialType(com.google.cloud.bigtable.config.CredentialOptions.CredentialType) NoSuchElementException(java.util.NoSuchElementException) ExpectedException(org.junit.rules.ExpectedException) Predicate(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Predicate) Nullable(org.checkerframework.checker.nullness.qual.Nullable) BigtableOptions(com.google.cloud.bigtable.config.BigtableOptions) DisplayData(org.apache.beam.sdk.transforms.display.DisplayData) Iterator(java.util.Iterator) Assert.assertNotNull(org.junit.Assert.assertNotNull) CredentialOptions(com.google.cloud.bigtable.config.CredentialOptions) FixedWindows(org.apache.beam.sdk.transforms.windowing.FixedWindows) Lists(org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Lists) Matchers(org.hamcrest.Matchers) JUnit4(org.junit.runners.JUnit4) PCollection(org.apache.beam.sdk.values.PCollection) TestCredential(org.apache.beam.sdk.extensions.gcp.auth.TestCredential) Rule(org.junit.Rule) Instant(org.joda.time.Instant) StaticValueProvider(org.apache.beam.sdk.options.ValueProvider.StaticValueProvider) Comparator(java.util.Comparator) Collections(java.util.Collections) IsIterableContainingInAnyOrder(org.hamcrest.collection.IsIterableContainingInAnyOrder) RowFilter(com.google.bigtable.v2.RowFilter) ByteString(com.google.protobuf.ByteString) Row(com.google.bigtable.v2.Row) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)36 Row (com.google.bigtable.v2.Row)16 ByteString (com.google.protobuf.ByteString)11 Function (com.google.common.base.Function)8 Row (com.google.api.ads.admanager.axis.v202108.Row)6 Row (com.google.api.ads.admanager.axis.v202111.Row)6 Row (com.google.api.ads.admanager.axis.v202202.Row)6 Family (com.google.bigtable.v2.Family)6 ByteKey (org.apache.beam.sdk.io.range.ByteKey)6 Row (com.google.api.ads.admanager.axis.v202105.Row)5 Row (com.google.api.ads.admanager.jaxws.v202105.Row)5 Row (com.google.api.ads.admanager.jaxws.v202108.Row)5 Row (com.google.api.ads.admanager.jaxws.v202111.Row)5 Row (com.google.api.ads.admanager.jaxws.v202202.Row)5 ResultSet (com.google.api.ads.admanager.axis.v202108.ResultSet)4 ResultSet (com.google.api.ads.admanager.axis.v202111.ResultSet)4 ResultSet (com.google.api.ads.admanager.axis.v202202.ResultSet)4 Column (com.google.bigtable.v2.Column)4 ReadRowsRequest (com.google.bigtable.v2.ReadRowsRequest)4 ResultSet (com.google.api.ads.admanager.jaxws.v202105.ResultSet)3