@@ -281,8 +281,9 @@ impl<'a> PrimitiveTypeBuilder<'a> {
281
281
// Check length before logical type, since it is used for logical type validation.
282
282
if self . physical_type == PhysicalType :: FIXED_LEN_BYTE_ARRAY && self . length < 0 {
283
283
return Err ( general_err ! (
284
- "Invalid FIXED_LEN_BYTE_ARRAY length: {}" ,
285
- self . length
284
+ "Invalid FIXED_LEN_BYTE_ARRAY length: {} for field '{}'" ,
285
+ self . length,
286
+ self . name
286
287
) ) ;
287
288
}
288
289
@@ -295,9 +296,10 @@ impl<'a> PrimitiveTypeBuilder<'a> {
295
296
!= self . converted_type
296
297
{
297
298
return Err ( general_err ! (
298
- "Logical type {:?} is imcompatible with converted type {}" ,
299
+ "Logical type {:?} is incompatible with converted type {} for field '{}' " ,
299
300
logical_type,
300
- self . converted_type
301
+ self . converted_type,
302
+ self . name
301
303
) ) ;
302
304
}
303
305
} else {
@@ -308,25 +310,28 @@ impl<'a> PrimitiveTypeBuilder<'a> {
308
310
match ( logical_type, self . physical_type ) {
309
311
( LogicalType :: Map , _) | ( LogicalType :: List , _) => {
310
312
return Err ( general_err ! (
311
- "{:?} cannot be applied to a primitive type" ,
312
- logical_type
313
+ "{:?} cannot be applied to a primitive type for field '{}'" ,
314
+ logical_type,
315
+ self . name
313
316
) ) ;
314
317
}
315
318
( LogicalType :: Enum , PhysicalType :: BYTE_ARRAY ) => { }
316
319
( LogicalType :: Decimal { scale, precision } , _) => {
317
320
// Check that scale and precision are consistent with legacy values
318
321
if * scale != self . scale {
319
322
return Err ( general_err ! (
320
- "DECIMAL logical type scale {} must match self.scale {}" ,
323
+ "DECIMAL logical type scale {} must match self.scale {} for field '{}' " ,
321
324
scale,
322
- self . scale
325
+ self . scale,
326
+ self . name
323
327
) ) ;
324
328
}
325
329
if * precision != self . precision {
326
330
return Err ( general_err ! (
327
- "DECIMAL logical type precision {} must match self.precision {}" ,
331
+ "DECIMAL logical type precision {} must match self.precision {} for field '{}' " ,
328
332
precision,
329
- self . precision
333
+ self . precision,
334
+ self . name
330
335
) ) ;
331
336
}
332
337
self . check_decimal_precision_scale ( ) ?;
@@ -342,7 +347,8 @@ impl<'a> PrimitiveTypeBuilder<'a> {
342
347
( LogicalType :: Time { unit, .. } , PhysicalType :: INT64 ) => {
343
348
if * unit == TimeUnit :: MILLIS ( Default :: default ( ) ) {
344
349
return Err ( general_err ! (
345
- "Cannot use millisecond unit on INT64 type"
350
+ "Cannot use millisecond unit on INT64 type for field '{}'" ,
351
+ self . name
346
352
) ) ;
347
353
}
348
354
}
@@ -359,9 +365,10 @@ impl<'a> PrimitiveTypeBuilder<'a> {
359
365
( LogicalType :: Uuid , PhysicalType :: FIXED_LEN_BYTE_ARRAY ) => { }
360
366
( a, b) => {
361
367
return Err ( general_err ! (
362
- "Cannot annotate {:?} from {} fields " ,
368
+ "Cannot annotate {:?} from {} for field '{}' " ,
363
369
a,
364
- b
370
+ b,
371
+ self . name
365
372
) )
366
373
}
367
374
}
@@ -374,8 +381,9 @@ impl<'a> PrimitiveTypeBuilder<'a> {
374
381
ConvertedType :: UTF8 | ConvertedType :: BSON | ConvertedType :: JSON => {
375
382
if self . physical_type != PhysicalType :: BYTE_ARRAY {
376
383
return Err ( general_err ! (
377
- "{} can only annotate BYTE_ARRAY fields" ,
378
- self . converted_type
384
+ "{} cannot annotate field '{}' because it is not a BYTE_ARRAY field" ,
385
+ self . converted_type,
386
+ self . name
379
387
) ) ;
380
388
}
381
389
}
@@ -392,8 +400,9 @@ impl<'a> PrimitiveTypeBuilder<'a> {
392
400
| ConvertedType :: INT_32 => {
393
401
if self . physical_type != PhysicalType :: INT32 {
394
402
return Err ( general_err ! (
395
- "{} can only annotate INT32" ,
396
- self . converted_type
403
+ "{} cannot annotate field '{}' because it is not a INT32 field" ,
404
+ self . converted_type,
405
+ self . name
397
406
) ) ;
398
407
}
399
408
}
@@ -404,8 +413,9 @@ impl<'a> PrimitiveTypeBuilder<'a> {
404
413
| ConvertedType :: INT_64 => {
405
414
if self . physical_type != PhysicalType :: INT64 {
406
415
return Err ( general_err ! (
407
- "{} can only annotate INT64" ,
408
- self . converted_type
416
+ "{} cannot annotate field '{}' because it is not a INT64 field" ,
417
+ self . converted_type,
418
+ self . name
409
419
) ) ;
410
420
}
411
421
}
@@ -414,19 +424,21 @@ impl<'a> PrimitiveTypeBuilder<'a> {
414
424
|| self . length != 12
415
425
{
416
426
return Err ( general_err ! (
417
- "INTERVAL can only annotate FIXED_LEN_BYTE_ARRAY(12)"
427
+ "INTERVAL cannot annotate field '{}' because it is not a FIXED_LEN_BYTE_ARRAY(12) field" ,
428
+ self . name
418
429
) ) ;
419
430
}
420
431
}
421
432
ConvertedType :: ENUM => {
422
433
if self . physical_type != PhysicalType :: BYTE_ARRAY {
423
- return Err ( general_err ! ( "ENUM can only annotate BYTE_ARRAY fields" ) ) ;
434
+ return Err ( general_err ! ( "ENUM cannot annotate field '{}' because it is not a BYTE_ARRAY field" , self . name ) ) ;
424
435
}
425
436
}
426
437
_ => {
427
438
return Err ( general_err ! (
428
- "{} cannot be applied to a primitive type" ,
429
- self . converted_type
439
+ "{} cannot be applied to primitive field '{}'" ,
440
+ self . converted_type,
441
+ self . name
430
442
) ) ;
431
443
}
432
444
}
@@ -1258,7 +1270,7 @@ mod tests {
1258
1270
if let Err ( e) = result {
1259
1271
assert_eq ! (
1260
1272
format!( "{}" , e) ,
1261
- "Parquet error: Cannot annotate Integer { bit_width: 8, is_signed: true } from INT64 fields "
1273
+ "Parquet error: Cannot annotate Integer { bit_width: 8, is_signed: true } from INT64 for field 'foo' "
1262
1274
) ;
1263
1275
}
1264
1276
@@ -1271,7 +1283,7 @@ mod tests {
1271
1283
if let Err ( e) = result {
1272
1284
assert_eq ! (
1273
1285
format!( "{}" , e) ,
1274
- "Parquet error: BSON can only annotate BYTE_ARRAY fields "
1286
+ "Parquet error: BSON cannot annotate field 'foo' because it is not a BYTE_ARRAY field "
1275
1287
) ;
1276
1288
}
1277
1289
@@ -1302,7 +1314,7 @@ mod tests {
1302
1314
if let Err ( e) = result {
1303
1315
assert_eq ! (
1304
1316
format!( "{}" , e) ,
1305
- "Parquet error: DECIMAL logical type scale 32 must match self.scale -1"
1317
+ "Parquet error: DECIMAL logical type scale 32 must match self.scale -1 for field 'foo' "
1306
1318
) ;
1307
1319
}
1308
1320
@@ -1419,7 +1431,7 @@ mod tests {
1419
1431
if let Err ( e) = result {
1420
1432
assert_eq ! (
1421
1433
format!( "{}" , e) ,
1422
- "Parquet error: UINT_8 can only annotate INT32"
1434
+ "Parquet error: UINT_8 cannot annotate field 'foo' because it is not a INT32 field "
1423
1435
) ;
1424
1436
}
1425
1437
@@ -1431,7 +1443,7 @@ mod tests {
1431
1443
if let Err ( e) = result {
1432
1444
assert_eq ! (
1433
1445
format!( "{}" , e) ,
1434
- "Parquet error: TIME_MICROS can only annotate INT64"
1446
+ "Parquet error: TIME_MICROS cannot annotate field 'foo' because it is not a INT64 field "
1435
1447
) ;
1436
1448
}
1437
1449
@@ -1443,7 +1455,7 @@ mod tests {
1443
1455
if let Err ( e) = result {
1444
1456
assert_eq ! (
1445
1457
format!( "{}" , e) ,
1446
- "Parquet error: INTERVAL can only annotate FIXED_LEN_BYTE_ARRAY(12)"
1458
+ "Parquet error: INTERVAL cannot annotate field 'foo' because it is not a FIXED_LEN_BYTE_ARRAY(12) field "
1447
1459
) ;
1448
1460
}
1449
1461
@@ -1456,7 +1468,7 @@ mod tests {
1456
1468
if let Err ( e) = result {
1457
1469
assert_eq ! (
1458
1470
format!( "{}" , e) ,
1459
- "Parquet error: INTERVAL can only annotate FIXED_LEN_BYTE_ARRAY(12)"
1471
+ "Parquet error: INTERVAL cannot annotate field 'foo' because it is not a FIXED_LEN_BYTE_ARRAY(12) field "
1460
1472
) ;
1461
1473
}
1462
1474
@@ -1468,7 +1480,7 @@ mod tests {
1468
1480
if let Err ( e) = result {
1469
1481
assert_eq ! (
1470
1482
format!( "{}" , e) ,
1471
- "Parquet error: ENUM can only annotate BYTE_ARRAY fields "
1483
+ "Parquet error: ENUM cannot annotate field 'foo' because it is not a BYTE_ARRAY field "
1472
1484
) ;
1473
1485
}
1474
1486
@@ -1480,7 +1492,7 @@ mod tests {
1480
1492
if let Err ( e) = result {
1481
1493
assert_eq ! (
1482
1494
format!( "{}" , e) ,
1483
- "Parquet error: MAP cannot be applied to a primitive type "
1495
+ "Parquet error: MAP cannot be applied to primitive field 'foo' "
1484
1496
) ;
1485
1497
}
1486
1498
@@ -1493,7 +1505,7 @@ mod tests {
1493
1505
if let Err ( e) = result {
1494
1506
assert_eq ! (
1495
1507
format!( "{}" , e) ,
1496
- "Parquet error: Invalid FIXED_LEN_BYTE_ARRAY length: -1"
1508
+ "Parquet error: Invalid FIXED_LEN_BYTE_ARRAY length: -1 for field 'foo' "
1497
1509
) ;
1498
1510
}
1499
1511
}
0 commit comments