Skip to content

Add SQL tests for prepare_temp_table_for_import and insert_from_select #4928

@Anish9901

Description

@Anish9901

Description

During the development of bulk_insert aka Import into existing tables, we ran into bugs caused by some edge cases. Even though these bugs are now fixed, it would be good to have SQL tests for these so that we could avoid regressions in the future.

Affects users

None

This may change if we do end up finding more bugs while writing tests.

Affects developers

Low

Having these test would mean that we would avoid running into regressions in the future. This could also help us discover more bugs during the process of adding these tests.

Suggested change

Tests to be added:

  • For msar.prepare_temp_table_for_import
    • Passing one or more columns named id doesn't throw an error.
    • A TEMPORARY TABLE is actually created on the database with or without a given tab_name.
    • Happy case: Valid tab_name and col_names create a temporary table on the database with expected table and column names and return the copy_sql and table_oid for the relevant temporary table.
  • For msar.insert_from_select
    • An error is thrown when inserting when mapping is made from a text type column into integer type column, i.e. there is a mismatch in datatypes of src and destination table and the src columns cannot be casted to valid dst column types.
    • Happy case: Records from the given src table are inserted into dst table according to the mappings provided.

Additional context

Feature implementation PRs: #4870, #4880

Metadata

Metadata

Assignees

No one assigned

    Labels

    affects: technical debtImproves the state of the codebasehelp wantedCommunity contributors can implement thisreadyReady for implementationwork: db-layerRelated to SQL or PL/pgSQL

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions