All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.cdap.plugin.gcp.bigquery.sink.lib.BigQueryTimePartitioning Maven / Gradle / Ivy

/*
 * Copyright © 2023 Cask Data, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package io.cdap.plugin.gcp.bigquery.sink.lib;

import com.google.api.client.json.JsonParser;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.services.bigquery.model.TimePartitioning;
import java.io.IOException;

/**
 * Wrapper for BigQuery {@link TimePartitioning}.
 *
 * 

This class is used to avoid client code to depend on BigQuery API classes, so that there is no * potential conflict between different versions of BigQuery API libraries in the client. * * @see TimePartitioning * - Moved from com.google.cloud.hadoop.io.bigquery bigquery-connector library * - Update the table regex as per the requirement of flexible column names * TODO(PLUGIN-1725): Migrate to Spark BigQuery connector. */ public class BigQueryTimePartitioning { private final TimePartitioning timePartitioning; public BigQueryTimePartitioning() { this.timePartitioning = new TimePartitioning(); } public BigQueryTimePartitioning(TimePartitioning timePartitioning) { this.timePartitioning = timePartitioning; } public String getType() { return timePartitioning.getType(); } public void setType(String type) { timePartitioning.setType(type); } public String getField() { return timePartitioning.getField(); } public void setField(String field) { timePartitioning.setField(field); } public long getExpirationMs() { return timePartitioning.getExpirationMs(); } public void setExpirationMs(long expirationMs) { timePartitioning.setExpirationMs(expirationMs); } public Boolean getRequirePartitionFilter() { return timePartitioning.getRequirePartitionFilter(); } public void setRequirePartitionFilter(Boolean requirePartitionFilter) { timePartitioning.setRequirePartitionFilter(requirePartitionFilter); } @Override public int hashCode() { return timePartitioning.hashCode(); } @Override public boolean equals(Object obj) { if (!(obj instanceof com.google.cloud.hadoop.io.bigquery.output.BigQueryTimePartitioning)) { return false; } BigQueryTimePartitioning other = (BigQueryTimePartitioning) obj; return timePartitioning.equals(other.timePartitioning); } TimePartitioning get() { return timePartitioning; } static TimePartitioning getFromJson(String json) throws IOException { JsonParser parser = JacksonFactory.getDefaultInstance().createJsonParser(json); return parser.parseAndClose(TimePartitioning.class); } public String getAsJson() throws IOException { return JacksonFactory.getDefaultInstance().toString(timePartitioning); } static BigQueryTimePartitioning wrap(TimePartitioning tableTimePartitioning) { return new BigQueryTimePartitioning(tableTimePartitioning); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy