Skip to content

Add given stage#451

Open
krishnangovindraj wants to merge 9 commits into
typedb:masterfrom
krishnangovindraj:add-inputs-stage
Open

Add given stage#451
krishnangovindraj wants to merge 9 commits into
typedb:masterfrom
krishnangovindraj:add-inputs-stage

Conversation

@krishnangovindraj

Copy link
Copy Markdown
Member

Product change and motivation

Adds the 'given' stage to the language.

Comment thread rust/parser/typeql.pest

preamble = { WITH ~ definition_function }

query_stage_given = { GIVEN ~ function_arguments ~ SEMICOLON }

@krishnangovindraj krishnangovindraj Jun 12, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to be able to specify rows inline?

given $s: string in [
  ["foo"],
  ["bar"],
]

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it much work to add this right now? Or we can do it in a follow up ?

Comment thread rust/parser/pipeline.rs
let mut stages =
children.take_while_ref(|child| child.as_rule() == Rule::query_stage).map(visit_query_stage).collect_vec();
let mut stages = Vec::new();
stages.extend(children.try_consume_expected(Rule::query_stage_given).map(visit_query_stage_given));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh you can extend a Vec with an Option? That's cool

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah im guessing both are IntoIter right

Comment thread rust/parser/typeql.pest

preamble = { WITH ~ definition_function }

query_stage_given = { GIVEN ~ function_arguments ~ SEMICOLON }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you wanna rename function_arguments to pipeline_arguments? I think that actually makes a lot of sense

@flyingsilverfin flyingsilverfin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved w 1 comment

fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} ", Keyword::Given)?;
write_joined!(f, ", ", self.variables)?;
Ok(())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt this need semicolon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants