This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 8e83bba34a0 Rename MySQLSQLFederationColumnTypeConverter (#37309)
8e83bba34a0 is described below
commit 8e83bba34a08e0bb881d263c4698d5f97ed65ed3
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Dec 9 13:06:50 2025 +0800
Rename MySQLSQLFederationColumnTypeConverter (#37309)
* Rename MySQLSQLFederationColumnTypeConverter
* Rename MySQLSQLFederationColumnTypeConverter
* Rename MySQLSQLFederationColumnTypeConverter
* Rename MySQLSQLFederationColumnTypeConverter
* Rename MySQLSQLFederationColumnTypeConverter
---
... => MySQLSQLFederationColumnTypeConverter.java} | 4 +-
...tset.converter.SQLFederationColumnTypeConverter | 2 +-
.../MySQLSQLFederationColumnTypeConverterTest.java | 69 ++++++++++++++++++++++
3 files changed, 72 insertions(+), 3 deletions(-)
diff --git
a/kernel/sql-federation/dialect/mysql/src/main/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLColumnTypeConverter.java
b/kernel/sql-federation/dialect/mysql/src/main/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLSQLFederationColumnTypeConverter.java
similarity index 91%
rename from
kernel/sql-federation/dialect/mysql/src/main/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLColumnTypeConverter.java
rename to
kernel/sql-federation/dialect/mysql/src/main/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLSQLFederationColumnTypeConverter.java
index 6de9991e7ac..70047c030ad 100644
---
a/kernel/sql-federation/dialect/mysql/src/main/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLColumnTypeConverter.java
+++
b/kernel/sql-federation/dialect/mysql/src/main/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLSQLFederationColumnTypeConverter.java
@@ -21,9 +21,9 @@ import org.apache.calcite.sql.type.SqlTypeName;
import
org.apache.shardingsphere.sqlfederation.resultset.converter.SQLFederationColumnTypeConverter;
/**
- * Column type converter for MySQL.
+ * SQL federation column type converter for MySQL.
*/
-public final class MySQLColumnTypeConverter implements
SQLFederationColumnTypeConverter {
+public final class MySQLSQLFederationColumnTypeConverter implements
SQLFederationColumnTypeConverter {
@Override
public Object convertColumnValue(final Object columnValue) {
diff --git
a/kernel/sql-federation/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.sqlfederation.resultset.converter.SQLFederationColumnTypeConverter
b/kernel/sql-federation/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.sqlfederation.resultset.converter.SQLFederationColumnTypeConverter
index a344a512e58..a54cd53f1db 100644
---
a/kernel/sql-federation/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.sqlfederation.resultset.converter.SQLFederationColumnTypeConverter
+++
b/kernel/sql-federation/dialect/mysql/src/main/resources/META-INF/services/org.apache.shardingsphere.sqlfederation.resultset.converter.SQLFederationColumnTypeConverter
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.sqlfederation.mysql.MySQLColumnTypeConverter
+org.apache.shardingsphere.sqlfederation.mysql.MySQLSQLFederationColumnTypeConverter
diff --git
a/kernel/sql-federation/dialect/mysql/src/test/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLSQLFederationColumnTypeConverterTest.java
b/kernel/sql-federation/dialect/mysql/src/test/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLSQLFederationColumnTypeConverterTest.java
new file mode 100644
index 00000000000..2c967cd1776
--- /dev/null
+++
b/kernel/sql-federation/dialect/mysql/src/test/java/org/apache/shardingsphere/sqlfederation/mysql/MySQLSQLFederationColumnTypeConverterTest.java
@@ -0,0 +1,69 @@
+/*
+ * 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.shardingsphere.sqlfederation.mysql;
+
+import org.apache.calcite.sql.type.SqlTypeName;
+import
org.apache.shardingsphere.database.connector.core.spi.DatabaseTypedSPILoader;
+import org.apache.shardingsphere.database.connector.core.type.DatabaseType;
+import org.apache.shardingsphere.infra.spi.type.typed.TypedSPILoader;
+import
org.apache.shardingsphere.sqlfederation.resultset.converter.SQLFederationColumnTypeConverter;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
+import java.util.Arrays;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+class MySQLSQLFederationColumnTypeConverterTest {
+
+ private final SQLFederationColumnTypeConverter converter =
DatabaseTypedSPILoader.getService(SQLFederationColumnTypeConverter.class,
TypedSPILoader.getService(DatabaseType.class, "MySQL"));
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("convertValueSource")
+ void assertConvertColumnValue(final String name, final Object input, final
Object expected) {
+ if (null == expected) {
+ assertNull(converter.convertColumnValue(input));
+ return;
+ }
+ assertThat(converter.convertColumnValue(input), is(expected));
+ }
+
+ @ParameterizedTest(name = "{0}")
+ @MethodSource("convertTypeSource")
+ void assertConvertColumnType(final String name, final SqlTypeName
sqlTypeName, final int expected) {
+ assertThat(converter.convertColumnType(sqlTypeName), is(expected));
+ }
+
+ private static Iterable<Arguments> convertValueSource() {
+ return Arrays.asList(
+ Arguments.arguments("booleanTrueConvertedToOne", Boolean.TRUE,
1),
+ Arguments.arguments("booleanFalseConvertedToZero",
Boolean.FALSE, 0),
+ Arguments.arguments("nonBooleanValueUntouched", "text",
"text"),
+ Arguments.arguments("nullRemainsNull", null, null));
+ }
+
+ private static Iterable<Arguments> convertTypeSource() {
+ return Arrays.asList(
+ Arguments.arguments("booleanMapsToVarchar",
SqlTypeName.BOOLEAN, SqlTypeName.VARCHAR.getJdbcOrdinal()),
+ Arguments.arguments("anyMapsToVarchar", SqlTypeName.ANY,
SqlTypeName.VARCHAR.getJdbcOrdinal()),
+ Arguments.arguments("otherTypesUnchanged",
SqlTypeName.INTEGER, SqlTypeName.INTEGER.getJdbcOrdinal()));
+ }
+}