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

Ordering of columns not preserved in JDBC mapping vs table in external store [HZ-1556] #22410

Closed
sumnerib opened this issue Oct 5, 2022 · 2 comments · Fixed by #22760
Closed
Assignees
Labels
Source: Internal PR or issue was opened by an employee Team: SQL to-jira Type: Defect
Milestone

Comments

@sumnerib
Copy link
Contributor

sumnerib commented Oct 5, 2022

Describe the bug
When creating a JDBC SQL mapping without specifying the columns (like in below example), the column order is reversed compared to that in remote source table. This affects statements such as SELECT * FROM ... and INSERT INTO <mapping> VALUES.

CREATE MAPPING people
TYPE JDBC 
OPTIONS (
  'externalDataStoreRef'='mysql-database' 
)

Expected behavior
A clear and concise description of what you expected to happen.

To Reproduce

Steps to reproduce the behavior:

  1. Start a member with an external-data-store configured
  2. Create a JDBC mapping referencing the data store. This should be done without provide any columns explicitly (like above).
  3. Execute SELECT * FROM <jdbc-mapping> or INSERT INTO <jdbc-mapping> VALUES to observe the behavior

Additional context

A potential workaround is to specify the columns in the desired order when creating the mapping. For example:

CREATE MAPPING people (
 id INT, 
 name VARCHAR 
) 
TYPE JDBC 
OPTIONS ( 
 'externalDataStoreRef'='mysql-database'
)
@github-actions github-actions bot changed the title Ordering of columns not preserved in JDBC mapping vs table in external store Ordering of columns not preserved in JDBC mapping vs table in external store [HZ-1556] Oct 5, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

Internal Jira issue: HZ-1556

@viliam-durina viliam-durina added this to the 5.3.0 milestone Oct 5, 2022
@viliam-durina
Copy link
Contributor

viliam-durina commented Oct 5, 2022

The column order isn't exactly reversed, but is lost because we put the columns into a HashMap here:

Map<String, DbField> fields = new HashMap<>();
for (int i = 1; i <= metaData.getColumnCount(); i++) {
String columnName = metaData.getColumnName(i);
fields.put(columnName,
new DbField(metaData.getColumnTypeName(i),
columnName,
pkColumns.contains(columnName)
));
}
return fields;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Internal PR or issue was opened by an employee Team: SQL to-jira Type: Defect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants