mathesar icon indicating copy to clipboard operation
mathesar copied to clipboard

Implementation for column mappings

Open Anish9901 opened this issue 2 years ago • 1 comments

Fixes #1508

This PR introduces the implementation of column mappings which will be used as a part of the import process while the records are to be imported from one table to another so that a user can exactly specify which column from the import file/temp_table should map to which specific columns of the target table.

Technical details

POST /api/db/v0/tables/<temp_table_id>/existing_import/

Request

{
    "import_target": <target_table_id>,
    "data_files": [<data_file_id>],
    "mappings": [
                    [<temp_table_col1_id>,<target_table_col1_id>],
                    [<temp_table_col2_id>,<target_table_col2_id>]
                ]
}

Checklist

  • [x] My pull request has a descriptive title (not a vague title like Update index.md).
  • [x] My pull request targets the master branch of the repository
  • [x] My commit messages follow best practices.
  • [x] My code follows the established code style of the repository.
  • [ ] I added tests for the changes I made (if applicable).
  • [ ] I added or updated documentation (if applicable).
  • [x] I tried running the project locally and verified that there are no visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

Anish9901 avatar Aug 08 '22 15:08 Anish9901

Codecov Report

Merging #1506 (1433840) into master (01a4bdd) will increase coverage by 0.02%. The diff coverage is 53.33%.

@@            Coverage Diff             @@
##           master    #1506      +/-   ##
==========================================
+ Coverage   92.49%   92.52%   +0.02%     
==========================================
  Files         142      142              
  Lines        6305     6314       +9     
==========================================
+ Hits         5832     5842      +10     
+ Misses        473      472       -1     
Flag Coverage Δ
pytest-backend 92.52% <53.33%> (+0.02%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
mathesar/models/base.py 92.55% <0.00%> (-0.84%) :arrow_down:
mathesar/api/serializers/tables.py 89.04% <40.00%> (-1.87%) :arrow_down:
db/records/operations/insert.py 95.74% <100.00%> (+16.19%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov-commenter avatar Aug 08 '22 15:08 codecov-commenter