Skip to content

feat(small): Support <slt:ignore> marker in sqllogictest for non-deterministic expected parts#18857

Merged
2010YOUY01 merged 4 commits intoapache:mainfrom
2010YOUY01:slt-ignore
Nov 23, 2025
Merged

feat(small): Support <slt:ignore> marker in sqllogictest for non-deterministic expected parts#18857
2010YOUY01 merged 4 commits intoapache:mainfrom
2010YOUY01:slt-ignore

Conversation

@2010YOUY01
Copy link
Copy Markdown
Contributor

@2010YOUY01 2010YOUY01 commented Nov 21, 2025

Which issue does this PR close?

Part of #17612

Rationale for this change

sqllogictests are in general easier to maintain than rust tests, however it's not able to test EXPLAIN ANALYZE results, because their results include changing part:

(in datafusion-cli) The elapsed_compute measurement changes from run to run.

> EXPLAIN ANALYZE SELECT * FROM generate_series(100);
+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan_type         | plan                                                                                                                                                                                             |
+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Plan with Metrics | LazyMemoryExec: partitions=1, batch_generators=[generate_series: start=0, end=100, batch_size=8192], metrics=[output_rows=101, elapsed_compute=74.042µs, output_bytes=64.0 KB, output_batches=1] |
|                   |                                                                                                                                                                                                  |
+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.006 seconds.

We can add a special marker to sqllogictest to skip those non-deterministic parts.

What changes are included in this PR?

  • Changed sqllogictest validator to recognize <slt:ignore> marker
  • doc
  • slt test

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions Bot added the sqllogictest SQL Logic Tests (.slt) label Nov 21, 2025
if let Some(idx) = actual_snapshot[pos..].find(frag) {
pos += idx + frag.len();
} else {
return false;
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.

This early return would make it hard to debug. It would be nice to log a warning with the reason, as done below (line 116+).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Honestly, I don't know what those log are used for. I think the error message is generated elsewhere, and I want to make sure they're developer-friendly.

It looks okay now, but with false positives

2. query result mismatch:
[SQL] select * from generate_series(3);
[Diff] (-expected|+actual)
-   <slt:ignore>
+   0
    1
-   3<slt:ignore>
+   2
    3
at /Users/yongting/Code/datafusion/datafusion/sqllogictest/test_files/slt_features.slt:84

I have filed #18878 for improvement.

Comment thread datafusion/sqllogictest/README.md Outdated
continue;
}
if let Some(idx) = actual_snapshot[pos..].find(frag) {
pos += idx + frag.len();
Copy link
Copy Markdown
Member

@martin-g martin-g Nov 21, 2025

Choose a reason for hiding this comment

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

I think this logic won't detect a prefix in the actual_snapshot.
Let's say the first expected fragment is "Hello" but the actual_snapshot starts with "Anything here before Hello". The find() will set the position to the correct index but Anything here before will be ignored and assumed as matching.
Similar issue with a suffix in actual_snapshot.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is a good catch. I fixed it in a3154e7 and added more tests.

2010YOUY01 and others added 2 commits November 22, 2025 12:25
Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
@2010YOUY01 2010YOUY01 added this pull request to the merge queue Nov 23, 2025
Merged via the queue into apache:main with commit fbe1ae6 Nov 23, 2025
28 checks passed
xudong963 pushed a commit to massive-com/arrow-datafusion that referenced this pull request Jan 27, 2026
…deterministic expected parts (apache#18857)

## Which issue does this PR close?

<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases.
You can link an issue to this PR using the GitHub syntax. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->

Part of apache#17612

## Rationale for this change

<!--
Why are you proposing this change? If this is already explained clearly
in the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand
your changes and offer better suggestions for fixes.
-->
`sqllogictest`s are in general easier to maintain than rust tests,
however it's not able to test `EXPLAIN ANALYZE` results, because their
results include changing part:

(in datafusion-cli) The `elapsed_compute` measurement changes from run
to run.
```
> EXPLAIN ANALYZE SELECT * FROM generate_series(100);
+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| plan_type         | plan                                                                                                                                                                                             |
+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Plan with Metrics | LazyMemoryExec: partitions=1, batch_generators=[generate_series: start=0, end=100, batch_size=8192], metrics=[output_rows=101, elapsed_compute=74.042µs, output_bytes=64.0 KB, output_batches=1] |
|                   |                                                                                                                                                                                                  |
+-------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row(s) fetched.
Elapsed 0.006 seconds.
```

We can add a special marker to `sqllogictest` to skip those
non-deterministic parts.

## What changes are included in this PR?

<!--
There is no need to duplicate the description in the issue here but it
is sometimes worth providing a summary of the individual changes in this
PR.
-->

- Changed `sqllogictest` validator to recognize `<slt:ignore>` marker
- doc
- slt test

## Are these changes tested?

<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code

If tests are not included in your PR, please explain why (for example,
are they covered by existing tests)?
-->

## Are there any user-facing changes?

<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->

<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->

---------

Co-authored-by: Martin Grigorov <martin-g@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants