1717import java .util .List ;
1818import java .util .Map ;
1919import java .util .Map .Entry ;
20- import java .util .Optional ;
2120import java .util .Set ;
2221import java .util .stream .Collectors ;
2322
@@ -28,8 +27,6 @@ the job of the class is to handle unknown field errors and then update the bq ta
2827public class JsonErrorHandler implements ErrorHandler {
2928
3029 private final BigQueryClient bigQueryClient ;
31- private final String tablePartitionKey ;
32- private final Optional <LegacySQLTypeName > partitionKeyDataType ;
3330 private final boolean castAllColumnsToStringDataType ;
3431 private final Map <String , String > metadataColumnsTypesMap ;
3532 private final String bqMetadataNamespace ;
@@ -40,15 +37,9 @@ public JsonErrorHandler(BigQueryClient bigQueryClient, BigQuerySinkConfig bigQue
4037
4138 this .instrumentation = instrumentation ;
4239 this .bigQueryClient = bigQueryClient ;
43- tablePartitionKey = bigQuerySinkConfig .isTablePartitioningEnabled () ? bigQuerySinkConfig .getTablePartitionKey () : "" ;
4440 defaultColumnsMap = bigQuerySinkConfig .getSinkBigqueryDefaultColumns ()
4541 .stream ()
4642 .collect (Collectors .toMap (TupleString ::getFirst , TupleString ::getSecond ));
47- if (bigQuerySinkConfig .isTablePartitioningEnabled ()) {
48- partitionKeyDataType = Optional .of (LegacySQLTypeName .valueOfStrict (defaultColumnsMap .get (tablePartitionKey ).toUpperCase ()));
49- } else {
50- partitionKeyDataType = Optional .empty ();
51- }
5243 castAllColumnsToStringDataType = bigQuerySinkConfig .getSinkBigqueryDefaultDatatypeStringEnable ();
5344 bqMetadataNamespace = bigQuerySinkConfig .getBqMetadataNamespace ();
5445 if (!bigQuerySinkConfig .shouldAddMetadata ()) {
@@ -103,11 +94,11 @@ private List<BigQueryError> getBqErrorsWithNoSuchFields(List<BigQueryError> valu
10394 ).collect (Collectors .toList ());
10495 }
10596
97+ /**
98+ * This method only used for unknown fields.
99+ */
106100
107101 private Field getField (String key ) {
108- if (!tablePartitionKey .isEmpty () && tablePartitionKey .equals (key ) && partitionKeyDataType .isPresent ()) {
109- return Field .of (key , partitionKeyDataType .get ());
110- }
111102 if (!bqMetadataNamespace .isEmpty ()) {
112103 throw new UnsupportedOperationException ("metadata namespace is not supported, because nested json structure is not supported" );
113104 }
0 commit comments