Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/en/introduction/concepts/incompatible-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ You need to check this document before you upgrade to related version.

## dev

### API: identifier and type matching no longer follows the worker's default locale

- **Behavior change: the API resolves the same identifier and type name on every worker**
- **Description**: Several `seatunnel-api` code paths matched an identifier or a type name with `String#toUpperCase()` / `String#toLowerCase()` without `Locale.ROOT`. Under a Turkish or Azerbaijani default locale, an upper-case `I` lower-cases to the dotless `ı` and a lower-case `i` upper-cases to the dotted `İ`, so a name that contains an `i` or an `I` no longer matched the constant it was compared against. `PluginIdentifier#hashCode` could then return a different value for two identifiers that `equals` considers equal, and a job that enables the metalake failed to start with `No enum constant org.apache.seatunnel.common.constants.MetaLakeType.GRAVİTİNO`. These conversions now use `Locale.ROOT`.
- **Impact**: Only workers whose default locale is Turkish or Azerbaijani. There, the affected lookups now resolve as they do under any other locale; previously a job that enabled the metalake failed to start and the metalake type was not converted. Workers with any other default locale are unchanged.
- **Migration Guide**: No configuration change is needed. On such a worker, a job that enables the metalake now starts instead of failing.

### Lance sink: BIGINT columns are created as int64

- **Behavior change: a `BIGINT` column in a dataset the Lance sink creates is Arrow `int64`**
Expand Down
7 changes: 7 additions & 0 deletions docs/zh/introduction/concepts/incompatible-changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

## dev

### API:标识符与类型匹配不再跟随工作节点的默认语言环境

- **行为变更:API 在任何工作节点上解析出的标识符和类型名都保持一致**
- **描述**:`seatunnel-api` 中若干路径此前使用未指定 `Locale.ROOT` 的 `String#toUpperCase()` / `String#toLowerCase()` 匹配标识符或类型名。在土耳其语或阿塞拜疆语默认语言环境下,大写 `I` 会小写为不带点的 `ı`,小写 `i` 会大写为带点的 `İ`,因此含有 `i` 或 `I` 的名称不再匹配对应的常量:`PluginIdentifier#hashCode` 可能为两个 `equals` 判定相等的标识符返回不同的哈希值,开启元数据湖的作业会以 `No enum constant org.apache.seatunnel.common.constants.MetaLakeType.GRAVİTİNO` 启动失败。现在这些转换统一使用 `Locale.ROOT`。
- **影响**:仅影响默认语言环境为土耳其语或阿塞拜疆语的工作节点。在这些节点上,受影响的查找现在会像其他语言环境一样正确解析;此前开启元数据湖的作业无法启动,元数据类型也无法转换。其他默认语言环境的工作节点不受影响。
- **迁移指南**:无需修改配置。在这类节点上,开启元数据湖的作业现在可以正常启动,而不再失败。

### Lance Sink:BIGINT 列创建为 int64

- **行为变更:Lance Sink 创建的数据集中,`BIGINT` 列为 Arrow `int64`**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import org.apache.seatunnel.shade.org.apache.commons.lang3.StringUtils;

import java.util.Locale;

