Skip to content

Commit 8f8f832

Browse files
committed
feat: support DefineStmt (aggregate)
1 parent 010d53d commit 8f8f832

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

crates/codegen/src/get_node_properties.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,28 @@ fn custom_handlers(node: &Node) -> TokenStream {
527527
_ => panic!("Unknown CreateCastStmt {:#?}", n.context())
528528
}
529529
},
530+
"DefineStmt" => quote! {
531+
tokens.push(TokenProperty::from(Token::Create));
532+
match n.kind() {
533+
protobuf::ObjectType::ObjectAggregate => tokens.push(TokenProperty::from(Token::Aggregate)),
534+
_ => todo!("Unknown DefineStmt {:#?}", n.kind())
535+
}
536+
if let Some(node) = &n.args[0].node {
537+
if let NodeEnum::List(n) = node {
538+
if n.items.len() == 2 {
539+
tokens.push(TokenProperty::from(Token::Order));
540+
tokens.push(TokenProperty::from(Token::By));
541+
tokens.push(TokenProperty::from(Token::Ident));
542+
tokens.push(TokenProperty::from(Token::Ident));
543+
}
544+
}
545+
} else {
546+
tokens.push(TokenProperty::from(Token::Ascii42));
547+
}
548+
if n.definition.len() > 0 {
549+
tokens.push(TokenProperty::from(Token::Ident));
550+
}
551+
},
530552
_ => quote! {},
531553
}
532554
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE AGGREGATE aggregate1 (int4) (sfunc = sfunc1, stype = stype1);
2+
CREATE AGGREGATE aggregate1 (int4, bool) (sfunc = sfunc1, stype = stype1);
3+
CREATE AGGREGATE aggregate1 (*) (sfunc = sfunc1, stype = stype1);
4+
CREATE AGGREGATE aggregate1 (int4) (sfunc = sfunc1, stype = stype1, finalfunc_extra, mfinalfuncextra);
5+
CREATE AGGREGATE aggregate1 (int4) (sfunc = sfunc1, stype = stype1, finalfunc_modify = read_only, parallel = restricted);
6+
CREATE AGGREGATE percentile_disc (float8 ORDER BY anyelement) (sfunc = ordered_set_transition, stype = internal, finalfunc = percentile_disc_final, finalfunc_extra);

0 commit comments

Comments
 (0)