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

Add standalone AnalyzerRule example that implements row level access control #11089

Merged
merged 7 commits into from
Jul 5, 2024

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jun 23, 2024

Which issue does this PR close?

Closes #10855

Rationale for this change

It is common to use DataFusion to analyze / modify queries, so it would be good to have some more full featured examples of doing so.

Additionally, the current rewrite_expr.rs example has three distinct examples:

  1. Using DataFusion LogicalPlanning without execution
  2. Implementing an AnalyzerRule
  3. Implementing an OptimizerRule

Each I think should be its own example to make them easier to find and more full featured

What changes are included in this PR?

  1. Add example analyzer_rule.rs that implements "row level access control". I was inspired by @goldmedal 's description of Wren's usecase in Add example for writing an AnalyzerRule #10855 (comment) to pick the row level access control example

Are these changes tested?

By CI

Are there any user-facing changes?

@alamb alamb force-pushed the alamb/analyzer_rule branch from 3ef7b8e to 78d271f Compare June 24, 2024 03:38
@alamb alamb changed the title Add standlone example AnalyzerRule Add standlone example AnalyzerRule that implements row level access control Jun 24, 2024
@alamb alamb marked this pull request as ready for review June 24, 2024 19:55
Copy link
Contributor

@goldmedal goldmedal left a comment

Choose a reason for hiding this comment

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

Thanks @alamb -- I think this example clearly shows how to use the AnalyzerRule and TreeNode APIs. LGTM.

// | Andrew | 22 | Manager |
// | Chunchun | 44 | Manager |
// +----------+-----+----------+
rule.set_show_position("Manager");
Copy link
Contributor

Choose a reason for hiding this comment

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

Gave me a lot of inspiration. It's exactly what a semantic engine will do.

datafusion-examples/examples/analyzer_rule.rs Outdated Show resolved Hide resolved
datafusion-examples/examples/analyzer_rule.rs Outdated Show resolved Hide resolved
Copy link
Member

@jonahgao jonahgao left a comment

Choose a reason for hiding this comment

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

Looks good to me!

datafusion-examples/examples/analyzer_rule.rs Outdated Show resolved Hide resolved
datafusion-examples/examples/analyzer_rule.rs Outdated Show resolved Hide resolved
@alamb alamb changed the title Add standlone example AnalyzerRule that implements row level access control Add standalone example AnalyzerRule that implements row level access control Jul 5, 2024
@alamb alamb changed the title Add standalone example AnalyzerRule that implements row level access control Add standalone AnalyzerRule example that implements row level access control Jul 5, 2024
@alamb
Copy link
Contributor Author

alamb commented Jul 5, 2024

Thank you for the review @jonahgao and @goldmedal

@alamb alamb merged commit dce77db into apache:main Jul 5, 2024
23 of 25 checks passed
@alamb alamb deleted the alamb/analyzer_rule branch July 5, 2024 12:46
comphead pushed a commit to comphead/arrow-datafusion that referenced this pull request Jul 8, 2024
…s control (apache#11089)

* Add standlone example AnalyzerRule

* Apply suggestions from code review

Co-authored-by: Jax Liu <[email protected]>

* update for api change

* Apply suggestions from code review

Co-authored-by: Jonah Gao <[email protected]>

---------

Co-authored-by: Jax Liu <[email protected]>
Co-authored-by: Jonah Gao <[email protected]>
findepi pushed a commit to findepi/datafusion that referenced this pull request Jul 16, 2024
…s control (apache#11089)

* Add standlone example AnalyzerRule

* Apply suggestions from code review

Co-authored-by: Jax Liu <[email protected]>

* update for api change

* Apply suggestions from code review

Co-authored-by: Jonah Gao <[email protected]>

---------

Co-authored-by: Jax Liu <[email protected]>
Co-authored-by: Jonah Gao <[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.

Add example for writing an AnalyzerRule
3 participants