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

Remove hard-coded collation in JDBC adapter #1518

Merged
merged 3 commits into from
Feb 22, 2024
Merged

Conversation

brfrn169
Copy link
Collaborator

@brfrn169 brfrn169 commented Feb 19, 2024

Description

Currently, in the JDBC adapter, we use a hard-coded collation for SQL Server when creating tables. However, we've encountered an issue where Japanese cannot be used with the hard-coded collation in SQL Server. To resolve this, this PR removes the hard-coded collation for SQL Server. For consistency, it also eliminates the hard-coded collation for MySQL. As a result, the collation configured in the database will be used when creating tables.

Related issues and/or PRs

N/A

Changes made

  • Removed the default collation for SQL Server and MySQL in JDBC adapter.
  • Add an integration test for Japanese.

Checklist

  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation to reflect the changes.
  • Any remaining open issues linked to this PR are documented and up-to-date (Jira, GitHub, etc.).
  • Tests (unit, integration, etc.) have been added for the changes.
  • My changes generate no new warnings.
  • Any dependent changes in other PRs have been merged and published.

Additional notes (optional)

N/A

Release notes

Removed the hard-coded collation for MySQL and SQL Server in the JDBC adapter. As a result, the collation configured in the underlying database will be used when creating tables.

@brfrn169 brfrn169 self-assigned this Feb 19, 2024
steps:
- name: Run MySQL 5.7
run: |
docker run -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we need to run MySQL with the collation-related parameters, we run docker run command here.

@@ -607,6 +595,7 @@ jobs:
MSSQL_PID: "Express"
SA_PASSWORD: "SqlServer17"
ACCEPT_EULA: "Y"
MSSQL_COLLATION: "Japanese_BIN2"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for SQL Server, we set MSSQL_COLLATION for the collation.

return new String[] {
"CREATE SCHEMA " + enclose(fullSchema) + " character set utf8 COLLATE utf8_bin"
};
return new String[] {"CREATE SCHEMA " + enclose(fullSchema)};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the hard-coded collation for MySQL.

return new String[] {
"CREATE SCHEMA IF NOT EXISTS " + enclose(schema) + " character set utf8 COLLATE utf8_bin"
};
return new String[] {"CREATE SCHEMA IF NOT EXISTS " + enclose(schema)};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

@@ -176,7 +176,7 @@ public String getDataTypeForEngine(DataType scalarDbDataType) {
case INT:
return "INT";
case TEXT:
return "VARCHAR(8000) COLLATE Latin1_General_BIN";
return "VARCHAR(8000)";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the hard-coded collation for SQL Server.

import org.junit.jupiter.api.TestInstance;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public abstract class DistributedStorageJapaneseIntegrationTestBase {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an integration test for Japanese.

@brfrn169 brfrn169 changed the title Remove default collation in JDBC adapter Remove hard-coded collation in JDBC adapter Feb 19, 2024
Copy link
Contributor

@komamitsu komamitsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 👍

Copy link
Contributor

@feeblefakie feeblefakie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@brfrn169
Copy link
Collaborator Author

@kota2and3kan As discussed, I've added an integration test for Japanese Hankaku in f670592. Please take a look when you have time!

Copy link
Contributor

@kota2and3kan kota2and3kan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants