Skip to content

Commit

Permalink
[Improve] Make sure CatalogTable options and partitionKeys are mutable (
Browse files Browse the repository at this point in the history
  • Loading branch information
Hisoka-X authored Oct 21, 2023
1 parent c554ea7 commit 7cbaedf
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.apache.seatunnel.api.table.type.SeaTunnelRowType;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -80,8 +82,9 @@ private CatalogTable(
String catalogName) {
this.tableId = tableId;
this.tableSchema = tableSchema;
this.options = options;
this.partitionKeys = partitionKeys;
// Make sure the options and partitionKeys are mutable
this.options = new HashMap<>(options);
this.partitionKeys = new ArrayList<>(partitionKeys);
this.comment = comment;
this.catalogName = catalogName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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 org.apache.seatunnel.api.table.catalog;

import org.junit.jupiter.api.Test;

import java.util.Collections;

public class CatalogTableTest {

@Test
public void testCatalogTableModifyOptionsOrPartitionKeys() {
CatalogTable catalogTable =
CatalogTable.of(
TableIdentifier.of("catalog", "database", "table"),
TableSchema.builder().build(),
Collections.emptyMap(),
Collections.emptyList(),
"comment");
catalogTable.getOptions().put("test", "value");
catalogTable.getPartitionKeys().add("test");
}
}

0 comments on commit 7cbaedf

Please sign in to comment.