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

Valid format for Array<String> in loading CSV data #308

Closed
vedantsali opened this issue Jul 17, 2024 · 1 comment
Closed

Valid format for Array<String> in loading CSV data #308

vedantsali opened this issue Jul 17, 2024 · 1 comment

Comments

@vedantsali
Copy link

Is there a valid format for loading data using csv file is one of the column is array of strings

listId;listName;applicationName;isActive;description;type;createdBy;createdOn;updatedBy;updatedOn
10;Timezone;[xyz];true;Global Timezones;;SYSTEM;PENDING_COMMIT_TIMESTAMP();SYSTEM;PENDING_COMMIT_TIMESTAMP()

@olavloite
Copy link
Collaborator

@vedantsali No, unfortunately that is not supported:

  1. Liquibase does not have any built-in support for loading arrays. All data types that Liquibase does not have any special handling for will be passed on to the underlying JDBC driver as a string.
  2. Spanner and the Spanner JDBC driver do not support any automatic conversion from a string to an array when it is given as a PreparedStatement parameter.

Instead of using loadData for this, I would recommend that you create a sql change set. That allows you to run any set of SQL statements, which again allows you to specify an array literal. See this for YAML example:

databaseChangeLog:
  - preConditions:
     onFail: HALT
     onError: HALT
  - changeSet:
     id:     v0.1-insert-data-with-sql
     author: spanner-liquibase-tests
     changes:
       - sql: |
           insert into my_table (id, name, other_languages)
           select 1, 'One', ['En', 'Eins', 'Uno']
           union all
           select 2, 'Two', ['To', 'Zwei', 'Dos'];
           
           insert into my_table (id, name, other_languages)
           select 3, 'Three', ['Tre', 'Drei', 'Tres']
           union all
           select 4, 'Four', ['Fire', 'Vier', 'Cuatro'];

https://github.com/cloudspannerecosystem/liquibase-spanner/blob/44d1f080cbf9c26359b9b84091d63a9ca3701df0/src/test/resources/sql.yaml

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

No branches or pull requests

2 participants