Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dinmukhamedm
Copy link
Member

@dinmukhamedm dinmukhamedm commented Jun 23, 2025

Important

Allow CTEs in SQL editor by updating SQLValidator to track and handle CTE aliases.

  • Behavior:
    • Allows CTEs in SQL queries by tracking CTE aliases in SQLValidator.
    • Updates whitelist check to include CTE aliases in validateAndTranspile().
    • Ensures project_id conditions are not applied to CTEs in processSubqueries().
  • Classes:
    • Adds withAliases set to SQLValidator to store CTE aliases.
  • Functions:
    • Modifies validateAndTranspile() to populate withAliases with CTE names.
    • Updates processSubqueries() to skip project_id application for CTEs.

This description was created by Ellipsis for 971b3cf. You can customize this summary. It will automatically update as commits are pushed.

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed 971b3cf in 47 seconds. Click for details.
  • Reviewed 12 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/lib/sql/transpile.ts:98
  • Draft comment:
    Removed debug logging. Avoid use of console.log in production; use proper logger if needed.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.

Workflow ID: wflow_H98V1jRVFO9rdgy1

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

Caution

Changes requested ❌

Reviewed everything up to ea36d65 in 1 minute and 49 seconds. Click for details.
  • Reviewed 52 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. frontend/lib/sql/transpile.ts:45
  • Draft comment:
    New 'withAliases' property added. Ensure that its use (e.g. via union) is supported in your JS environment.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to ensure that the new 'withAliases' property is supported in their JS environment. This falls under the rule of not asking the author to ensure behavior is intended or tested. The comment does not provide a specific suggestion or point out a specific issue with the code.
2. frontend/lib/sql/transpile.ts:74
  • Draft comment:
    Extracting WITH clause aliases looks good; verify that all CTE entries have the expected structure to avoid undefined values.
  • Reason this comment was not posted:
    Confidence changes required: 30% <= threshold 50% None
3. frontend/lib/sql/transpile.ts:302
  • Draft comment:
    The additional check '!this.withAliases.has(mainTable)' ensures CTES alias are skipped for project_id filtering. Confirm this aligns with intended business logic.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to confirm if the additional check aligns with the intended business logic. This falls under asking the author to confirm their intention, which is against the rules. Therefore, this comment should be removed.

Workflow ID: wflow_UkDzTClCIgKzNDIW

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

try {
this.parser.whiteListCheck(sqlQuery,
allowedTables,
[`(select)::(.*)::(${Array.from(this.allowedTables.union(this.withAliases)).join('|')})`],
Copy link
Contributor

Choose a reason for hiding this comment

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

Using 'union' on Set is non-standard in JavaScript. Consider using 'new Set([...this.allowedTables, ...this.withAliases])' for compatibility.

Suggested change
[`(select)::(.*)::(${Array.from(this.allowedTables.union(this.withAliases)).join('|')})`],
[`(select)::(.*)::(${Array.from(new Set([...this.allowedTables, ...this.withAliases])).join('|')})`],

}
// Transpile the query
const transpiled = this.transpileQuery(ast, projectId);
console.log(transpiled.sql);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove or replace the console.log of transpiled SQL before production deployment.

Suggested change
console.log(transpiled.sql);

@dinmukhamedm dinmukhamedm merged commit e7d7838 into dev Jun 24, 2025
3 checks passed
@dinmukhamedm dinmukhamedm deleted the sql-editor/allow-ctes branch June 24, 2025 14:41
olzhik11 added a commit that referenced this pull request Jun 26, 2025
* estimate span size before any processing (#654)

* Feat/lam 682 (#655)

* feat: update delete project, fix spans filters

* fix: rendering, model fallback

* feat: move delete endpoint to next

* feat: fix margins

* feat: update delete project data in ch, fix comments

* fix: command

* feat: add debug console

* feat: move helper function

* allow CTES in SQL editor (#653)

* allow CTES in SQL editor

* remove debug console.log

* fix reset usage when upgrading (#657)

* Hotfix/ack browser events (#660)

* first ack browser events, then increment usage

* don't wait for async insert on browser events

* feat: fix decode key by passing in docker file (#661)

* feat: fix decode key by passing in docker file

* feat: add key to full build

---------

Co-authored-by: Dinmukhamed Mailibay <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants