fn desc(&self) -> Result<RelationDesc, anyhow::Error> {
        // Add columns for the data, based on the encoding format.
        Ok(match self {
            DataEncoding::Bytes => {
                RelationDesc::empty().with_column("data", ScalarType::Bytes.nullable(false))
            }
            DataEncoding::AvroOcf(AvroOcfEncoding {
                reader_schema: schema,
                ..
            })
            | DataEncoding::Avro(AvroEncoding { schema, .. }) => {
                let parsed_schema = avro::parse_schema(schema).context("validating avro schema")?;
                avro::schema_to_relationdesc(parsed_schema).context("validating avro schema")?
            }
            DataEncoding::Protobuf(ProtobufEncoding {
                descriptors,
                message_name,
                schema_registry_config: _,
            }) => protobuf::DecodedDescriptors::from_bytes(descriptors, message_name.to_owned())?
                .columns()
                .iter()
                .fold(RelationDesc::empty(), |desc, (name, ty)| {
                    desc.with_column(name, ty.clone())
                }),
            DataEncoding::Regex(RegexEncoding { regex }) => regex
                .capture_names()
                .enumerate()
                // The first capture is the entire matched string. This will
                // often not be useful, so skip it. If people want it they can
                // just surround their entire regex in an explicit capture
                // group.
                .skip(1)
                .fold(RelationDesc::empty(), |desc, (i, name)| {
                    let name = match name {
                        None => format!("column{}", i),
                        Some(name) => name.to_owned(),
                    };
                    let ty = ScalarType::String.nullable(true);
                    desc.with_column(name, ty)
                }),
            DataEncoding::Csv(CsvEncoding { columns, .. }) => match columns {
                ColumnSpec::Count(n) => {
                    (1..=*n).into_iter().fold(RelationDesc::empty(), |desc, i| {
                        desc.with_column(format!("column{}", i), ScalarType::String.nullable(false))
                    })
                }
                ColumnSpec::Header { names } => names
                    .iter()
                    .map(|s| &**s)
                    .fold(RelationDesc::empty(), |desc, name| {
                        desc.with_column(name, ScalarType::String.nullable(false))
                    }),
            },
            DataEncoding::Text => {
                RelationDesc::empty().with_column("text", ScalarType::String.nullable(false))
            }
            DataEncoding::Postgres => RelationDesc::empty()
                .with_column("oid", ScalarType::Int32.nullable(false))
                .with_column(
                    "row_data",
                    ScalarType::List {
                        element_type: Box::new(ScalarType::String),
                        custom_oid: None,
                    }
                    .nullable(false),
                ),
        })
    }
/// Computes the [`RelationDesc`] for the relation specified by this
/// data encoding and envelope.
///
/// If a key desc is provided it will be prepended to the returned desc
Computes the [`RelationDesc`] for the relation specified by this
data encoding and envelope.

If a key desc is provided it will be prepended to the returned desc
Computes the [ ` RelationDesc ` ] for the relation specified by this data encoding and envelope . If a key desc is provided it will be prepended to the returned desc
fn desc(&self) -> Result<RelationDesc, anyhow::Error> {
        // Add columns for the data, based on the encoding format.
        Ok(match self {
            DataEncoding::Bytes => {
                RelationDesc::empty().with_column("data", ScalarType::Bytes.nullable(false))
            }
            DataEncoding::AvroOcf(AvroOcfEncoding {
                reader_schema: schema,
                ..
            })
            | DataEncoding::Avro(AvroEncoding { schema, .. }) => {
                let parsed_schema = avro::parse_schema(schema).context("validating avro schema")?;
                avro::schema_to_relationdesc(parsed_schema).context("validating avro schema")?
            }
            DataEncoding::Protobuf(ProtobufEncoding {
                descriptors,
                message_name,
                schema_registry_config: _,
            }) => protobuf::DecodedDescriptors::from_bytes(descriptors, message_name.to_owned())?
                .columns()
                .iter()
                .fold(RelationDesc::empty(), |desc, (name, ty)| {
                    desc.with_column(name, ty.clone())
                }),
            DataEncoding::Regex(RegexEncoding { regex }) => regex
                .capture_names()
                .enumerate()
                // The first capture is the entire matched string. This will
                // often not be useful, so skip it. If people want it they can
                // just surround their entire regex in an explicit capture
                // group.
                .skip(1)
                .fold(RelationDesc::empty(), |desc, (i, name)| {
                    let name = match name {
                        None => format!("column{}", i),
                        Some(name) => name.to_owned(),
                    };
                    let ty = ScalarType::String.nullable(true);
                    desc.with_column(name, ty)
                }),
            DataEncoding::Csv(CsvEncoding { columns, .. }) => match columns {
                ColumnSpec::Count(n) => {
                    (1..=*n).into_iter().fold(RelationDesc::empty(), |desc, i| {
                        desc.with_column(format!("column{}", i), ScalarType::String.nullable(false))
                    })
                }
                ColumnSpec::Header { names } => names
                    .iter()
                    .map(|s| &**s)
                    .fold(RelationDesc::empty(), |desc, name| {
                        desc.with_column(name, ScalarType::String.nullable(false))
                    }),
            },
            DataEncoding::Text => {
                RelationDesc::empty().with_column("text", ScalarType::String.nullable(false))
            }
            DataEncoding::Postgres => RelationDesc::empty()
                .with_column("oid", ScalarType::Int32.nullable(false))
                .with_column(
                    "row_data",
                    ScalarType::List {
                        element_type: Box::new(ScalarType::String),
                        custom_oid: None,
                    }
                    .nullable(false),
                ),
        })
    }
