Skip to content

Update the documentation of Row condition #1889

Open
Allex-Nik wants to merge 2 commits into
masterfrom
row-condition-documentation
Open

Update the documentation of Row condition #1889
Allex-Nik wants to merge 2 commits into
masterfrom
row-condition-documentation

Conversation

@Allex-Nik

Copy link
Copy Markdown
Collaborator

Fixes #1706
Helps #898

  • Add RowFilter and RowValueFilter as kinds of row conditions
  • Move DataRow samples from core to samples
  • Minor fixes

@Allex-Nik Allex-Nik added the documentation Improvements or additions to documentation (not KDocs) label Jun 5, 2026
Comment thread docs/StardustDocs/topics/concepts/DataRow.md

```kotlin
// Row expression computes updated values
df.update { weight }.at(1, 3, 4).with { prev()?.weight }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the original example. Do you think we should replace it with something more plausible?

Something like df.update { age }.at(1).with { it + 1 }?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd expand the original one - use both prev() and it and write about it in the comment

```kotlin
// Row condition is used to filter rows by index
// Row filter is used to filter rows by index
df.filter { index() % 5 == 0 }

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Also an original example. Do you think it's fine?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd replace with something more meaningful — name == && age > ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

And also, just here, I'd show the original df first with highlighted rows meeting the predicate.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

`RowValueFilter` is used via the `where` clause after selecting columns in functions
such as [`update`](update.md), [`gather`](gather.md), and [`format`](format.md).
Like `RowFilter`, it returns a `Boolean` indicating whether the row should be included in the result.
However, unlike `RowFilter`, where both `this` and `it` refer to the current [`DataRow`](DataRow.md),

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Is it correct? As far as I understood, it's not that RowFilter works with entire rows and RowValueFilter works only with parts of rows. RowValueFilter can also access the whole row, it just additionally accesses the selected part of the row as it, right?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

RowValueFilter works only with parts of rows

Why?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I do not think that RowValueFilter works only with parts of rows. In the second sentence I mean that as far as I understood, the distinction between RowFilter and RowValueFilter is not "one works only with entire rows and another works only with parts of rows" :)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry, missread.
So, yes, totally correct! But not sure if RowValueFilter is used only via the where.

```

<!---END-->
<inline-frame src="resources/filter.html" width="100%"/>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not found:
Image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

and are used in [add](add.md), [filter](filter.md), [forEach](iterate.md), [update](update.md), and other operations.

<!---FUN expressions-->
Row expression signature: ```DataRow.(DataRow) -> T```. Row values can be accessed with or without ```it``` keyword.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

But below you show and example of update.with which has a different signature (it has a s type of selected column values)!
I believe we miss here Row-Value Expression definition


Could you please review it and rewrite it the same way as Row-Value Condition.


```kotlin
// Row expression computes updated values
df.update { weight }.at(1, 3, 4).with { prev()?.weight }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd expand the original one - use both prev() and it and write about it in the comment

```kotlin
// Row condition is used to filter rows by index
// Row filter is used to filter rows by index
df.filter { index() % 5 == 0 }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd replace with something more meaningful — name == && age > ...

`RowValueFilter` is used via the `where` clause after selecting columns in functions
such as [`update`](update.md), [`gather`](gather.md), and [`format`](format.md).
Like `RowFilter`, it returns a `Boolean` indicating whether the row should be included in the result.
However, unlike `RowFilter`, where both `this` and `it` refer to the current [`DataRow`](DataRow.md),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

RowValueFilter works only with parts of rows

Why?

@AndreiKingsley

Copy link
Copy Markdown
Collaborator

@Allex-Nik let me fix #1888 so you can make examples prettier!

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

Labels

documentation Improvements or additions to documentation (not KDocs)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update "Row condition" documentation

2 participants