func()

in table/internal/parquet_files.go [103:158]


func (p parquetFormat) createStatsAgg(typ iceberg.PrimitiveType, physicalTypeStr string, truncLen int) (StatsAgg, error) {
	expectedPhysical := p.PrimitiveTypeToPhysicalType(typ)
	if physicalTypeStr != expectedPhysical {
		switch {
		case physicalTypeStr == "INT32" && expectedPhysical == "INT64":
		case physicalTypeStr == "FLOAT" && expectedPhysical == "DOUBLE":
		default:
			return nil, fmt.Errorf("unexpected physical type %s for %s, expected %s",
				physicalTypeStr, typ, expectedPhysical)
		}
	}

	switch physicalTypeStr {
	case "BOOLEAN":
		return newStatAgg[bool](typ, truncLen), nil
	case "INT32":
		switch typ.(type) {
		case iceberg.DecimalType:
			return &decAsIntAgg[int32]{
				newStatAgg[int32](typ, truncLen).(*statsAggregator[int32]),
			}, nil
		}

		return newStatAgg[int32](typ, truncLen), nil
	case "INT64":
		switch typ.(type) {
		case iceberg.DecimalType:
			return &decAsIntAgg[int64]{
				newStatAgg[int64](typ, truncLen).(*statsAggregator[int64]),
			}, nil
		}

		return newStatAgg[int64](typ, truncLen), nil
	case "FLOAT":
		return newStatAgg[float32](typ, truncLen), nil
	case "DOUBLE":
		return newStatAgg[float64](typ, truncLen), nil
	case "FIXED_LEN_BYTE_ARRAY":
		switch typ.(type) {
		case iceberg.UUIDType:
			return newStatAgg[uuid.UUID](typ, truncLen), nil
		case iceberg.DecimalType:
			return newStatAgg[iceberg.Decimal](typ, truncLen), nil
		default:
			return newStatAgg[[]byte](typ, truncLen), nil
		}
	case "BYTE_ARRAY":
		if typ.Equals(iceberg.PrimitiveTypes.String) {
			return newStatAgg[string](typ, truncLen), nil
		}

		return newStatAgg[[]byte](typ, truncLen), nil
	default:
		return nil, fmt.Errorf("unsupported physical type: %s", physicalTypeStr)
	}
}