forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set BigQuery table timepartition inside get table function (feast-dev…
…#333) * Fix BigQuery write setting timepartition outside of table reference * Give core a bit more time to start up * Rename GetTableReference to correctly reflect return type * Increase kafka sleep time
- Loading branch information
Chen Zhiling
committed
Nov 28, 2019
1 parent
d635315
commit ac6c18e
Showing
3 changed files
with
38 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
ingestion/src/main/java/feast/store/serving/bigquery/GetTableDestination.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package feast.store.serving.bigquery; | ||
|
||
import com.google.api.services.bigquery.model.TimePartitioning; | ||
import feast.types.FeatureRowProto.FeatureRow; | ||
import org.apache.beam.sdk.io.gcp.bigquery.TableDestination; | ||
import org.apache.beam.sdk.transforms.SerializableFunction; | ||
import org.apache.beam.sdk.values.ValueInSingleWindow; | ||
|
||
public class GetTableDestination implements | ||
SerializableFunction<ValueInSingleWindow<FeatureRow>, TableDestination> { | ||
|
||
private String projectId; | ||
private String datasetId; | ||
|
||
public GetTableDestination(String projectId, String datasetId) { | ||
this.projectId = projectId; | ||
this.datasetId = datasetId; | ||
} | ||
|
||
@Override | ||
public TableDestination apply(ValueInSingleWindow<FeatureRow> input) { | ||
String[] split = input.getValue().getFeatureSet().split(":"); | ||
|
||
TimePartitioning timePartitioning = | ||
new TimePartitioning() | ||
.setType("DAY") | ||
.setField(FeatureRowToTableRow.getEventTimestampColumn()); | ||
|
||
return new TableDestination( | ||
String.format("%s:%s.%s_v%s", projectId, datasetId, split[0], split[1]), | ||
String | ||
.format("Feast table for %s", input.getValue().getFeatureSet()), | ||
timePartitioning); | ||
} | ||
} |