From ba92df425cb5eb091adc66656bfe6330108ab826 Mon Sep 17 00:00:00 2001 From: waruto Date: Thu, 23 Feb 2023 15:04:46 +0800 Subject: [PATCH] fix: remove message name parameter for avro schema (#8124) 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 --- e2e_test/source/basic/kafka.slt | 9 ++++++--- src/sqlparser/src/ast/statement.rs | 12 ++---------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/e2e_test/source/basic/kafka.slt b/e2e_test/source/basic/kafka.slt index a7c8b6c73205e..8c9d56dc64bf3 100644 --- a/e2e_test/source/basic/kafka.slt +++ b/e2e_test/source/basic/kafka.slt @@ -132,7 +132,8 @@ 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 ( @@ -140,7 +141,8 @@ create table s10 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 create table s11 with ( @@ -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; diff --git a/src/sqlparser/src/ast/statement.rs b/src/sqlparser/src/ast/statement.rs index 06ed47fa2cf38..4cbe273b055c8 100644 --- a/src/sqlparser/src/ast/statement.rs +++ b/src/sqlparser/src/ast/statement.rs @@ -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 { - 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, }) @@ -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 = 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);