Skip to content

Generated unique temp table names in DataProcessor#17

Open
mysticBliss wants to merge 2 commits into
mainfrom
code-health-unique-temp-table-3827690947800499909
Open

Generated unique temp table names in DataProcessor#17
mysticBliss wants to merge 2 commits into
mainfrom
code-health-unique-temp-table-3827690947800499909

Conversation

@mysticBliss

Copy link
Copy Markdown
Owner

What:

  • Modified datamov/core/data_processor/DataProcessor.py to import uuid and generate a unique temporary table name in create_temp_table_and_resultant_df.
  • The format used is temp_<uuid_hex>.
  • Added tests/test_data_processor.py to test this behavior.

Why:

  • Hardcoded table names can lead to race conditions or data overwrites if multiple jobs run concurrently or sequentially within the same Spark session context.
  • Using a unique identifier ensures isolation for each transformation step.

Verification:

  • Ran tests/test_data_processor.py which confirmed that the generated table names are unique and distinct from the old hardcoded name.
  • Ran existing tests (tests/test_integration.py) and verified via logs that the integration flow also uses the new unique table name format (e.g., temp_4f38dfbb9c6647648f1c4ebb0c1cdbea). Note: test_integration.py fails due to a pre-existing unrelated mocking issue, but the log output confirms the fix is active.

PR created automatically by Jules for task 3827690947800499909 started by @mysticBliss

Replaced the hardcoded temporary table name 'datamov_tmp' with a unique name generated using UUID (prefixed with 'temp_') to avoid potential collisions during concurrent execution or when reusing the Spark session.

Added `tests/test_data_processor.py` to verify that `create_temp_table_and_resultant_df` generates unique table names for each call.

Co-authored-by: mysticBliss <11345806+mysticBliss@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Updated `tests/conftest.py` to attempt importing `pyspark` and `great_expectations` before falling back to mocks. This ensures that in environments where these packages are installed (like CI), the real packages are used.
- Updated `tests/test_integration.py` to defensively configure the `spark` fixture mock if it is an instance of `MagicMock`. This sets the return value of `.count()` to an integer to avoid `TypeError: '>' not supported between instances of 'MagicMock' and 'int'`.
- Verified locally that tests pass with these changes.

Co-authored-by: mysticBliss <11345806+mysticBliss@users.noreply.github.com>
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.

1 participant