Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sqlsmith): fuzz query support sqllogic test cases #17216

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

b41sh
Copy link
Member

@b41sh b41sh commented Jan 8, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

fuzz query supports the fuzz-path argument, which can specify the test file path and generate more complex SQL by reading the existing sqllogictest as a seed case for fuzz.

The following example read all sqllogic tests in the query/functions folder and fuzz the SQL from there.

./target/debug/databend-sqlsmith --port 48000 --fuzz-path ./tests/sqllogictests/suites/query/functions
2025-01-08T11:35:16.095205Z  INFO databend_sqlsmith::runner: orig sql: SELECT sum(number) AS salary, number%3 AS user_name FROM numbers_mt(10000) GROUP BY user_name ORDER BY salary ASC
2025-01-08T11:35:16.099655Z  INFO databend_sqlsmith::runner: fuzz sql: SELECT number % 3 AS salary, number % (3 - 953) AS user_name FROM numbers_mt(10000) GROUP BY user_name ORDER BY salary ASC
2025-01-08T11:35:16.124583Z  INFO databend_sqlsmith::runner: orig sql: SELECT arg_min(user_name, salary)  FROM (SELECT sum(number) AS salary, number%3 AS user_name FROM numbers_mt(10000) GROUP BY user_name)
2025-01-08T11:35:16.127620Z  INFO databend_sqlsmith::runner: fuzz sql: SELECT arg_min(user_name, salary) FROM (SELECT number % 3, sum(number) AS salary, 3 % (to_decimal(17, 12)(10) - 284) AS user_name FROM numbers_mt(10000) WHERE arg_min(user_name, salary) GROUP BY user_name HAVING number % 3)
...

Other changes

  1. Sqlsmith has support for testing interval type values
  2. Support random interval value generation
  3. Support interval merge domain
  4. Supports interval domain cast as singleton scalars
  5. Fix set returning function in qualify caused panic SELECT 123 QUALIFY json_each(parse_json('null'));
  6. Fixed an order by panic bug caused by empty . SELECT a > b FROM (SELECT 3 a, 4 AS b ORDER BY CAST(4.56 AS Decimal(6, 2)) DESC NULLS LAST) ORDER BY '9999-05-06 03:25:02.868894' ASC NULLS FIRST;

part of: #17130

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Bug Fix (non-breaking change which fixes an issue)
  • New Feature (non-breaking change which adds functionality)
  • Breaking Change (fix or feature that could cause existing functionality not to work as expected)
  • Documentation Update
  • Refactoring
  • Performance Improvement
  • Other (please describe):

This change is Reviewable

@b41sh b41sh requested review from sundy-li and TCeason January 8, 2025 11:44
@github-actions github-actions bot added the pr-feature this PR introduces a new feature to the codebase label Jan 8, 2025
@b41sh b41sh added this pull request to the merge queue Jan 9, 2025
Merged via the queue into databendlabs:main with commit 2a6c198 Jan 9, 2025
75 checks passed
@b41sh b41sh deleted the feat-fuzzy-query-2 branch January 9, 2025 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-feature this PR introduces a new feature to the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants