Skip to content

Conversation

galvana
Copy link
Contributor

@galvana galvana commented Jul 29, 2025

Closes ENG-1051

Description Of Changes

Added new behavior for retrieve_data requests with missing database tables.

  • If a table is missing for a leaf-collection (a collection without any downstream dependencies) then the collection is skipped
  • If a table is missing for a collection with downstream dependencies, then the collection still errors

Code Changes

  • Added a missing table check to the exception handler for SQLConnector.retrieve_data
  • Added get_qualified_table_name to SQLConnector (overridden by BigQueryConnector and SnowflakeConnector)
  • Added generic table_exists to SQLConnector
  • Central handling for missing table handling (the new behavior specified above)

Steps to Confirm

  1. Start Fides and the Admin UI
  2. Run the python qa bigquery_table_not_found setup QA scenario
  3. Submit a privacy request for customer-1@example.com
  4. Verify the customer_profile_missing collection is skipped
    image
  5. Run the python qa bigquery_table_not_found setup --table customer QA scenario (note the customer param)
  6. Submit a privacy request for customer-1@example.com
  7. Verify the request errors, since the customer_missing collection has downstream dependencies
    image

Pre-Merge Checklist

  • Issue requirements met
  • All CI pipelines succeeded
  • CHANGELOG.md updated
    • Add a db-migration This indicates that a change includes a database migration label to the entry if your change includes a DB migration
    • Add a high-risk This issue suggests changes that have a high-probability of breaking existing code label to the entry if your change includes a high-risk change (i.e. potential for performance impact or unexpected regression) that should be flagged
    • Updates unreleased work already in Changelog, no new entry necessary
  • Followup issues:
    • Followup issues created
    • No followup issues
  • Database migrations:
    • Ensure that your downrev is up to date with the latest revision on main
    • Ensure that your downgrade() migration is correct and works
      • If a downgrade migration is not possible for this change, please call this out in the PR description!
    • No migrations
  • Documentation:
    • Documentation complete, PR opened in fidesdocs
    • Documentation issue created in fidesdocs
    • If there are any new client scopes created as part of the pull request, remember to update public-facing documentation that references our scope registry
    • No documentation updates required

Copy link

vercel bot commented Jul 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fides-plus-nightly ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 30, 2025 11:28pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
fides-privacy-center ⬜️ Ignored (Inspect) Jul 30, 2025 11:28pm

@@ -30,7 +30,7 @@ def format_clause_for_query(
"""Returns field names in clauses surrounded by quotation marks as required by Snowflake syntax."""
return f'"{string_path}" {operator} (:{operand})'

def _generate_table_name(self) -> str:
def generate_table_name(self) -> str:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changing this from private to public

Comment on lines 193 to 214
try:
self.set_schema(connection)
if (
query_config.partitioning
): # only BigQuery supports partitioning, for now
return self.partitioned_retrieval(query_config, connection, stmt)

results = connection.execute(stmt)
return self.cursor_result_to_rows(results)
except Exception as exc:
# Check if table exists using qualified table name
if not self.table_exists(connection, node):
# Central decision point - will raise TableNotFound or ConnectionException
qualified_table_name = self.get_qualified_table_name(node)
self.handle_table_not_found(
node=node,
table_name=qualified_table_name,
operation_context="data retrieval",
original_exception=exc,
)
# Table exists or can't check - re-raise original exception
raise
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Central handling for missing tables. Instead of checking for table existence before each query, we check after any exception. The other way to check for missing tables would be to parse various exceptions for missing tables but that seemed too fragile.

"""
return node.collection.name

def table_exists(self, connection: Connection, node: ExecutionNode) -> bool:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Generic way to check for table existence using SQLAlchemy. If this fails in any way we assume the table exists to maintain the current behavior.

Copy link

codecov bot commented Jul 29, 2025

Codecov Report

❌ Patch coverage is 36.36364% with 56 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.00%. Comparing base (af6c240) to head (cfac9f0).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/fides/api/service/connectors/sql_connector.py 47.61% 17 Missing and 5 partials ⚠️
...ides/api/service/connectors/snowflake_connector.py 16.00% 21 Missing ⚠️
src/fides/api/graph/execution.py 33.33% 3 Missing and 1 partial ⚠️
.../connectors/query_configs/bigquery_query_config.py 25.00% 3 Missing ⚠️
src/fides/api/service/connectors/base_connector.py 50.00% 2 Missing ⚠️
...fides/api/service/connectors/bigquery_connector.py 33.33% 2 Missing ⚠️
...connectors/query_configs/snowflake_query_config.py 33.33% 2 Missing ⚠️

❌ Your patch status has failed because the patch coverage (36.36%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6397      +/-   ##
==========================================
- Coverage   87.14%   87.00%   -0.14%     
==========================================
  Files         455      455              
  Lines       29179    29252      +73     
  Branches     3244     3256      +12     
==========================================
+ Hits        25427    25451      +24     
- Misses       3025     3069      +44     
- Partials      727      732       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@galvana galvana requested a review from thabofletcher July 29, 2025 04:36
@galvana galvana added the run unsafe ci checks Runs fides-related CI checks that require sensitive credentials label Jul 29, 2025
Copy link
Contributor

@thabofletcher thabofletcher left a comment

Choose a reason for hiding this comment

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

👍 - code looks good but I only had a quick chance to look at it. I ran through your tests though and everything worked great

@galvana galvana merged commit b2b8247 into main Jul 30, 2025
17 checks passed
@galvana galvana deleted the ENG-1051-skip-missing-tables-for-leaf-collections branch July 30, 2025 23:32
Copy link

cypress bot commented Jul 30, 2025

fides    Run #13191

Run Properties:  status check passed Passed #13191  •  git commit b2b82476b6: Skipping missing tables for leaf-collections (#6397)
Project fides
Branch Review main
Run status status check passed Passed #13191
Run duration 00m 53s
Commit git commit b2b82476b6: Skipping missing tables for leaf-collections (#6397)
Committer Adrian Galvan
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 5
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.
View all changes introduced in this branch ↗︎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run unsafe ci checks Runs fides-related CI checks that require sensitive credentials
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants