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(Views): updated views to reflect refactors #1582

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

scaliseraoul
Copy link
Contributor

@scaliseraoul scaliseraoul commented Feb 3, 2025


Important

Refactor view handling and SQL query execution, update schema management, and enhance file operations with absolute paths.

  • Behavior:
    • Updated create() in __init__.py to use absolute paths for parquet files.
    • Modified _execute_local_sql_query() in base.py to register DataFrames using schema.name.
    • Enhanced _execute_sql_query() in base.py to check for schema.source before executing local queries.
  • Schema and Query Handling:
    • Refactored SemanticLayerSchema in semantic_layer_schema.py to include is_compatible_source().
    • Updated QueryBuilder and ViewQueryBuilder to handle view-based queries with JOINs.
    • Modified CodeCleaner in code_cleaning.py to clean SQL queries using schema.name.
  • File Management:
    • Added abs_path() method to FileManager in filemanager.py for absolute path resolution.
    • Updated LocalDatasetLoader in local_loader.py to use abs_path() for file operations.
  • Testing:
    • Added tests for view handling and SQL query execution in test_agent.py, test_loader.py, and test_sql_loader.py.
    • Updated test_code_cleaning.py to test SQL query cleaning with new schema handling.

This description was created by Ellipsis for ac57b4a. It will automatically update as commits are pushed.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot 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! Reviewed everything up to ac57b4a in 2 minutes and 51 seconds

More details
  • Looked at 850 lines of code in 21 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 drafted comments based on config settings.
1. tests/unit_tests/agent/test_agent.py:97
  • Draft comment:
    Use assert_called_once_with() instead of 'called_with()'. Replace 'assert mock_generate_code.validate_and_clean_code.called_with(cached_code)' with 'mock_generate_code.validate_and_clean_code.assert_called_once_with(cached_code)'.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
2. tests/unit_tests/agent/test_agent.py:66
  • Draft comment:
    Ensure that the code string returned for code generation contains proper quotes. For example, change 'print(United States has the highest gdp)' to "print('United States has the highest gdp')".
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
3. tests/unit_tests/prompts/test_sql_prompt.py:64
  • Draft comment:
    Review the multi-line expected prompt string for clarity and consistent formatting; consider simplifying the prompt template for readability.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    None
4. tests/unit_tests/data_loader/test_sql_loader.py:49
  • Draft comment:
    Verify the SQL query formatting in mocks. For example, check that table names are correctly substituted, matching changes from using schema.name instead of schema.source.table.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
5. tests/unit_tests/data_loader/test_loader.py:60
  • Draft comment:
    Ensure that schema name sanitization is consistent; consider adding comments if the transformation from non-sanitized to sanitized name is intentional.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
6. tests/unit_tests/conftest.py:145
  • Draft comment:
    Consider adding type hints for fixtures that return dict[str, MagicMock] for better readability.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    None
7. tests/unit_tests/test_config.py:52
  • Draft comment:
    Improve error message grammar in test cases: e.g., 'validate_llm with langchain integration' should read 'Validating llm with Langchain integration'.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    None
8. tests/unit_tests/agent/test_agent.py:97
  • Draft comment:
    Use 'assert_called_with(cached_code)' instead of 'called_with(cached_code)' to properly verify that the cached code is used.
  • Reason this comment was not posted:
    Comment was not on a location in the diff, so it can't be submitted as a review comment.
9. pandasai/data_loader/view_query_builder.py:47
  • Draft comment:
    The construction of the FROM clause in _get_from_statement is quite complex. Consider refactoring to a more robust query builder method or adding more inline comments to clarify the logic.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The comment is somewhat vague - it doesn't specify how to refactor or what specific parts need clarification. The code is already modular with helper methods. While more comments could help, the logic flow is fairly straightforward for SQL query building. The suggestion to "refactor to a more robust query builder" is not concrete enough.
    The code could potentially benefit from some documentation. Breaking down the large method into smaller pieces might improve readability.
    While documentation could help, the comment doesn't provide specific enough guidance to be actionable. The code is already reasonably modular with helper methods.
    The comment should be deleted as it's too vague to be actionable and the code structure is already reasonably clear with helper methods.
10. pandasai/data_loader/query_builder.py:33
  • Draft comment:
    Ensure consistent use of table naming conventions. Other parts of the code now use 'schema.name' whereas this method uses 'schema.source.table.lower()'.
  • Reason this comment was not posted:
    Comment was on unchanged code.

Workflow ID: wflow_mnJR8znKrCXJNEze


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Collaborator

@gventuri gventuri left a comment

Choose a reason for hiding this comment

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

Seems all great to me. Left couple of minor comments, good to merge afterwards!

pandasai/agent/base.py Outdated Show resolved Hide resolved
pandasai/data_loader/semantic_layer_schema.py Show resolved Hide resolved
pandasai/data_loader/view_loader.py Outdated Show resolved Hide resolved
@gventuri gventuri merged commit 1c47fe8 into sinaptik-ai:main Feb 4, 2025
12 checks passed
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.

3 participants