[importer] Add API endpoint and serializer for creating tables from files#4164
[importer] Add API endpoint and serializer for creating tables from files#4164Harshg999 wants to merge 2 commits into
Conversation
|
|
There was a problem hiding this comment.
Pull Request Overview
Adds a new endpoint and serializer to create SQL tables from file data and wires up a placeholder operation.
- Introduces
CreateTableSerializerto validate request parameters. - Registers the
create_tableAPI route and implements the view. - Adds a stub
create_tablefunction in operations for later implementation.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| desktop/core/src/desktop/lib/importer/serializers.py | New CreateTableSerializer with field and interdependent validations |
| desktop/core/src/desktop/lib/importer/api.py | Added create_table view using the serializer and operation stub |
| desktop/core/src/desktop/lib/importer/operations.py | Stubbed create_table function with signature but no implementation |
| desktop/core/src/desktop/api_public_urls_v1.py | Registered the new importer/table/create route |
Comments suppressed due to low confidence (4)
desktop/core/src/desktop/lib/importer/operations.py:739
- Add a detailed docstring for create_table explaining expected parameters, return format, and error conditions.
def create_table(
desktop/core/src/desktop/lib/importer/serializers.py:178
- Add unit tests for CreateTableSerializer to cover defaulting logic for delimiters and validations of external, Kudu, and Iceberg parameters.
class CreateTableSerializer(serializers.Serializer):
desktop/core/src/desktop/lib/importer/api.py:285
- Include integration tests for the create_table endpoint to verify request validation, error responses, and successful payload structure.
@api_view(["POST"])
desktop/core/src/desktop/lib/importer/operations.py:739
- The signature references List, Dict, Any, Optional but those types are not imported; this will cause a NameError at runtime.
def create_table(
| return mapping[polars_type] | ||
|
|
||
|
|
||
| def create_table( |
There was a problem hiding this comment.
The function body is empty (pass), so calls to create_table will silently return None. Implement the table creation logic or raise NotImplementedError until ready.
| return data | ||
|
|
||
|
|
||
| class CreateTableSerializer(serializers.Serializer): |
There was a problem hiding this comment.
[nitpick] This serializer is very large. Consider extracting file-type–specific and table-format–specific validations into helper methods or nested serializers for readability.
Python Coverage Report •
Pytest Report
|
||||||||||||||||||||||||||||||
|
This PR is stale because it has been open 45 days with no activity and is not labeled "Prevent stale". Remove "stale" label or comment or this will be closed in 10 days. |
This pull request introduces a new API endpoint for creating SQL tables from file data, along with the supporting serializer and backend logic. The changes include defining the
create_tableAPI, implementing the corresponding serializer for request validation, and adding a placeholder function for the table creation operation.Addition of the
create_tableAPI:desktop/core/src/desktop/api_public_urls_v1.py: Added a new route^importer/table/create/? for thecreate_table` API endpoint.desktop/core/src/desktop/lib/importer/api.py: Implemented thecreate_tableAPI, which validates input using theCreateTableSerializer, processes the table creation request, and returns metadata and the SQL query.Serializer for request validation:
desktop/core/src/desktop/lib/importer/api.py: Imported theCreateTableSerializerto validate parameters for thecreate_tableAPI.desktop/core/src/desktop/lib/importer/serializers.py: Defined theCreateTableSerializerclass to validate input parameters such as file path, file type, SQL dialect, and table name, and handle interdependent field validation for specific table formats and file types.Backend logic for table creation:
desktop/core/src/desktop/lib/importer/operations.py: Added a placeholder functioncreate_tableto encapsulate the logic for creating a table based on the provided parameters.