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

fix(sql_parse): Provide more lenient logic when extracting latest[_sub]_partition #28152

Conversation

john-bodley
Copy link
Member

SUMMARY

This is a follow up to #28117, which sadly wasn't suffice when variables as opposed to constants were being used with the format() Jinja macro.

Sadly the as_const() method has only been implemented for a subset of node types and given that the plethora of logic which one could define is vast it's likely best to just acknowledge there are times when we wont be able to accurately extract the table referenced by the latest[_sub]_partition Jinja macro.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

Added unit tests.

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

{Table(table="bar", schema="foo")},
),
(
"SELECT * FROM foo.baz WHERE quux = '{{{{ {engine}.{macro} }}}}'",
Copy link
Member Author

Choose a reason for hiding this comment

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

This example no longer exists. It's a trivial extension from the previous logic, but was making the nested parametrization challenging.

]
# Try to extract the table referenced in the macro.
try:
tables.add(
Copy link
Member Author

Choose a reason for hiding this comment

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

Same logic as before, just nested within a try/except block.

@john-bodley john-bodley merged commit c5e7d87 into apache:master Apr 26, 2024
30 checks passed
@john-bodley john-bodley deleted the john-bodley--fix-extract_tables_from_jinja_sql branch April 26, 2024 05:02
qleroy pushed a commit to qleroy/superset that referenced this pull request Apr 28, 2024
@michael-s-molina michael-s-molina added v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch labels Apr 29, 2024
michael-s-molina pushed a commit that referenced this pull request Apr 29, 2024
michael-s-molina pushed a commit that referenced this pull request Apr 29, 2024
jzhao62 pushed a commit to jzhao62/superset that referenced this pull request May 16, 2024
@mistercrunch mistercrunch added 🍒 3.1.3 🍒 4.0.1 🍒 4.0.2 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels labels Jul 2, 2024
vinothkumar66 pushed a commit to vinothkumar66/superset that referenced this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/M v3.1 Label added by the release manager to track PRs to be included in the 3.1 branch v4.0 Label added by the release manager to track PRs to be included in the 4.0 branch 🍒 3.1.3 🍒 4.0.1 🍒 4.0.2 🚢 4.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants