1
+ /*
2
+ * Copyright 2024 Copyright 2022 Aiven Oy and
3
+ * bigquery-connector-for-apache-kafka project contributors
4
+ *
5
+ * This software contains code derived from the Confluent BigQuery
6
+ * Kafka Connector, Copyright Confluent, Inc, which in turn
7
+ * contains code derived from the WePay BigQuery Kafka Connector,
8
+ * Copyright WePay, Inc.
9
+ *
10
+ * Licensed under the Apache License, Version 2.0 (the "License");
11
+ * you may not use this file except in compliance with the License.
12
+ * You may obtain a copy of the License at
13
+ *
14
+ * http://www.apache.org/licenses/LICENSE-2.0
15
+ *
16
+ * Unless required by applicable law or agreed to in writing,
17
+ * software distributed under the License is distributed on an
18
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19
+ * KIND, either express or implied. See the License for the
20
+ * specific language governing permissions and limitations
21
+ * under the License.
22
+ */
23
+
1
24
package com .wepay .kafka .connect .bigquery ;
2
25
3
26
import com .google .cloud .bigquery .BigQuery ;
@@ -31,7 +54,6 @@ class RecordTableResolver {
31
54
private final boolean usePartitionDecorator ;
32
55
private final boolean upsertDelete ;
33
56
private final boolean useMessageTimeDatePartitioning ;
34
- private final boolean useStorageApi ;
35
57
36
58
public RecordTableResolver (BigQuerySinkTaskConfig config , MergeBatches mergeBatches , BigQuery bigQuery ) {
37
59
this .config = config ;
@@ -40,11 +62,10 @@ public RecordTableResolver(BigQuerySinkTaskConfig config, MergeBatches mergeBatc
40
62
41
63
this .useMessageTimeDatePartitioning =
42
64
config .getBoolean (BigQuerySinkConfig .BIGQUERY_MESSAGE_TIME_PARTITIONING_CONFIG );
43
- this .usePartitionDecorator =
44
- config .getBoolean (BigQuerySinkConfig .BIGQUERY_PARTITION_DECORATOR_CONFIG );
45
- this .useStorageApi =
46
- config .getBoolean (BigQuerySinkConfig .USE_STORAGE_WRITE_API_CONFIG );
47
- this .upsertDelete = !useStorageApi && (config .getBoolean (BigQuerySinkConfig .UPSERT_ENABLED_CONFIG )
65
+ this .usePartitionDecorator = config .getBoolean (BigQuerySinkConfig .BIGQUERY_PARTITION_DECORATOR_CONFIG )
66
+ && !config .getBoolean (BigQuerySinkConfig .ENABLE_BATCH_MODE_CONFIG );
67
+ this .upsertDelete = !config .getBoolean (BigQuerySinkConfig .USE_STORAGE_WRITE_API_CONFIG )
68
+ && (config .getBoolean (BigQuerySinkConfig .UPSERT_ENABLED_CONFIG )
48
69
|| config .getBoolean (BigQuerySinkConfig .DELETE_ENABLED_CONFIG ));
49
70
}
50
71
@@ -74,9 +95,7 @@ private TableId getBaseTableId(String topic) {
74
95
return topicToTableId .computeIfAbsent (topic , topicName -> {
75
96
String [] datasetAndTable = TableNameUtils .getDataSetAndTableName (config , topic );
76
97
String project = config .getString (BigQuerySinkConfig .PROJECT_CONFIG );
77
- TableId baseTableId = (!useStorageApi )
78
- ? TableId .of (datasetAndTable [0 ], datasetAndTable [1 ])
79
- : TableId .of (project , datasetAndTable [0 ], datasetAndTable [1 ]);
98
+ TableId baseTableId = TableId .of (project , datasetAndTable [0 ], datasetAndTable [1 ]);
80
99
81
100
if (usePartitionDecorator ) {
82
101
validatePartitioningForDecorator (baseTableId );
@@ -90,7 +109,7 @@ private void validatePartitioningForDecorator(TableId tableId) {
90
109
StandardTableDefinition definition = retrieveTableDefinition (tableId );
91
110
if (definition == null ) {
92
111
// If we could not find table and its definition, ignore.
93
- // Table creation will potentially be handled later via SchemaManager
112
+ // Table creation will potentially be handled later if auto create is enabled
94
113
return ;
95
114
}
96
115
TimePartitioning partitioning = definition .getTimePartitioning ();
0 commit comments