@@ -286,6 +286,68 @@ public void testMixedHyphenatedAndNormalFieldNames()
286286 }
287287 }
288288
289+ /**
290+ * End-to-end test that writes to an Iceberg table with hyphenated struct fields
291+ * and reads it back, verifying the complete write→read cycle works correctly.
292+ * This test validates the full integration of:
293+ * 1. PrimitiveTypeMapBuilder.makeCompatibleName() for writing hex-encoded field names
294+ * 2. ColumnIOConverter.constructField() for reading with makeCompatibleName()
295+ * 3. IcebergPageSourceProvider.getColumnType() for SYNTHESIZED column handling
296+ */
297+ @ Test
298+ public void testEndToEndWriteReadWithHyphenatedStructFields ()
299+ {
300+ String tableName = "test_e2e_hyphenated_struct" ;
301+ try {
302+ // Create table with multiple hyphenated fields in struct
303+ assertUpdate ("CREATE TABLE " + tableName + " (" +
304+ "id INT, " +
305+ "application ROW(" +
306+ " \" aws-region\" VARCHAR, " +
307+ " \" user-id\" INT, " +
308+ " \" data-center\" VARCHAR, " +
309+ " \" zone-id\" INT, " +
310+ " normal_field VARCHAR" +
311+ ")" +
312+ ")" );
313+
314+ // Write data - tests PrimitiveTypeMapBuilder.makeCompatibleName()
315+ assertUpdate ("INSERT INTO " + tableName + " VALUES " +
316+ "(1, ROW('us-west-2', 1001, 'dc-west-01', 100, 'normal1')), " +
317+ "(2, ROW('eu-central-1', 1002, 'dc-eu-01', 200, 'normal2')), " +
318+ "(3, ROW('ap-south-1', 1003, 'dc-ap-01', 300, 'normal3'))" , 3 );
319+
320+ // Read back - tests ColumnIOConverter.constructField() with makeCompatibleName()
321+ // Test individual field access (SYNTHESIZED path)
322+ assertQuery (
323+ "SELECT id, application.\" aws-region\" , application.\" user-id\" , application.\" data-center\" FROM " + tableName ,
324+ "VALUES (1, 'us-west-2', 1001, 'dc-west-01'), " +
325+ "(2, 'eu-central-1', 1002, 'dc-eu-01'), " +
326+ "(3, 'ap-south-1', 1003, 'dc-ap-01')" );
327+
328+ // Test all fields including normal field
329+ assertQuery (
330+ "SELECT application.\" aws-region\" , application.\" user-id\" , application.\" data-center\" , " +
331+ "application.\" zone-id\" , application.normal_field FROM " + tableName ,
332+ "VALUES ('us-west-2', 1001, 'dc-west-01', 100, 'normal1'), " +
333+ "('eu-central-1', 1002, 'dc-eu-01', 200, 'normal2'), " +
334+ "('ap-south-1', 1003, 'dc-ap-01', 300, 'normal3')" );
335+
336+ // Test with WHERE clause on hyphenated field
337+ assertQuery (
338+ "SELECT id, application.\" aws-region\" FROM " + tableName + " WHERE application.\" user-id\" = 1002" ,
339+ "VALUES (2, 'eu-central-1')" );
340+
341+ // Test with ORDER BY on hyphenated field
342+ assertQuery (
343+ "SELECT id, application.\" zone-id\" FROM " + tableName + " ORDER BY application.\" zone-id\" DESC" ,
344+ "VALUES (3, 300), (2, 200), (1, 100)" );
345+ }
346+ finally {
347+ assertUpdate ("DROP TABLE IF EXISTS " + tableName );
348+ }
349+ }
350+
289351 /**
290352 * Test top level hyphenated column names still work correctly.
291353 * Top level columns use field ID based lookup so they were never broken.
0 commit comments