(&mut self)
| 2202 | } |
| 2203 | |
| 2204 | fn parse_avro_schema(&mut self) -> Result<AvroSchema<Raw>, ParserError> { |
| 2205 | let avro_schema = if self.parse_keywords(&[CONFLUENT, SCHEMA, REGISTRY]) { |
| 2206 | let csr_connection = self.parse_csr_connection_avro()?; |
| 2207 | AvroSchema::Csr { csr_connection } |
| 2208 | } else if self.parse_keywords(&[AWS, GLUE, SCHEMA, REGISTRY]) { |
| 2209 | self.expect_keyword(CONNECTION)?; |
| 2210 | let connection = self.parse_raw_name()?; |
| 2211 | let with_options = if self.consume_token(&Token::LParen) { |
| 2212 | let opts = self.parse_comma_separated(Parser::parse_glue_avro_option)?; |
| 2213 | self.expect_token(&Token::RParen)?; |
| 2214 | opts |
| 2215 | } else { |
| 2216 | vec![] |
| 2217 | }; |
| 2218 | // SEED VALUE SCHEMA '<json>' is normally emitted by purification |
| 2219 | // and re-parsed when persisted create_sql is reloaded. A user may |
| 2220 | // also write it directly; that is accepted here (purification trusts |
| 2221 | // a pre-populated seed), though it is not the intended path. |
| 2222 | let seed = if self.parse_keyword(SEED) { |
| 2223 | self.expect_keywords(&[VALUE, SCHEMA])?; |
| 2224 | let value_schema = self.parse_literal_string()?; |
| 2225 | Some(GlueAvroSeed { value_schema }) |
| 2226 | } else { |
| 2227 | None |
| 2228 | }; |
| 2229 | AvroSchema::Glue { |
| 2230 | connection, |
| 2231 | with_options, |
| 2232 | seed, |
| 2233 | } |
| 2234 | } else if self.parse_keyword(SCHEMA) { |
| 2235 | self.prev_token(); |
| 2236 | self.expect_keyword(SCHEMA)?; |
| 2237 | let schema = Schema { |
| 2238 | schema: self.parse_literal_string()?, |
| 2239 | }; |
| 2240 | let with_options = if self.consume_token(&Token::LParen) { |
| 2241 | let with_options = self.parse_comma_separated(Parser::parse_avro_schema_option)?; |
| 2242 | self.expect_token(&Token::RParen)?; |
| 2243 | with_options |
| 2244 | } else { |
| 2245 | vec![] |
| 2246 | }; |
| 2247 | AvroSchema::InlineSchema { |
| 2248 | schema, |
| 2249 | with_options, |
| 2250 | } |
| 2251 | } else { |
| 2252 | return self.expected( |
| 2253 | self.peek_pos(), |
| 2254 | "CONFLUENT SCHEMA REGISTRY, AWS GLUE SCHEMA REGISTRY, or SCHEMA", |
| 2255 | self.peek_token(), |
| 2256 | ); |
| 2257 | }; |
| 2258 | Ok(avro_schema) |
| 2259 | } |
| 2260 | |
| 2261 | fn parse_avro_schema_option(&mut self) -> Result<AvroSchemaOption<Raw>, ParserError> { |
no test coverage detected