Skip to content

Commit

Permalink
fix: remove message name parameter for avro schema (#8124)
Browse files Browse the repository at this point in the history
I checked the code for the version where this parameter was first introduced and found that it was never used, it was probably just copied from `ProtobufSchema`.

It is strange to let the user specify the message name for a avro schema, so we should remove it.

Approved-By: tabVersion
Approved-By: hzxa21
  • Loading branch information
waruto210 committed Feb 23, 2023
1 parent 5c050ef commit ba92df4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
9 changes: 6 additions & 3 deletions e2e_test/source/basic/kafka.slt
Expand Up @@ -132,15 +132,17 @@ create table s9 with (
topic = 'avro_bin',
properties.bootstrap.server = '127.0.0.1:29092',
scan.startup.mode = 'earliest'
) row format avro message 'test_student' row schema location 'file:///risingwave/avro-simple-schema.avsc'
) row format avro
row schema location 'file:///risingwave/avro-simple-schema.avsc'

statement ok
create table s10 with (
connector = 'kafka',
topic = 'avro_c_bin',
properties.bootstrap.server = '127.0.0.1:29092',
scan.startup.mode = 'earliest'
) row format avro message 'user' row schema location 'file:///risingwave/avro-complex-schema.avsc'
) row format avro
row schema location 'file:///risingwave/avro-complex-schema.avsc'

statement ok
create table s11 with (
Expand Down Expand Up @@ -240,7 +242,8 @@ create source s18 with (
topic = 'avro_c_bin',
properties.bootstrap.server = '127.0.0.1:29092',
scan.startup.mode = 'earliest'
) row format avro message 'user' row schema location 'file:///risingwave/avro-complex-schema.avsc'
) row format avro
row schema location 'file:///risingwave/avro-complex-schema.avsc'

statement ok
flush;
Expand Down
12 changes: 2 additions & 10 deletions src/sqlparser/src/ast/statement.rs
Expand Up @@ -188,28 +188,22 @@ impl fmt::Display for ProtobufSchema {
}

// sql_grammar!(AvroSchema {
// [Keyword::MESSAGE],
// message_name: AstString,
// [Keyword::ROW, Keyword::SCHEMA, Keyword::LOCATION],
// row_schema_location: AstString,
// [Keyword::ROW, Keyword::SCHEMA, Keyword::LOCATION, [Keyword::CONFLUENT, Keyword::SCHEMA,
// Keyword::REGISTRY]], row_schema_location: AstString,
// });
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct AvroSchema {
pub message_name: AstString,
pub row_schema_location: AstString,
pub use_schema_registry: bool,
}

impl ParseTo for AvroSchema {
fn parse_to(p: &mut Parser) -> Result<Self, ParserError> {
impl_parse_to!([Keyword::MESSAGE], p);
impl_parse_to!(message_name: AstString, p);
impl_parse_to!([Keyword::ROW, Keyword::SCHEMA, Keyword::LOCATION], p);
impl_parse_to!(use_schema_registry => [Keyword::CONFLUENT, Keyword::SCHEMA, Keyword::REGISTRY], p);
impl_parse_to!(row_schema_location: AstString, p);
Ok(Self {
message_name,
row_schema_location,
use_schema_registry,
})
Expand All @@ -219,8 +213,6 @@ impl ParseTo for AvroSchema {
impl fmt::Display for AvroSchema {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut v: Vec<String> = vec![];
impl_fmt_display!([Keyword::MESSAGE], v);
impl_fmt_display!(message_name, v, self);
impl_fmt_display!([Keyword::ROW, Keyword::SCHEMA, Keyword::LOCATION], v);
impl_fmt_display!(use_schema_registry => [Keyword::CONFLUENT, Keyword::SCHEMA, Keyword::REGISTRY], v, self);
impl_fmt_display!(row_schema_location, v, self);
Expand Down

0 comments on commit ba92df4

Please sign in to comment.