Skip to main content

datafusion_proto_models/
from_proto.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: See the NOTICE file distributed with this work for additional information regarding copyright ownership
3// SPDX-FileContributor: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements
4
5//! Conversions from the protobuf messages in this crate to their
6//! `datafusion-common` counterparts.
7//!
8//! The DataFusion side of these conversions lives *below* this crate in the
9//! dependency graph, so it cannot host the impls itself. They live here
10//! instead, on the local proto type — the same arrangement
11//! `datafusion-proto-common` uses for `ScalarValue` and `Statistics`.
12
13use std::sync::Arc;
14
15use datafusion_common::config::{
16    CsvOptions, JsonOptions, MaxRowGroupBytes, ParquetCdcOptions, ParquetColumnOptions,
17    ParquetOptions, TableParquetOptions,
18};
19use datafusion_common::display::{PlanType, StringifiedPlan};
20use datafusion_common::parquet_config::RowGroupRangeAssignment;
21use datafusion_common::parsers::{CompressionTypeVariant, CsvQuoteStyle};
22use datafusion_common::utils::usize_from_wire;
23use datafusion_common::{
24    JoinConstraint, JoinType, NullEquality, RecursionUnnestOption, TableReference,
25    UnnestOptions,
26};
27use datafusion_proto_common::FromProtoError as Error;
28
29use crate::protobuf::{
30    self, AnalyzedLogicalPlanType, CsvOptions as CsvOptionsProto,
31    CsvQuoteStyle as CsvQuoteStyleProto, JsonOptions as JsonOptionsProto,
32    OptimizedLogicalPlanType, OptimizedPhysicalPlanType,
33    ParquetCdcOptions as ParquetCdcOptionsProto,
34    ParquetColumnOptions as ParquetColumnOptionsProto,
35    ParquetOptions as ParquetOptionsProto,
36    TableParquetOptions as TableParquetOptionsProto, parquet_column_options,
37    parquet_options,
38    plan_type::PlanTypeEnum::{
39        AnalyzedLogicalPlan, FinalAnalyzedLogicalPlan, FinalLogicalPlan,
40        FinalPhysicalPlan, FinalPhysicalPlanWithSchema, FinalPhysicalPlanWithStats,
41        InitialLogicalPlan, InitialPhysicalPlan, InitialPhysicalPlanWithSchema,
42        InitialPhysicalPlanWithStats, OptimizedLogicalPlan, OptimizedPhysicalPlan,
43        PhysicalPlanError,
44    },
45};
46
47impl From<&protobuf::UnnestOptions> for UnnestOptions {
48    fn from(opts: &protobuf::UnnestOptions) -> Self {
49        use datafusion_common::NullHandling;
50        use protobuf::unnest_options::NullHandling as ProtoNullHandling;
51        let null_handling = match ProtoNullHandling::try_from(opts.null_handling) {
52            Ok(ProtoNullHandling::Preserve) => NullHandling::Preserve,
53            Ok(ProtoNullHandling::Drop) => NullHandling::Drop,
54            Ok(ProtoNullHandling::PreserveAndExpandEmpty) => {
55                NullHandling::PreserveAndExpandEmpty
56            }
57            // Unknown enum values fall back to the default (Preserve), which
58            // matches DataFusion's historical behavior.
59            Err(_) => NullHandling::Preserve,
60        };
61        Self {
62            null_handling,
63            recursions: opts
64                .recursions
65                .iter()
66                .map(|r| RecursionUnnestOption {
67                    input_column: r.input_column.as_ref().unwrap().into(),
68                    output_column: r.output_column.as_ref().unwrap().into(),
69                    depth: r.depth as usize,
70                })
71                .collect::<Vec<_>>(),
72        }
73    }
74}
75
76impl TryFrom<protobuf::TableReference> for TableReference {
77    type Error = Error;
78
79    fn try_from(value: protobuf::TableReference) -> Result<Self, Self::Error> {
80        use protobuf::table_reference::TableReferenceEnum;
81        let table_reference_enum = value
82            .table_reference_enum
83            .ok_or_else(|| Error::required("table_reference_enum"))?;
84
85        match table_reference_enum {
86            TableReferenceEnum::Bare(protobuf::BareTableReference { table }) => {
87                Ok(TableReference::bare(table))
88            }
89            TableReferenceEnum::Partial(protobuf::PartialTableReference {
90                schema,
91                table,
92            }) => Ok(TableReference::partial(schema, table)),
93            TableReferenceEnum::Full(protobuf::FullTableReference {
94                catalog,
95                schema,
96                table,
97            }) => Ok(TableReference::full(catalog, schema, table)),
98        }
99    }
100}
101
102impl From<&protobuf::StringifiedPlan> for StringifiedPlan {
103    fn from(stringified_plan: &protobuf::StringifiedPlan) -> Self {
104        Self {
105            plan_type: match stringified_plan
106                .plan_type
107                .as_ref()
108                .and_then(|pt| pt.plan_type_enum.as_ref())
109                .unwrap_or_else(|| {
110                    panic!(
111                        "Cannot create protobuf::StringifiedPlan from {stringified_plan:?}"
112                    )
113                }) {
114                InitialLogicalPlan(_) => PlanType::InitialLogicalPlan,
115                AnalyzedLogicalPlan(AnalyzedLogicalPlanType { analyzer_name }) => {
116                    PlanType::AnalyzedLogicalPlan {
117                        analyzer_name:analyzer_name.clone()
118                    }
119                }
120                FinalAnalyzedLogicalPlan(_) => PlanType::FinalAnalyzedLogicalPlan,
121                OptimizedLogicalPlan(OptimizedLogicalPlanType { optimizer_name }) => {
122                    PlanType::OptimizedLogicalPlan {
123                        optimizer_name: optimizer_name.clone(),
124                    }
125                }
126                FinalLogicalPlan(_) => PlanType::FinalLogicalPlan,
127                InitialPhysicalPlan(_) => PlanType::InitialPhysicalPlan,
128                InitialPhysicalPlanWithStats(_) => PlanType::InitialPhysicalPlanWithStats,
129                InitialPhysicalPlanWithSchema(_) => PlanType::InitialPhysicalPlanWithSchema,
130                OptimizedPhysicalPlan(OptimizedPhysicalPlanType { optimizer_name }) => {
131                    PlanType::OptimizedPhysicalPlan {
132                        optimizer_name: optimizer_name.clone(),
133                    }
134                }
135                FinalPhysicalPlan(_) => PlanType::FinalPhysicalPlan,
136                FinalPhysicalPlanWithStats(_) => PlanType::FinalPhysicalPlanWithStats,
137                FinalPhysicalPlanWithSchema(_) => PlanType::FinalPhysicalPlanWithSchema,
138                PhysicalPlanError(_) => PlanType::PhysicalPlanError,
139            },
140            plan: Arc::new(stringified_plan.plan.clone()),
141        }
142    }
143}
144
145impl From<protobuf::JoinType> for JoinType {
146    fn from(t: protobuf::JoinType) -> Self {
147        match t {
148            protobuf::JoinType::Inner => JoinType::Inner,
149            protobuf::JoinType::Left => JoinType::Left,
150            protobuf::JoinType::Right => JoinType::Right,
151            protobuf::JoinType::Full => JoinType::Full,
152            protobuf::JoinType::Leftsemi => JoinType::LeftSemi,
153            protobuf::JoinType::Rightsemi => JoinType::RightSemi,
154            protobuf::JoinType::Leftanti => JoinType::LeftAnti,
155            protobuf::JoinType::Rightanti => JoinType::RightAnti,
156            protobuf::JoinType::Leftmark => JoinType::LeftMark,
157            protobuf::JoinType::Rightmark => JoinType::RightMark,
158        }
159    }
160}
161
162impl From<protobuf::JoinConstraint> for JoinConstraint {
163    fn from(t: protobuf::JoinConstraint) -> Self {
164        match t {
165            protobuf::JoinConstraint::On => JoinConstraint::On,
166            protobuf::JoinConstraint::Using => JoinConstraint::Using,
167        }
168    }
169}
170
171impl From<protobuf::NullEquality> for NullEquality {
172    fn from(t: protobuf::NullEquality) -> Self {
173        match t {
174            protobuf::NullEquality::NullEqualsNothing => NullEquality::NullEqualsNothing,
175            protobuf::NullEquality::NullEqualsNull => NullEquality::NullEqualsNull,
176        }
177    }
178}
179
180impl TryFrom<&CsvOptionsProto> for CsvOptions {
181    type Error = datafusion_common::DataFusionError;
182
183    fn try_from(proto: &CsvOptionsProto) -> datafusion_common::Result<Self, Self::Error> {
184        Ok(CsvOptions {
185            has_header: if !proto.has_header.is_empty() {
186                Some(proto.has_header[0] != 0)
187            } else {
188                None
189            },
190            delimiter: proto.delimiter.first().copied().unwrap_or(b','),
191            quote: proto.quote.first().copied().unwrap_or(b'"'),
192            terminator: if !proto.terminator.is_empty() {
193                Some(proto.terminator[0])
194            } else {
195                None
196            },
197            escape: if !proto.escape.is_empty() {
198                Some(proto.escape[0])
199            } else {
200                None
201            },
202            double_quote: if !proto.double_quote.is_empty() {
203                Some(proto.double_quote[0] != 0)
204            } else {
205                None
206            },
207            compression: match proto.compression {
208                0 => CompressionTypeVariant::GZIP,
209                1 => CompressionTypeVariant::BZIP2,
210                2 => CompressionTypeVariant::XZ,
211                3 => CompressionTypeVariant::ZSTD,
212                _ => CompressionTypeVariant::UNCOMPRESSED,
213            },
214            schema_infer_max_rec: proto
215                .schema_infer_max_rec
216                .map(|value| usize_from_wire(value, "CsvOptions", "schema_infer_max_rec"))
217                .transpose()?,
218            date_format: if proto.date_format.is_empty() {
219                None
220            } else {
221                Some(proto.date_format.clone())
222            },
223            datetime_format: if proto.datetime_format.is_empty() {
224                None
225            } else {
226                Some(proto.datetime_format.clone())
227            },
228            timestamp_format: if proto.timestamp_format.is_empty() {
229                None
230            } else {
231                Some(proto.timestamp_format.clone())
232            },
233            timestamp_tz_format: if proto.timestamp_tz_format.is_empty() {
234                None
235            } else {
236                Some(proto.timestamp_tz_format.clone())
237            },
238            time_format: if proto.time_format.is_empty() {
239                None
240            } else {
241                Some(proto.time_format.clone())
242            },
243            null_value: if proto.null_value.is_empty() {
244                None
245            } else {
246                Some(proto.null_value.clone())
247            },
248            null_regex: if proto.null_regex.is_empty() {
249                None
250            } else {
251                Some(proto.null_regex.clone())
252            },
253            comment: if !proto.comment.is_empty() {
254                Some(proto.comment[0])
255            } else {
256                None
257            },
258            newlines_in_values: if proto.newlines_in_values.is_empty() {
259                None
260            } else {
261                Some(proto.newlines_in_values[0] != 0)
262            },
263            truncated_rows: if proto.truncated_rows.is_empty() {
264                None
265            } else {
266                Some(proto.truncated_rows[0] != 0)
267            },
268            compression_level: proto.compression_level,
269            quote_style: match CsvQuoteStyleProto::try_from(proto.quote_style) {
270                Ok(CsvQuoteStyleProto::Always) => CsvQuoteStyle::Always,
271                Ok(CsvQuoteStyleProto::NonNumeric) => CsvQuoteStyle::NonNumeric,
272                Ok(CsvQuoteStyleProto::Never) => CsvQuoteStyle::Never,
273                Ok(CsvQuoteStyleProto::Necessary) => CsvQuoteStyle::Necessary,
274                _ => CsvQuoteStyle::Necessary,
275            },
276            ignore_leading_whitespace: if proto.ignore_leading_whitespace.is_empty() {
277                None
278            } else {
279                Some(proto.ignore_leading_whitespace[0] != 0)
280            },
281            ignore_trailing_whitespace: if proto.ignore_trailing_whitespace.is_empty() {
282                None
283            } else {
284                Some(proto.ignore_trailing_whitespace[0] != 0)
285            },
286        })
287    }
288}
289
290impl TryFrom<&JsonOptionsProto> for JsonOptions {
291    type Error = datafusion_common::DataFusionError;
292
293    fn try_from(
294        proto: &JsonOptionsProto,
295    ) -> datafusion_common::Result<Self, Self::Error> {
296        Ok(JsonOptions {
297            compression: match proto.compression {
298                0 => CompressionTypeVariant::GZIP,
299                1 => CompressionTypeVariant::BZIP2,
300                2 => CompressionTypeVariant::XZ,
301                3 => CompressionTypeVariant::ZSTD,
302                _ => CompressionTypeVariant::UNCOMPRESSED,
303            },
304            schema_infer_max_rec: proto
305                .schema_infer_max_rec
306                .map(|value| {
307                    usize_from_wire(value, "JsonOptions", "schema_infer_max_rec")
308                })
309                .transpose()?,
310            compression_level: proto.compression_level,
311            newline_delimited: proto.newline_delimited.unwrap_or(true),
312        })
313    }
314}
315
316impl TryFrom<ParquetCdcOptionsProto> for ParquetCdcOptions {
317    type Error = datafusion_common::DataFusionError;
318
319    fn try_from(
320        value: ParquetCdcOptionsProto,
321    ) -> datafusion_common::Result<Self, Self::Error> {
322        let to_usize =
323            |value: u64, field: &str| usize_from_wire(value, "ParquetCdcOptions", field);
324        Ok(ParquetCdcOptions {
325            enabled: value.enabled,
326            min_chunk_size: to_usize(value.min_chunk_size, "min_chunk_size")?,
327            max_chunk_size: to_usize(value.max_chunk_size, "max_chunk_size")?,
328            norm_level: value.norm_level,
329        })
330    }
331}
332
333impl TryFrom<&ParquetOptionsProto> for ParquetOptions {
334    type Error = datafusion_common::DataFusionError;
335
336    fn try_from(
337        proto: &ParquetOptionsProto,
338    ) -> datafusion_common::Result<Self, Self::Error> {
339        let writer_version = match proto.writer_version.as_str() {
340            // Proto3 decodes an omitted string field as the empty string. The
341            // schema documents writer_version's logical default as "1.0", so
342            // preserve that default when the field is absent on the wire.
343            "" => ParquetOptions::default().writer_version,
344            version => version.parse()?,
345        };
346        let to_usize =
347            |value: u64, field: &str| usize_from_wire(value, "ParquetOptions", field);
348
349        Ok(ParquetOptions {
350            enable_page_index: proto.enable_page_index,
351            pruning: proto.pruning,
352            skip_metadata: proto.skip_metadata,
353            metadata_size_hint: proto
354                .metadata_size_hint_opt
355                .as_ref()
356                .map(|opt| match opt {
357                    parquet_options::MetadataSizeHintOpt::MetadataSizeHint(size) => {
358                        to_usize(*size, "metadata_size_hint")
359                    }
360                })
361                .transpose()?,
362            pushdown_filters: proto.pushdown_filters,
363            reorder_filters: proto.reorder_filters,
364            force_filter_selections: proto.force_filter_selections,
365            data_pagesize_limit: to_usize(
366                proto.data_pagesize_limit,
367                "data_pagesize_limit",
368            )?,
369            write_batch_size: to_usize(proto.write_batch_size, "write_batch_size")?,
370            writer_version,
371            compression: proto
372                .compression_opt
373                .as_ref()
374                .map(|opt| match opt {
375                    parquet_options::CompressionOpt::Compression(compression) => {
376                        compression.parse()
377                    }
378                })
379                .transpose()?,
380            enable_rle_to_dictionary: proto.enable_rle_to_dictionary,
381            dictionary_enabled: proto.dictionary_enabled_opt.as_ref().map(|opt| {
382                match opt {
383                    parquet_options::DictionaryEnabledOpt::DictionaryEnabled(
384                        enabled,
385                    ) => *enabled,
386                }
387            }),
388            dictionary_page_size_limit: to_usize(
389                proto.dictionary_page_size_limit,
390                "dictionary_page_size_limit",
391            )?,
392            statistics_enabled: proto
393                .statistics_enabled_opt
394                .as_ref()
395                .map(|opt| match opt {
396                    parquet_options::StatisticsEnabledOpt::StatisticsEnabled(
397                        statistics,
398                    ) => statistics.parse(),
399                })
400                .transpose()?,
401            max_row_group_size: to_usize(proto.max_row_group_size, "max_row_group_size")?,
402            max_in_list_size: to_usize(proto.max_in_list_size, "max_in_list_size")?,
403            row_group_range_assignment: RowGroupRangeAssignment::from_proto_str(
404                &proto.row_group_range_assignment,
405            )?,
406            created_by: proto.created_by.clone(),
407            column_index_truncate_length: proto
408                .column_index_truncate_length_opt
409                .as_ref()
410                .map(|opt| match opt {
411                    parquet_options::ColumnIndexTruncateLengthOpt::ColumnIndexTruncateLength(length) => {
412                        to_usize(*length, "column_index_truncate_length")
413                    }
414                })
415                .transpose()?,
416            statistics_truncate_length: proto
417                .statistics_truncate_length_opt
418                .as_ref()
419                .map(|opt| match opt {
420                    parquet_options::StatisticsTruncateLengthOpt::StatisticsTruncateLength(length) => {
421                        to_usize(*length, "statistics_truncate_length")
422                    }
423                })
424                .transpose()?,
425            data_page_row_count_limit: to_usize(
426                proto.data_page_row_count_limit,
427                "data_page_row_count_limit",
428            )?,
429            encoding: proto
430                .encoding_opt
431                .as_ref()
432                .map(|opt| match opt {
433                    parquet_options::EncodingOpt::Encoding(encoding) => encoding.parse(),
434                })
435                .transpose()?,
436            bloom_filter_on_read: proto.bloom_filter_on_read,
437            bloom_filter_on_write: proto.bloom_filter_on_write,
438            bloom_filter_fpp: proto
439                .bloom_filter_fpp_opt
440                .as_ref()
441                .map(|opt| match opt {
442                    parquet_options::BloomFilterFppOpt::BloomFilterFpp(fpp) => *fpp,
443                }),
444            bloom_filter_ndv: proto
445                .bloom_filter_ndv_opt
446                .as_ref()
447                .map(|opt| match opt {
448                    parquet_options::BloomFilterNdvOpt::BloomFilterNdv(ndv) => *ndv,
449                }),
450            allow_single_file_parallelism: proto.allow_single_file_parallelism,
451            maximum_parallel_row_group_writers: to_usize(
452                proto.maximum_parallel_row_group_writers,
453                "maximum_parallel_row_group_writers",
454            )?,
455            maximum_buffered_record_batches_per_stream: to_usize(
456                proto.maximum_buffered_record_batches_per_stream,
457                "maximum_buffered_record_batches_per_stream",
458            )?,
459            schema_force_view_types: proto.schema_force_view_types,
460            binary_as_string: proto.binary_as_string,
461            skip_arrow_metadata: proto.skip_arrow_metadata,
462            write_row_group_number_distinct_values: proto
463                .write_row_group_number_distinct_values,
464            coerce_int96: proto
465                .coerce_int96_opt
466                .as_ref()
467                .map(|opt| match opt {
468                    parquet_options::CoerceInt96Opt::CoerceInt96(coerce_int96) => {
469                        coerce_int96.parse()
470                    }
471                })
472                .transpose()?,
473            coerce_int96_tz: proto
474                .coerce_int96_tz_opt
475                .as_ref()
476                .map(|opt| match opt {
477                    parquet_options::CoerceInt96TzOpt::CoerceInt96Tz(tz) => tz.parse(),
478                })
479                .transpose()?,
480            max_predicate_cache_size: proto
481                .max_predicate_cache_size_opt
482                .as_ref()
483                .map(|opt| match opt {
484                    parquet_options::MaxPredicateCacheSizeOpt::MaxPredicateCacheSize(
485                        size,
486                    ) => to_usize(*size, "max_predicate_cache_size"),
487                })
488                .transpose()?,
489            max_row_group_bytes: proto
490                .max_row_group_bytes_opt
491                .as_ref()
492                .map(|opt| match opt {
493                    parquet_options::MaxRowGroupBytesOpt::MaxRowGroupBytes(size) => {
494                        MaxRowGroupBytes::try_new(to_usize(*size, "max_row_group_bytes")?)
495                    }
496                })
497                .transpose()?,
498            content_defined_chunking: proto
499                .content_defined_chunking
500                .map(ParquetCdcOptions::try_from)
501                .transpose()?
502                .unwrap_or_default(),
503        })
504    }
505}
506
507impl From<ParquetColumnOptionsProto> for ParquetColumnOptions {
508    fn from(proto: ParquetColumnOptionsProto) -> Self {
509        ParquetColumnOptions {
510            bloom_filter_enabled: proto.bloom_filter_enabled_opt.map(
511                |parquet_column_options::BloomFilterEnabledOpt::BloomFilterEnabled(v)| v,
512            ),
513            encoding: proto
514                .encoding_opt
515                .map(|parquet_column_options::EncodingOpt::Encoding(v)| v),
516            dictionary_enabled: proto.dictionary_enabled_opt.map(
517                |parquet_column_options::DictionaryEnabledOpt::DictionaryEnabled(v)| v,
518            ),
519            compression: proto
520                .compression_opt
521                .map(|parquet_column_options::CompressionOpt::Compression(v)| v),
522            statistics_enabled: proto.statistics_enabled_opt.map(
523                |parquet_column_options::StatisticsEnabledOpt::StatisticsEnabled(v)| v,
524            ),
525            bloom_filter_fpp: proto
526                .bloom_filter_fpp_opt
527                .map(|parquet_column_options::BloomFilterFppOpt::BloomFilterFpp(v)| v),
528            bloom_filter_ndv: proto
529                .bloom_filter_ndv_opt
530                .map(|parquet_column_options::BloomFilterNdvOpt::BloomFilterNdv(v)| v),
531        }
532    }
533}
534
535impl TryFrom<&TableParquetOptionsProto> for TableParquetOptions {
536    type Error = datafusion_common::DataFusionError;
537
538    fn try_from(
539        proto: &TableParquetOptionsProto,
540    ) -> datafusion_common::Result<Self, Self::Error> {
541        Ok(TableParquetOptions {
542            global: proto
543                .global
544                .as_ref()
545                .map(ParquetOptions::try_from)
546                .transpose()?
547                .unwrap_or_default(),
548            column_specific_options: proto
549                .column_specific_options
550                .iter()
551                .map(|parquet_column_options| {
552                    (
553                        parquet_column_options.column_name.clone(),
554                        ParquetColumnOptions::from(
555                            parquet_column_options.options.clone().unwrap_or_default(),
556                        ),
557                    )
558                })
559                .collect(),
560            key_value_metadata: proto
561                .key_value_metadata
562                .iter()
563                .map(|(k, v)| (k.clone(), Some(v.clone())))
564                .collect(),
565            ..Default::default()
566        })
567    }
568}
569
570#[cfg(test)]
571mod tests {
572    use super::*;
573
574    #[test]
575    fn rejects_invalid_parquet_encoding() {
576        let proto = ParquetOptionsProto {
577            encoding_opt: Some(parquet_options::EncodingOpt::Encoding(
578                "invalid".to_string(),
579            )),
580            ..Default::default()
581        };
582
583        let err = ParquetOptions::try_from(&proto).unwrap_err();
584        assert!(
585            err.to_string()
586                .contains("Unknown or unsupported parquet encoding: invalid")
587        );
588    }
589
590    #[test]
591    fn rejects_invalid_parquet_statistics() {
592        let proto = ParquetOptionsProto {
593            statistics_enabled_opt: Some(
594                parquet_options::StatisticsEnabledOpt::StatisticsEnabled(
595                    "invalid".to_string(),
596                ),
597            ),
598            ..Default::default()
599        };
600
601        let err = ParquetOptions::try_from(&proto).unwrap_err();
602        assert!(
603            err.to_string()
604                .contains("Invalid parquet statistics setting: invalid")
605        );
606    }
607
608    #[test]
609    fn accepts_parquet_coerce_int96_tz_without_unit() {
610        let proto = ParquetOptionsProto {
611            coerce_int96_tz_opt: Some(parquet_options::CoerceInt96TzOpt::CoerceInt96Tz(
612                "+08".to_string(),
613            )),
614            ..Default::default()
615        };
616
617        let options = ParquetOptions::try_from(&proto).unwrap();
618        assert_eq!(options.coerce_int96, None);
619        assert_eq!(
620            options.coerce_int96_tz.as_ref().map(|tz| tz.as_str()),
621            Some("+08")
622        );
623    }
624
625    #[test]
626    fn rejects_invalid_parquet_coerce_int96_tz() {
627        let proto = ParquetOptionsProto {
628            coerce_int96_tz_opt: Some(parquet_options::CoerceInt96TzOpt::CoerceInt96Tz(
629                "Not/A_Timezone".to_string(),
630            )),
631            ..Default::default()
632        };
633
634        let err = ParquetOptions::try_from(&proto).unwrap_err();
635        assert!(
636            err.to_string()
637                .contains("Invalid time zone: Not/A_Timezone."),
638            "unexpected error: {err}"
639        );
640    }
641}