/** Used to identify a plugin. */
public class PluginIdentifier {
private final String engineType;
Expand Down Expand Up @@ -69,9 +71,13 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
int result = engineType != null ? engineType.toLowerCase().hashCode() : 0;
result = 31 * result + (pluginType != null ? pluginType.toLowerCase().hashCode() : 0);
result = 31 * result + (pluginName != null ? pluginName.toLowerCase().hashCode() : 0);
int result = engineType != null ? engineType.toLowerCase(Locale.ROOT).hashCode() : 0;
result =
31 * result
+ (pluginType != null ? pluginType.toLowerCase(Locale.ROOT).hashCode() : 0);
result =
31 * result
+ (pluginName != null ? pluginName.toLowerCase(Locale.ROOT).hashCode() : 0);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.seatunnel.common.constants.MetaLakeType;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.function.Supplier;

Expand All @@ -38,23 +39,23 @@ public class MetaLakeFactory {
private MetaLakeFactory() {}

public static void register(String type) {
CLIENT_REGISTRY.put(type.toLowerCase(), GravitinoClient::new);
MAPPER_REGISTRY.put(type.toLowerCase(), GravitinoTableSchemaConvertor::new);
CLIENT_REGISTRY.put(type.toLowerCase(Locale.ROOT), GravitinoClient::new);
MAPPER_REGISTRY.put(type.toLowerCase(Locale.ROOT), GravitinoTableSchemaConvertor::new);
}

public static MetalakeClient createClient(MetaLakeType metaLakeType) {
String type = metaLakeType.name().toLowerCase();
Supplier<MetalakeClient> constructor = CLIENT_REGISTRY.get(type.toLowerCase());
String type = metaLakeType.name().toLowerCase(Locale.ROOT);
Supplier<MetalakeClient> constructor = CLIENT_REGISTRY.get(type.toLowerCase(Locale.ROOT));
if (constructor == null) {
throw new IllegalArgumentException("Unknown MetalakeClient type: " + type);
}
return constructor.get();
}

public static MetaLakeTableSchemaConvertor createTypeMapper(MetaLakeType metaLakeType) {
String type = metaLakeType.name().toLowerCase();
String type = metaLakeType.name().toLowerCase(Locale.ROOT);
Supplier<MetaLakeTableSchemaConvertor> constructor =
MAPPER_REGISTRY.get(type.toLowerCase());
MAPPER_REGISTRY.get(type.toLowerCase(Locale.ROOT));
if (constructor == null) {
throw new IllegalArgumentException("Unknown MetaLakeTypeMapper type: " + type);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;

@Deprecated
Expand All @@ -54,21 +55,24 @@ public static Config getMetalakeConfig(Config jobConfigTmp) {
.getOrDefault(
EnvCommonOptions.METALAKE_ENABLED
.key()
.toUpperCase(),
.toUpperCase(Locale.ROOT),
Boolean.toString(false)));
if (!metalakeEnabled) return jobConfigTmp;

Config update = jobConfigTmp;
String metalakeType =
envConfig.hasPath(EnvCommonOptions.METALAKE_TYPE.key())
? envConfig.getString(EnvCommonOptions.METALAKE_TYPE.key())
: System.getenv(EnvCommonOptions.METALAKE_TYPE.key().toUpperCase());
: System.getenv(
EnvCommonOptions.METALAKE_TYPE.key().toUpperCase(Locale.ROOT));
String metalakeUrl =
envConfig.hasPath(EnvCommonOptions.METALAKE_URL.key())
? envConfig.getString(EnvCommonOptions.METALAKE_URL.key())
: System.getenv(EnvCommonOptions.METALAKE_URL.key().toUpperCase());
: System.getenv(
EnvCommonOptions.METALAKE_URL.key().toUpperCase(Locale.ROOT));
MetalakeClient metalakeClient =
MetaLakeFactory.createClient(MetaLakeType.valueOf(metalakeType.toUpperCase()));
MetaLakeFactory.createClient(
MetaLakeType.valueOf(metalakeType.toUpperCase(Locale.ROOT)));
update =
replaceConfigList(update, PluginType.SOURCE.getType(), metalakeClient, metalakeUrl);
update = replaceConfigList(update, PluginType.SINK.getType(), metalakeClient, metalakeUrl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -202,7 +203,7 @@ private SeaTunnelDataType<?> convertComplexType(String fieldName, JsonNode typeN
throw CommonError.convertToSeaTunnelTypeError(
MetaLakeType.GRAVITINO.getType(), typeNode.toString(), fieldName);
}
String type = typeField.asText().toLowerCase();
String type = typeField.asText().toLowerCase(Locale.ROOT);
switch (type) {
case "list":
JsonNode elementType = typeNode.get(ELEMENT_TYPE);
Expand Down Expand Up @@ -270,7 +271,7 @@ private SeaTunnelDataType<?> convertComplexType(String fieldName, JsonNode typeN
/** Convert simple type (string like "boolean", "integer", "decimal(10,2)", etc.). */
private SeaTunnelDataType<?> convertSimpleType(String fieldName, JsonNode typeNode) {
String gravitinoType = typeNode.asText();
String normalizedType = gravitinoType.trim().toLowerCase();
String normalizedType = gravitinoType.trim().toLowerCase(Locale.ROOT);
// Remove parameters for simple type matching
String baseType = normalizedType.split("\\(")[0].trim();

Expand Down Expand Up @@ -346,7 +347,7 @@ private SeaTunnelDataType<?> convertSimpleType(String fieldName, JsonNode typeNo
*/
private Pair<Long, Integer> extractLengthAndScale(String type) {
// Extract base type before the parenthesis
String baseType = type.split("\\(")[0].trim().toLowerCase();
String baseType = type.split("\\(")[0].trim().toLowerCase(Locale.ROOT);
// Remove 'unsigned' suffix for type matching
String cleanType = baseType.replaceAll("unsigned", "").trim();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.common;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Locale;

public class PluginIdentifierTest {

@Test
public void testEqualsIgnoresCase() {
Assertions.assertEquals(
PluginIdentifier.of("SeaTunnel", "Source", "TiDB"),
PluginIdentifier.of("seatunnel", "source", "tidb"));
Assertions.assertNotEquals(
PluginIdentifier.of("seatunnel", "source", "tidb"),
PluginIdentifier.of("seatunnel", "source", "mysql"));
}

@Test
public void testHashCodeIsIndependentOfDefaultLocale() {
Locale defaultLocale = Locale.getDefault();
try {
// In a Turkish or Azerbaijani locale an upper-case "I" lower-cases to
// a dotless "i", so a locale dependent hash code would differ from the
// hash code of an equal identifier.
Locale.setDefault(Locale.forLanguageTag("tr-TR"));
PluginIdentifier identifier = PluginIdentifier.of("SeaTunnel", "Source", "Iceberg");
PluginIdentifier sameIdentifier = PluginIdentifier.of("seatunnel", "source", "iceberg");
Assertions.assertEquals(identifier, sameIdentifier);
Assertions.assertEquals(identifier.hashCode(), sameIdentifier.hashCode());
} finally {
Locale.setDefault(defaultLocale);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* 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.metalake;

import org.apache.seatunnel.shade.com.typesafe.config.Config;
import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;

import org.apache.seatunnel.api.options.EnvCommonOptions;
import org.apache.seatunnel.common.Constants;
import org.apache.seatunnel.common.constants.MetaLakeType;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.util.Locale;

public class MetalakeLocaleTest {

private static final String JOB_CONFIG =
"env {\n"
+ " metalake_enabled = true\n"
+ " metalake_type = \"gravitino\"\n"
+ " metalake_url = \"http://localhost:8090/api/metalakes/test/\"\n"
+ "}\n"
+ "source = []\n"
+ "sink = []\n"
+ "transform = []\n";

@Test
public void testCreateTypeMapperIsIndependentOfDefaultLocale() {
Locale defaultLocale = Locale.getDefault();
try {
// The registry is keyed by the lower-cased type name while the lookup
// lower-cases the enum constant name, so a locale dependent conversion
// would not find the registered entry.
Locale.setDefault(Locale.forLanguageTag("tr-TR"));
Assertions.assertNotNull(MetaLakeFactory.createTypeMapper(MetaLakeType.GRAVITINO));
} finally {
Locale.setDefault(defaultLocale);
}
}

@Test
public void testGetMetalakeConfigIsIndependentOfDefaultLocale() {
Locale defaultLocale = Locale.getDefault();
try {
// The configured type name "gravitino" upper-cases to "GRAVİTİNO" in a
// Turkish locale, which is not a MetaLakeType constant.
Locale.setDefault(Locale.forLanguageTag("tr-TR"));
Config config = ConfigFactory.parseString(JOB_CONFIG);
Config metalakeConfig = MetalakeConfigUtils.getMetalakeConfig(config);
Assertions.assertNotNull(metalakeConfig);
// The env block must survive the conversion untouched.
Config envConfig = metalakeConfig.getConfig(Constants.ENV);
Assertions.assertTrue(envConfig.getBoolean(EnvCommonOptions.METALAKE_ENABLED.key()));
Assertions.assertEquals(
"gravitino", envConfig.getString(EnvCommonOptions.METALAKE_TYPE.key()));
Assertions.assertEquals(
"http://localhost:8090/api/metalakes/test/",
envConfig.getString(EnvCommonOptions.METALAKE_URL.key()));
} finally {
Locale.setDefault(defaultLocale);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.junit.jupiter.api.Test;

import java.util.List;
import java.util.Locale;

public class GravitinoTableSchemaConvertorTest {

Expand Down Expand Up @@ -963,4 +964,24 @@ void testBuildCatalogTableWithPostgresMetadata() throws Exception {
Assertions.assertEquals("all_type", catalogTable.getTableId().getTableName());
Assertions.assertEquals(tableSchema, catalogTable.getTableSchema());
}

@Test
void testConvertTypeIsIndependentOfDefaultLocale() throws Exception {
Locale defaultLocale = Locale.getDefault();
try {
// In a Turkish or Azerbaijani locale an upper-case "I" is lower-cased to
// a dotless "i" (U+0131), so a locale dependent conversion would not match
// the type name below.
Locale.setDefault(Locale.forLanguageTag("tr-TR"));
String json =
"{\"columns\":[{\"name\":\"int_col\",\"type\":\"INTEGER\",\"nullable\":true}]}";
JsonNode metaInfo = OBJECT_MAPPER.readTree(json);
TableSchema schema = CONVERTOR.convertor(metaInfo);
Column column = schema.getColumns().get(0);
Assertions.assertEquals("int_col", column.getName());
Assertions.assertEquals(BasicType.INT_TYPE, column.getDataType());
} finally {
Locale.setDefault(defaultLocale);
}
}
}
Loading