@@ -272,6 +272,22 @@ static <T extends ProtocolMessageEnum> SqlType.Enum<T> enumOf(Function<Integer,
272272 return Type .Enum .create (method );
273273 }
274274
275+ /**
276+ * Extracts the unqualified name from a fully qualified proto message or enum name. For example,
277+ * "my.package.MyMessage" becomes "MyMessage".
278+ *
279+ * <p>This is considered an internal implementation detail and not meant to be used by
280+ * applications.
281+ */
282+ @ InternalApi
283+ static String getUnqualifiedName (String fullName ) {
284+ if (fullName == null || fullName .isEmpty ()) {
285+ return "" ;
286+ }
287+ int lastDotIndex = fullName .lastIndexOf ('.' );
288+ return (lastDotIndex == -1 ) ? fullName : fullName .substring (lastDotIndex + 1 );
289+ }
290+
275291 /**
276292 * Creates a {@link SqlType} from the protobuf representation of Types.
277293 *
@@ -327,16 +343,6 @@ static SqlType<?> fromProto(com.google.bigtable.v2.Type proto) {
327343 */
328344 @ InternalApi
329345 static boolean typesMatch (SqlType <?> left , SqlType <?> right ) {
330- Function <String , String > getUnqualifiedMessageName =
331- fullMessageName -> {
332- if (fullMessageName == null || fullMessageName .isEmpty ()) {
333- return "" ;
334- }
335- int lastDotIndex = fullMessageName .lastIndexOf ('.' );
336- return (lastDotIndex == -1 )
337- ? fullMessageName
338- : fullMessageName .substring (lastDotIndex + 1 );
339- };
340346 switch (left .getCode ()) {
341347 case BYTES :
342348 case STRING :
@@ -359,9 +365,8 @@ static boolean typesMatch(SqlType<?> left, SqlType<?> right) {
359365 return left .equals (right );
360366 }
361367 // Compares mixed SchemalessProto and Proto
362- return getUnqualifiedMessageName
363- .apply (((SqlType .Proto ) left ).getMessageName ())
364- .equals (getUnqualifiedMessageName .apply (((SqlType .Proto ) right ).getMessageName ()));
368+ return getUnqualifiedName (((SqlType .Proto ) left ).getMessageName ())
369+ .equals (getUnqualifiedName (((SqlType .Proto ) right ).getMessageName ()));
365370 }
366371 case ENUM :
367372 {
@@ -375,9 +380,8 @@ static boolean typesMatch(SqlType<?> left, SqlType<?> right) {
375380 return left .equals (right );
376381 }
377382 // Compares mixed SchemalessEnum and Enum
378- return getUnqualifiedMessageName
379- .apply (((SqlType .Enum ) left ).getEnumName ())
380- .equals (getUnqualifiedMessageName .apply (((SqlType .Enum ) right ).getEnumName ()));
383+ return getUnqualifiedName (((SqlType .Enum ) left ).getEnumName ())
384+ .equals (getUnqualifiedName (((SqlType .Enum ) right ).getEnumName ()));
381385 }
382386 case STRUCT :
383387 // Don't validate fields since the field types will be validated on
0 commit comments