Skip to content

feat: implement RLS in sqlglot#33524

Merged
betodealmeida merged 1 commit intomasterfrom
sqlglot-rls
May 28, 2025
Merged

feat: implement RLS in sqlglot#33524
betodealmeida merged 1 commit intomasterfrom
sqlglot-rls

Conversation

@betodealmeida
Copy link
Member

@betodealmeida betodealmeida commented May 19, 2025

SUMMARY

Part of #26786, stacked on:

Implement the RLS logic in sqlglot, using both strategies currently supported: as a predicate, or as a subquery.

This PR only implements the logic, but doesn't hook it up yet. That will come next.

I added unit tests for all cases current tested for the sqlparse logic.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot bot added the authentication:row-level-security Related to Row Level Security label May 19, 2025
# "dremio": ???
"drill": Dialects.DRILL,
# "druid": ???
"druid": Dialects.DRUID,
Copy link
Member Author

Choose a reason for hiding this comment

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

I added this to sqlglot a while ago.

assert SQLStatement(sql, engine).as_cte().format() == expected


@pytest.mark.parametrize(
Copy link
Member Author

Choose a reason for hiding this comment

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

These tests are all copied from superset/tests/unit_tests/sql_parse_tests.py, except a few that are not relevant.

@korbit-ai
Copy link

korbit-ai bot commented May 19, 2025

I was unable to post the issues I found. This could be because a force push or squash has changed the commit history since I scanned this pull request. You can get another review by commenting /korbit-review.

Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

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

LGTM

Base automatically changed from sqlglot-cte to master May 28, 2025 12:38
@betodealmeida betodealmeida merged commit 0abe6ee into master May 28, 2025
50 of 51 checks passed
@betodealmeida betodealmeida deleted the sqlglot-rls branch May 28, 2025 13:10
LevisNgigi pushed a commit to LevisNgigi/superset that referenced this pull request Jun 18, 2025
@github-actions github-actions bot added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 6.0.0 First shipped in 6.0.0 labels Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

authentication:row-level-security Related to Row Level Security 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset-io size/XL 🚢 6.0.0 First shipped in 6.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants