⚡ Sangsakala Proxy 🏠 Home
Skip to content

Implement ORDER BY Clause Handling for SELECT DISTINCT in DatabendRandomQuerySynthesizer #1159

Open

Description

@Saahi30

In the DatabendRandomQuerySynthesizer.java file, there is a TODO comment indicating that when generating SELECT DISTINCT queries, the ORDER BY expressions must appear in the select list. This functionality is currently not implemented, and we need to address this to ensure compliance with SQL standards.

The code snippet I am talking aboutt:

if (Randomly.getBoolean() && !noExprColumns.isEmpty() && !isDistinct) {
    select.setOrderByClauses(Randomly.nonEmptySubset(noExprColumns));
    // TODO (for SELECT DISTINCT, ORDER BY expressions must appear in select list)
    // isDistinct
    // 需要orderby输入每个select list,可以用数字代替比如:1,2,3...
}

What I'll Do

  1. Modify the logic in the DatabendRandomQuerySynthesizer to ensure that when isDistinct is true, the ORDER BY clauses are derived from the select list.
  2. Implement a mechanism to allow ORDER BY expressions to reference the select list by their position (e.g., using numbers like 1, 2, 3...).
  3. Add unit tests to verify that the generated queries comply with the SQL standard for SELECT DISTINCT.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions