Copilot commented on code in PR #18606: URL: https://github.com/apache/iotdb/pull/18606#discussion_r3965396128
########## iotdb-client/isession/src/main/java/org/apache/iotdb/isession/TypeServices.java: ########## @@ -0,0 +1,65 @@ +/* + * 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.iotdb.isession; + +import org.apache.iotdb.rpc.IoTDBRpcDataSet; +import org.apache.iotdb.rpc.StatementExecutionException; + +import org.apache.tsfile.read.common.Field; +import org.apache.tsfile.read.common.type.service.TypeService; +import org.apache.tsfile.write.UnSupportedDataTypeException; + +/** Type-specific RPC result readers that preserve primitive access without intermediate boxing. */ +final class TypeServices { + + static final TypeService<FieldValueReader> FIELD_VALUE_READER_SERVICE = + type -> + switch (type.getTypeEnum()) { + case BOOLEAN -> + (dataSet, columnIndex, field) -> field.setBoolV(dataSet.getBoolean(columnIndex)); + case INT32, DATE -> + (dataSet, columnIndex, field) -> field.setIntV(dataSet.getInt(columnIndex)); + case INT64, TIMESTAMP -> + (dataSet, columnIndex, field) -> field.setLongV(dataSet.getLong(columnIndex)); + case FLOAT -> + (dataSet, columnIndex, field) -> field.setFloatV(dataSet.getFloat(columnIndex)); + case DOUBLE -> + (dataSet, columnIndex, field) -> field.setDoubleV(dataSet.getDouble(columnIndex)); + case TEXT, BLOB, STRING, OBJECT -> + (dataSet, columnIndex, field) -> field.setBinaryV(dataSet.getBinary(columnIndex)); + case ROW, UNKNOWN, VECTOR -> + (dataSet, columnIndex, field) -> { + throw new UnSupportedDataTypeException( + String.format("Data type %s is not supported.", type.getTypeEnum())); Review Comment: This user-visible exception bypasses the module's English/Chinese message bundles, so Chinese-locale builds will still emit English. Add a matching constant to both `ISessionMessages` locale files and reference it here. ########## iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeMiscMessages.java: ########## @@ -603,6 +603,10 @@ private DataNodeMiscMessages() {} public static final String INPUT_DOUBLE_INFINITY = "The input double value is Infinity"; public static final String BOOLEAN_PARSE_ERROR = "The BOOLEAN should be true/TRUE, false/FALSE or 0/1"; + public static final String DATA_TYPE_NOT_CONSISTENT_FMT = + "data type is not consistent, input %s, registered %s"; + public static final String DATA_TYPE_NOT_CONSISTENT_WITH_CAUSE_FMT = + "data type is not consistent, input %s, registered %s because %s"; Review Comment: These new exception message keys do not follow the repository's generated exception-message naming convention. Rename them consistently in both locale files and update their call sites. ########## iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodePipeMessages.java: ########## @@ -1541,6 +1541,12 @@ public final class DataNodePipeMessages { public static final String FAILED_TO_UNBIND_FROM_PIPE_TSFILE_TO = "Failed to unbind from pipe tsfile to tablets metrics, pipe map is not empty, pipe: {}"; + // --------------------------------------------------------------------------- + // pipe – PipeRow + // --------------------------------------------------------------------------- + public static final String UNSUPPORTED_DATA_TYPE_FOR_COLUMN_FMT = + "unsupported data type %s for column %s"; Review Comment: This new exception message key does not follow the repository's generated exception-message naming convention. Rename it consistently in both locale files and update its call sites. ########## iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java: ########## @@ -1393,6 +1407,8 @@ public final class DataNodeQueryMessages { "Error occurred during getting UDF access strategy"; public static final String TRANSFORMUTILS_SHOULD_NOT_BE_INSTANTIATED = "TransformUtils should not be instantiated."; + public static final String INVALID_DATA_TYPE_FOR_STATE_WINDOW_STRATEGY = + "The data type of the state window strategy is not valid."; Review Comment: This new exception message key does not follow the repository's generated naming convention. Rename it consistently in both locale files and update its call sites. ########## iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java: ########## @@ -1020,6 +1032,8 @@ public final class DataNodeQueryMessages { "Unexpected expression: "; public static final String FAILED_TO_FETCH_SUBQUERY_RESULT = "Failed to Fetch Subquery Result."; + public static final String UNSUPPORTED_SCALAR_SUBQUERY_RESULT_DATA_TYPE_FMT = + "Unsupported data type for scalar subquery result: %s"; Review Comment: This new exception message key does not follow the repository's generated naming convention. Rename it consistently in both locale files and update its call sites. ########## library-udf/src/main/i18n/en/org/apache/iotdb/library/i18n/LibraryUdfMessages.java: ########## @@ -60,6 +60,9 @@ public final class LibraryUdfMessages { public static final String ALL_VALUES_ARE_NAN = "All values are NaN"; // UDFEnvelopeAnalysis + public static final String FREQUENCY_MUST_BE_POSITIVE = "The param 'frequency' must > 0."; + public static final String AMPLIFICATION_MUST_BE_AT_LEAST_1 = + "The param 'amplification' must >= 1."; Review Comment: The English validation text is ungrammatical. Use “must be greater than” / “must be greater than or equal to” so the errors read clearly to users. ########## iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TSDataTypeSwitchArchitectureTest.java: ########## @@ -0,0 +1,39 @@ +/* + * 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.iotdb.db.utils; + +import com.tngtech.archunit.core.importer.ClassFileImporter; +import com.tngtech.archunit.core.importer.ImportOption; +import org.junit.Test; + +public class TSDataTypeSwitchArchitectureTest { + + @Test + public void productionCodeMustUseTypeService() { + // Scan IoTDB production classes on this module's classpath, including its dependencies. + // Do not freeze violations or swallow failures: existing violations must fail this test too. + TSDataTypeSwitchRule.RULE.check( + new ClassFileImporter() + .withImportOption(new ImportOption.DoNotIncludeTests()) + // Avoid building the entire server dependency graph: only switch owners need checking. + .withImportOption(location -> TSDataTypeSwitchRule.hasSwitch(location.asURI())) + .importPackages("org.apache.iotdb")); Review Comment: This check only imports production classes visible from the datanode test classpath, so it does not enforce the stated repository-wide rule in modules such as `library-udf`, JDBC, or examples. A future `TSDataType` switch in an unreferenced module will pass; place equivalent checks in each independent module or run the rule from an aggregate test classpath. ########## library-udf/src/main/i18n/en/org/apache/iotdb/library/i18n/LibraryUdfMessages.java: ########## @@ -100,6 +103,16 @@ public final class LibraryUdfMessages { // UDAFPatternMatch, UDAFDTWMatch public static final String UNSUPPORTED_DATATYPE = "Unsupported datatype %s"; + // ExactOrderStatistics + public static final String UNSUPPORTED_DATA_TYPE = "Unsupported data type: %s"; + + // UDAFQuantile + public static final String UNSUPPORTED_DATA_TYPE_IN_QUANTILE = "Unsupported data type"; Review Comment: These newly added message keys also use ad hoc names rather than the repository's generated exception-message naming convention. Rename them consistently in both locale files and update their call sites. ########## library-udf/src/main/i18n/en/org/apache/iotdb/library/i18n/LibraryUdfMessages.java: ########## @@ -60,6 +60,9 @@ public final class LibraryUdfMessages { public static final String ALL_VALUES_ARE_NAN = "All values are NaN"; // UDFEnvelopeAnalysis + public static final String FREQUENCY_MUST_BE_POSITIVE = "The param 'frequency' must > 0."; + public static final String AMPLIFICATION_MUST_BE_AT_LEAST_1 = + "The param 'amplification' must >= 1."; Review Comment: These newly introduced message keys do not follow the repository's generated exception-message naming convention (prefix plus normalized text and hash). Rename the new keys consistently in both locale files and their call sites to avoid collisions and keep generated message keys uniform. ########## library-udf/src/main/i18n/en/org/apache/iotdb/library/i18n/LibraryUdfMessages.java: ########## @@ -100,6 +103,16 @@ public final class LibraryUdfMessages { // UDAFPatternMatch, UDAFDTWMatch public static final String UNSUPPORTED_DATATYPE = "Unsupported datatype %s"; + // ExactOrderStatistics + public static final String UNSUPPORTED_DATA_TYPE = "Unsupported data type: %s"; + + // UDAFQuantile + public static final String UNSUPPORTED_DATA_TYPE_IN_QUANTILE = "Unsupported data type"; + public static final String QUANTILE_K_MUST_BE_AT_LEAST_100 = + "Size K has to be greater than or equal to 100."; + public static final String QUANTILE_RANK_MUST_BE_IN_RANGE = + "rank has to be greater than 0 and less than or equal to 1."; Review Comment: These newly added validation-message keys do not follow the repository's generated exception-message naming convention. Rename them consistently in both locale files and update their call sites. ########## iotdb-core/datanode/src/main/i18n/en/org/apache/iotdb/db/i18n/DataNodeQueryMessages.java: ########## @@ -528,6 +528,18 @@ public final class DataNodeQueryMessages { "TIMESTAMP does not support REGEXP/NOT REGEXP"; public static final String GROUPBYTIME_FILTER_CANNOT_EXIST_IN_VALUE_FILTER = "GroupByTime filter cannot exist in value filter."; + public static final String VALUE_CANNOT_BE_CAST_TO_DATA_TYPE_FMT = + "\"%s\" cannot be cast to [%s]"; + public static final String UNSUPPORTED_DATA_TYPE_FMT = + "Unsupported data type %s"; Review Comment: The new message keys use ad hoc `_FMT` names instead of the repository's generated exception-message naming convention. Rename all newly added keys in this block consistently in both locale files and their call sites. This issue also appears in the following locations of the same file: - line 535 - line 539 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