fn desc ( & self ) -> Result < RelationDesc , anyhow :: Error > { // Add columns for the data, based on the encoding format. Ok ( match self { DataEncoding :: Bytes => { RelationDesc :: empty ( ) . with_column ( " " , ScalarType :: Bytes . nullable ( false ) ) } DataEncoding :: AvroOcf ( AvroOcfEncoding { reader_schema : schema , .. } ) | DataEncoding :: Avro ( AvroEncoding { schema , .. } ) => { let parsed_schema = avro :: parse_schema ( schema ) . context ( " " ) ? ; avro :: schema_to_relationdesc ( parsed_schema ) . context ( " " ) ? } DataEncoding :: Protobuf ( ProtobufEncoding { descriptors , message_name , schema_registry_config : _ , } ) => protobuf :: DecodedDescriptors :: from_bytes ( descriptors , message_name . to_owned ( ) ) ? . columns ( ) . iter ( ) . fold ( RelationDesc :: empty ( ) , | desc , ( name , ty ) | { desc . with_column ( name , ty . clone ( ) ) } ) , DataEncoding :: Regex ( RegexEncoding { regex } ) => regex . capture_names ( ) . enumerate ( ) // The first capture is the entire matched string. This will // often not be useful, so skip it. If people want it they can // just surround their entire regex in an explicit capture // group. . skip ( 1 ) . fold ( RelationDesc :: empty ( ) , | desc , ( i , name ) | { let name = match name { None => format ! ( " " i ) , Some ( name ) => name . to_owned ( ) , } ; let ty = ScalarType :: String . nullable ( true ) ; desc . with_column ( name , ty ) } ) , DataEncoding :: Csv ( CsvEncoding { columns , .. } ) => match columns { ColumnSpec :: Count ( n ) => { ( 1 ..= * n ) . into_iter ( ) . fold ( RelationDesc :: empty ( ) , | desc , i | { desc . with_column ( format ! ( " " i ) , ScalarType :: String . nullable ( false ) ) } ) } ColumnSpec :: Header { names } => names . iter ( ) . map ( | s | & * * s ) . fold ( RelationDesc :: empty ( ) , | desc , name | { desc . with_column ( name , ScalarType :: String . nullable ( false ) ) } ) , } , DataEncoding :: Text => { RelationDesc :: empty ( ) . with_column ( " " , ScalarType :: String . nullable ( false ) ) } DataEncoding :: Postgres => RelationDesc :: empty ( ) . with_column ( " " , ScalarType :: Int32 . nullable ( false ) ) . with_column ( " " , ScalarType :: List { element_type : Box :: new ( ScalarType :: String ) , custom_oid : None , } . nullable ( false ) , ) , } ) }
Computes the [`RelationDesc`] for the relation specified by this
data encoding and envelope.
Computes the [ ` RelationDesc ` ] for the relation specified by this data encoding and envelope .
&self
&self