-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: better default stream support in client library (#750)
* . * . * . * feat: Support default stream on streamWriter and jsonStreamWriter * add integration test * . * . * ci(java): ignore bot users for generate-files-bot (#749) Depends on googleapis/repo-automation-bots#1254 Fixes googleapis/repo-automation-bots#1096 Source-Author: Jeff Ching <chingor@google.com> Source-Date: Tue Dec 15 16:16:07 2020 -0800 Source-Repo: googleapis/synthtool Source-Sha: 3f67ceece7e797a5736a25488aae35405649b90b Source-Link: googleapis/synthtool@3f67cee * . * . * chore: synthtool changes (#746) * changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * chore: migrate java-bigquerystorage to the Java microgenerator Committer: @miraleung PiperOrigin-RevId: 345311069 Source-Author: Google APIs <noreply@google.com> Source-Date: Wed Dec 2 14:17:15 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: e39e42f368d236203a774ee994fcb4d730c33a83 Source-Link: googleapis/googleapis@e39e42f * feat!: Updates to BigQuery Write API V1Beta2 public interface. This includes breaking changes to the API, it is fine because the API is not officially launched yet. PiperOrigin-RevId: 345469340 Source-Author: Google APIs <noreply@google.com> Source-Date: Thu Dec 3 09:33:11 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: b53c4d98aab1eae3dac90b37019dede686782f13 Source-Link: googleapis/googleapis@b53c4d9 * fix: Update gapic-generator-java to 0.0.7 Committer: @miraleung PiperOrigin-RevId: 345476969 Source-Author: Google APIs <noreply@google.com> Source-Date: Thu Dec 3 10:07:32 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 7be2c821dd88109038c55c89f7dd48f092eeab9d Source-Link: googleapis/googleapis@7be2c82 * chore: rollback migrating java-bigquerystorage to the Java microgenerator Committer: @miraleung PiperOrigin-RevId: 345522380 Source-Author: Google APIs <noreply@google.com> Source-Date: Thu Dec 3 13:28:07 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: f8f975c7d43904e90d6c5f1684fdb6804400e641 Source-Link: googleapis/googleapis@f8f975c * chore: migrate java-bigquerystorage to the Java microgenerator Committer: @miraleung PiperOrigin-RevId: 346405446 Source-Author: Google APIs <noreply@google.com> Source-Date: Tue Dec 8 14:03:11 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: abc43060f136ce77124754a48f367102e646844a Source-Link: googleapis/googleapis@abc4306 * chore: update gapic-generator-java to 0.0.11 Committer: @miraleung PiperOrigin-RevId: 347036369 Source-Author: Google APIs <noreply@google.com> Source-Date: Fri Dec 11 11:13:47 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 6d65640b1fcbdf26ea76cb720de0ac138cae9bed Source-Link: googleapis/googleapis@6d65640 * chore: update gapic-generator-java to 0.0.13 Committer: @miraleung PiperOrigin-RevId: 347849179 Source-Author: Google APIs <noreply@google.com> Source-Date: Wed Dec 16 10:28:38 2020 -0800 Source-Repo: googleapis/googleapis Source-Sha: 360a0e177316b7e9811f2ccbbef11e5f83377f3f Source-Link: googleapis/googleapis@360a0e1 * . * . * . * . * . * . * . * fix flushall test Co-authored-by: Yoshi Automation Bot <yoshi-automation@google.com> Co-authored-by: Stephanie Wang <stephaniewang526@users.noreply.github.com>
- Loading branch information
1 parent
0988105
commit 488f258
Showing
9 changed files
with
372 additions
and
66 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
85 changes: 85 additions & 0 deletions
85
...age/src/main/java/com/google/cloud/bigquery/storage/v1beta2/BQV2ToBQStorageConverter.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,85 @@ | ||
/* | ||
* Copyright 2020 Google LLC | ||
* | ||
* 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 | ||
* | ||
* https://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 com.google.cloud.bigquery.storage.v1beta2; | ||
|
||
import com.google.cloud.bigquery.Field; | ||
import com.google.cloud.bigquery.Schema; | ||
import com.google.cloud.bigquery.StandardSQLTypeName; | ||
import com.google.common.collect.ImmutableMap; | ||
|
||
/** Converts structure from BigQuery v2 API to BigQueryStorage API */ | ||
public class BQV2ToBQStorageConverter { | ||
private static ImmutableMap<Field.Mode, TableFieldSchema.Mode> BQTableSchemaModeMap = | ||
ImmutableMap.of( | ||
Field.Mode.NULLABLE, TableFieldSchema.Mode.NULLABLE, | ||
Field.Mode.REPEATED, TableFieldSchema.Mode.REPEATED, | ||
Field.Mode.REQUIRED, TableFieldSchema.Mode.REQUIRED); | ||
|
||
private static ImmutableMap<StandardSQLTypeName, TableFieldSchema.Type> BQTableSchemaTypeMap = | ||
new ImmutableMap.Builder<StandardSQLTypeName, TableFieldSchema.Type>() | ||
.put(StandardSQLTypeName.BOOL, TableFieldSchema.Type.BOOL) | ||
.put(StandardSQLTypeName.BYTES, TableFieldSchema.Type.BYTES) | ||
.put(StandardSQLTypeName.DATE, TableFieldSchema.Type.DATE) | ||
.put(StandardSQLTypeName.DATETIME, TableFieldSchema.Type.DATETIME) | ||
.put(StandardSQLTypeName.FLOAT64, TableFieldSchema.Type.DOUBLE) | ||
.put(StandardSQLTypeName.GEOGRAPHY, TableFieldSchema.Type.GEOGRAPHY) | ||
.put(StandardSQLTypeName.INT64, TableFieldSchema.Type.INT64) | ||
.put(StandardSQLTypeName.NUMERIC, TableFieldSchema.Type.NUMERIC) | ||
.put(StandardSQLTypeName.STRING, TableFieldSchema.Type.STRING) | ||
.put(StandardSQLTypeName.STRUCT, TableFieldSchema.Type.STRUCT) | ||
.put(StandardSQLTypeName.TIME, TableFieldSchema.Type.TIME) | ||
.put(StandardSQLTypeName.TIMESTAMP, TableFieldSchema.Type.TIMESTAMP) | ||
.build(); | ||
|
||
/** | ||
* Converts from bigquery v2 Table Schema to bigquery storage API Table Schema. | ||
* | ||
* @param schame the bigquery v2 Table Schema | ||
* @return the bigquery storage API Table Schema | ||
*/ | ||
public static TableSchema ConvertTableSchema(Schema schema) { | ||
TableSchema.Builder result = TableSchema.newBuilder(); | ||
for (int i = 0; i < schema.getFields().size(); i++) { | ||
result.addFields(i, ConvertFieldSchema(schema.getFields().get(i))); | ||
} | ||
return result.build(); | ||
} | ||
|
||
/** | ||
* Converts from bigquery v2 Field Schema to bigquery storage API Field Schema. | ||
* | ||
* @param schame the bigquery v2 Field Schema | ||
* @return the bigquery storage API Field Schema | ||
*/ | ||
public static TableFieldSchema ConvertFieldSchema(Field field) { | ||
TableFieldSchema.Builder result = TableFieldSchema.newBuilder(); | ||
if (field.getMode() == null) { | ||
field = field.toBuilder().setMode(Field.Mode.NULLABLE).build(); | ||
} | ||
result.setMode(BQTableSchemaModeMap.get(field.getMode())); | ||
result.setName(field.getName()); | ||
result.setType(BQTableSchemaTypeMap.get(field.getType().getStandardType())); | ||
if (field.getDescription() != null) { | ||
result.setDescription(field.getDescription()); | ||
} | ||
if (field.getSubFields() != null) { | ||
for (int i = 0; i < field.getSubFields().size(); i++) { | ||
result.addFields(i, ConvertFieldSchema(field.getSubFields().get(i))); | ||
} | ||
} | ||
return result.build(); | ||
} | ||
} |
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
Oops, something went wrong.