Copilot commented on code in PR #18870: URL: https://github.com/apache/pinot/pull/18870#discussion_r3548076046
########## pinot-segment-local/src/test/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImplUuidPrimaryKeyTest.java: ########## @@ -0,0 +1,89 @@ +/** + * 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.pinot.segment.local.indexsegment.mutable; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import org.apache.pinot.spi.data.FieldSpec; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.data.readers.GenericRow; +import org.apache.pinot.spi.data.readers.PrimaryKey; +import org.apache.pinot.spi.utils.ByteArray; +import org.apache.pinot.spi.utils.UuidUtils; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + + +/** + * Regression tests for UUID primary-key normalization during realtime upsert ingestion. + */ Review Comment: The class-level Javadoc says this covers "realtime upsert ingestion", but this test is exercising `MutableSegmentImpl#getPrimaryKey` directly (via reflection) without going through the record-transformer path that now rejects non-canonical UUID PK strings for upsert/dedup tables. Updating the Javadoc to describe the actual unit under test will avoid confusion with `DataTypeTransformerTest#testUuidUpsertPrimaryKeyCanonicalValidation`. ########## pinot-segment-local/src/test/java/org/apache/pinot/segment/local/indexsegment/mutable/MutableSegmentImplUuidPrimaryKeyTest.java: ########## @@ -0,0 +1,89 @@ +/** + * 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.pinot.segment.local.indexsegment.mutable; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.List; +import org.apache.pinot.spi.data.FieldSpec; +import org.apache.pinot.spi.data.Schema; +import org.apache.pinot.spi.data.readers.GenericRow; +import org.apache.pinot.spi.data.readers.PrimaryKey; +import org.apache.pinot.spi.utils.ByteArray; +import org.apache.pinot.spi.utils.UuidUtils; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + + +/** + * Regression tests for UUID primary-key normalization during realtime upsert ingestion. + */ +public class MutableSegmentImplUuidPrimaryKeyTest { + private static final String UUID_PK_COLUMN = "uuidPk"; + private static final String VALUE_COLUMN = "payload"; + private static final String TIME_COLUMN = "ts"; + private static final String UUID_VALUE = "550e8400-e29b-41d4-a716-446655440000"; + + private static final Schema SCHEMA = new Schema.SchemaBuilder() + .addSingleValueDimension(UUID_PK_COLUMN, FieldSpec.DataType.UUID) + .addSingleValueDimension(VALUE_COLUMN, FieldSpec.DataType.STRING) + .addDateTimeField(TIME_COLUMN, FieldSpec.DataType.LONG, "1:MILLISECONDS:EPOCH", "1:MILLISECONDS") + .setPrimaryKeyColumns(List.of(UUID_PK_COLUMN)) + .build(); + + private MutableSegmentImpl _segment; + + @AfterMethod + public void tearDown() { + if (_segment != null) { + _segment.destroy(); + _segment = null; + } + } + + @Test + public void testUpsertPrimaryKeyNormalizesMixedCaseUuidStrings() + throws ReflectiveOperationException { + _segment = MutableSegmentImplTestUtils.createMutableSegmentImpl(SCHEMA, false, TIME_COLUMN, null, null); Review Comment: The method name implies an end-to-end upsert ingestion behavior, but the test is specifically about `MutableSegmentImpl#getPrimaryKey` normalization. Renaming the test to reflect the unit under test will make it clearer (and avoid conflicting with the separate canonical-PK rejection test in `DataTypeTransformerTest`). -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
