Search in sources :

Example 11 with DataplexBigQueryToGcsFilter

use of com.google.cloud.teleport.v2.utils.DataplexBigQueryToGcsFilter in project DataflowTemplates by GoogleCloudPlatform.

the class DataplexBigQueryToGcsFilterTest method test_whenBeforeDateIs1DayDuration_dateParsedCorrectly.

@Test
public void test_whenBeforeDateIs1DayDuration_dateParsedCorrectly() {
    // current time in the DEFAULT time zone minus one day:
    long micros = Instant.now().minus(Duration.standardDays(1)).getMillis() * 1000L;
    BigQueryTable.Builder olderTable = table().setLastModificationTime(micros - 100000L);
    BigQueryTable.Builder newerTable = table().setLastModificationTime(micros + 100000L);
    options.setTables(null);
    options.setExportDataModifiedBeforeDateTime("-P1D");
    Filter f = new DataplexBigQueryToGcsFilter(options, new ArrayList<String>());
    assertThat(f.shouldSkipUnpartitionedTable(newerTable)).isTrue();
    assertThat(f.shouldSkipUnpartitionedTable(olderTable)).isFalse();
}
Also used : Filter(com.google.cloud.teleport.v2.utils.BigQueryMetadataLoader.Filter) BigQueryTable(com.google.cloud.teleport.v2.values.BigQueryTable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)10 Filter (com.google.cloud.teleport.v2.utils.BigQueryMetadataLoader.Filter)9 BigQueryTable (com.google.cloud.teleport.v2.values.BigQueryTable)9 BigQueryTablePartition (com.google.cloud.teleport.v2.values.BigQueryTablePartition)5 FieldValueList (com.google.cloud.bigquery.FieldValueList)1 QueryJobConfiguration (com.google.cloud.bigquery.QueryJobConfiguration)1 NoopTransform (com.google.cloud.teleport.v2.transforms.NoopTransform)1 DataplexBigQueryToGcsFilter (com.google.cloud.teleport.v2.utils.DataplexBigQueryToGcsFilter)1 WriteDispositionException (com.google.cloud.teleport.v2.utils.WriteDisposition.WriteDispositionException)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 Pipeline (org.apache.beam.sdk.Pipeline)1