Add support of parsing struct field's options in BigQuery (#1890)
Some checks failed
license / Release Audit Tool (RAT) (push) Has been cancelled
Rust / codestyle (push) Has been cancelled
Rust / lint (push) Has been cancelled
Rust / benchmark-lint (push) Has been cancelled
Rust / compile (push) Has been cancelled
Rust / docs (push) Has been cancelled
Rust / compile-no-std (push) Has been cancelled
Rust / test (beta) (push) Has been cancelled
Rust / test (nightly) (push) Has been cancelled
Rust / test (stable) (push) Has been cancelled

Co-authored-by: Ifeanyi Ubah <ify1992@yahoo.com>
This commit is contained in:
hulk 2025-06-18 13:00:53 +08:00 committed by GitHub
parent be30697efb
commit b1b379e570
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 138 additions and 52 deletions

View file

@ -428,14 +428,22 @@ impl fmt::Display for Interval {
pub struct StructField {
pub field_name: Option<Ident>,
pub field_type: DataType,
/// Struct field options.
/// See [BigQuery](https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language#column_name_and_column_schema)
pub options: Option<Vec<SqlOption>>,
}
impl fmt::Display for StructField {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if let Some(name) = &self.field_name {
write!(f, "{name} {}", self.field_type)
write!(f, "{name} {}", self.field_type)?;
} else {
write!(f, "{}", self.field_type)
write!(f, "{}", self.field_type)?;
}
if let Some(options) = &self.options {
write!(f, " OPTIONS({})", display_separated(options, ", "))
} else {
Ok(())
}
}
}