yzeng1618 commented on code in PR #10521: URL: https://github.com/apache/seatunnel/pull/10521#discussion_r2887210717
########## docs/en/connectors/source/SingleStore.md: ########## @@ -0,0 +1,142 @@ +import ChangeLog from '../changelog/connector-jdbc.md'; + +# SingleStore + +> JDBC SingleStore Source Connector + +## Description + +Read data from SingleStore (formerly MemSQL) through JDBC. SingleStore is a high-performance real-time analytical database that is MySQL-compatible. The connector uses the JDBC source with the SingleStore dialect. + +## Supported SingleStore Version + +- **SingleStore v7.1+** (tested on 7.1 and later). This version range is required for the JDBC driver and MySQL-compatible SQL (e.g. `SHOW TABLE STATUS`, `CRC32`, `ON DUPLICATE KEY UPDATE`) used by the connector. Earlier versions are not officially supported and may have compatibility differences. + +## Support Those Engines + +> Spark<br/> +> Flink<br/> +> SeaTunnel Zeta<br/> + +## Using Dependency + +### For Spark/Flink Engine + +> 1. You need to ensure that the [SingleStore JDBC driver](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) has been placed in directory `${SEATUNNEL_HOME}/plugins/`. The connector is built and tested with `singlestore-jdbc-client` 1.2.8; other versions may work but compatibility and security should be verified. + +### For SeaTunnel Zeta Engine + +> 1. You need to ensure that the [SingleStore JDBC driver](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) has been placed in directory `${SEATUNNEL_HOME}/lib/`. + +## Key Features + +- [x] [batch](../../introduction/concepts/connector-v2-features.md) +- [ ] [stream](../../introduction/concepts/connector-v2-features.md) +- [x] [exactly-once](../../introduction/concepts/connector-v2-features.md) +- [x] [column projection](../../introduction/concepts/connector-v2-features.md) +- [x] [parallelism](../../introduction/concepts/connector-v2-features.md) +- [x] [support user-defined split](../../introduction/concepts/connector-v2-features.md) +- [x] [support multiple table reading](../../introduction/concepts/connector-v2-features.md) + +## Supported DataSource Info + +| Datasource | Driver | URL | Maven | +|-------------|-----------------------------|------------------------------------------|-----------------------------------------------------------------------| +| SingleStore | com.singlestore.jdbc.Driver | jdbc:singlestore://host:3306/database | [Download](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) | + +### Connection URL Format + +The SingleStore JDBC URL has the following format: + +``` +jdbc:singlestore:[loadbalance:|sequential:]//<host>[:port]/[database][?<key1>=<value1>[&<key2>=<value2>]] +``` + +- Default port is `3306`. +- Example: `jdbc:singlestore://localhost:3306/test?user=root&password=myPassword` +- For load balancing: `jdbc:singlestore:loadbalance://host1,host2/db` +- For sequential failover: `jdbc:singlestore:sequential://host1,host2/db` + +## Data Type Mapping + +SingleStore is MySQL-compatible. Data type mapping follows the same as [MySQL JDBC Source](Mysql.md#data-type-mapping) (TINYINT, INT, BIGINT, VARCHAR, TEXT, DATETIME, etc.). + +## FAQ / Troubleshooting + +| Issue | Possible cause | Suggestion | +|-------|----------------|------------| +| Connection refused or timeout | Wrong host/port, firewall, or SingleStore not running | Check URL format `jdbc:singlestore://host:port/database`, default port 3306. Ensure the database is reachable. | +| "No suitable driver" or ClassNotFoundException | JDBC driver not on classpath | Place `singlestore-jdbc-client` JAR in `${SEATUNNEL_HOME}/plugins/` (Spark/Flink) or `${SEATUNNEL_HOME}/lib/` (Zeta). | +| Split or sampling errors | SingleStore version or SQL differences | Use SingleStore 7.1+. If you see errors on `SHOW TABLE STATUS` or `CRC32`, report the SingleStore version. | +| Upsert or batch write failures | Syntax or driver behavior | Ensure `rewriteBatchedStatements=true` in URL or properties. Verify primary key columns and table schema. | +| Schema evolution (ALTER TABLE) issues | DDL inherited from MySQL dialect | Test ADD/MODIFY/DROP COLUMN on your SingleStore version; document any differences. | + +## Manual integration testing + +There is no Testcontainers image for SingleStore in this project. To validate the connector against a real SingleStore instance: + +1. Start SingleStore 7.1+ (e.g. Docker or cloud). +2. Create a database and table, then run a small job with the JDBC source (and optionally sink) using the config examples above. +3. Verify split behavior (parallelism), upsert, and batch writes if using the sink. +4. If you use Schema Evolution, run ADD/MODIFY/DROP COLUMN and confirm the job continues correctly. + +## Source Options + +All options of the [JDBC Source](Jdbc.md) connector apply. Key options for SingleStore: + +| Name | Type | Required | Default | Description | +|-------------|--------|----------|---------|-----------------------------------------------------------------------------| +| url | String | Yes | - | JDBC connection URL. Example: `jdbc:singlestore://localhost:3306/test` | +| driver | String | Yes | - | JDBC driver class: `com.singlestore.jdbc.Driver` | +| username | String | No | - | Database user name | +| password | String | No | - | Database password | +| query | String | No | - | Query statement. Use either `query` or `table_path` / `table_list` | +| table_path | String | No | - | Full table path, e.g. `mydb.mytable` | +| dialect | String | No | - | Optional. Set to `SingleStore` when URL does not start with `jdbc:singlestore:` | + +## Example + +### Read by table_path + +```hocon +source { + Jdbc { + url = "jdbc:singlestore://localhost:3306/test" + driver = "com.singlestore.jdbc.Driver" + user = "root" Review Comment: Parameter inconsistency ########## docs/en/connectors/source/SingleStore.md: ########## @@ -0,0 +1,142 @@ +import ChangeLog from '../changelog/connector-jdbc.md'; + +# SingleStore + +> JDBC SingleStore Source Connector + +## Description + +Read data from SingleStore (formerly MemSQL) through JDBC. SingleStore is a high-performance real-time analytical database that is MySQL-compatible. The connector uses the JDBC source with the SingleStore dialect. + +## Supported SingleStore Version + +- **SingleStore v7.1+** (tested on 7.1 and later). This version range is required for the JDBC driver and MySQL-compatible SQL (e.g. `SHOW TABLE STATUS`, `CRC32`, `ON DUPLICATE KEY UPDATE`) used by the connector. Earlier versions are not officially supported and may have compatibility differences. + +## Support Those Engines + +> Spark<br/> +> Flink<br/> +> SeaTunnel Zeta<br/> + +## Using Dependency + +### For Spark/Flink Engine + +> 1. You need to ensure that the [SingleStore JDBC driver](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) has been placed in directory `${SEATUNNEL_HOME}/plugins/`. The connector is built and tested with `singlestore-jdbc-client` 1.2.8; other versions may work but compatibility and security should be verified. + +### For SeaTunnel Zeta Engine + +> 1. You need to ensure that the [SingleStore JDBC driver](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) has been placed in directory `${SEATUNNEL_HOME}/lib/`. + +## Key Features + +- [x] [batch](../../introduction/concepts/connector-v2-features.md) +- [ ] [stream](../../introduction/concepts/connector-v2-features.md) +- [x] [exactly-once](../../introduction/concepts/connector-v2-features.md) +- [x] [column projection](../../introduction/concepts/connector-v2-features.md) +- [x] [parallelism](../../introduction/concepts/connector-v2-features.md) +- [x] [support user-defined split](../../introduction/concepts/connector-v2-features.md) +- [x] [support multiple table reading](../../introduction/concepts/connector-v2-features.md) + +## Supported DataSource Info + +| Datasource | Driver | URL | Maven | +|-------------|-----------------------------|------------------------------------------|-----------------------------------------------------------------------| +| SingleStore | com.singlestore.jdbc.Driver | jdbc:singlestore://host:3306/database | [Download](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) | + +### Connection URL Format + +The SingleStore JDBC URL has the following format: + +``` +jdbc:singlestore:[loadbalance:|sequential:]//<host>[:port]/[database][?<key1>=<value1>[&<key2>=<value2>]] +``` + +- Default port is `3306`. +- Example: `jdbc:singlestore://localhost:3306/test?user=root&password=myPassword` +- For load balancing: `jdbc:singlestore:loadbalance://host1,host2/db` +- For sequential failover: `jdbc:singlestore:sequential://host1,host2/db` + +## Data Type Mapping + +SingleStore is MySQL-compatible. Data type mapping follows the same as [MySQL JDBC Source](Mysql.md#data-type-mapping) (TINYINT, INT, BIGINT, VARCHAR, TEXT, DATETIME, etc.). + +## FAQ / Troubleshooting + +| Issue | Possible cause | Suggestion | +|-------|----------------|------------| +| Connection refused or timeout | Wrong host/port, firewall, or SingleStore not running | Check URL format `jdbc:singlestore://host:port/database`, default port 3306. Ensure the database is reachable. | +| "No suitable driver" or ClassNotFoundException | JDBC driver not on classpath | Place `singlestore-jdbc-client` JAR in `${SEATUNNEL_HOME}/plugins/` (Spark/Flink) or `${SEATUNNEL_HOME}/lib/` (Zeta). | +| Split or sampling errors | SingleStore version or SQL differences | Use SingleStore 7.1+. If you see errors on `SHOW TABLE STATUS` or `CRC32`, report the SingleStore version. | +| Upsert or batch write failures | Syntax or driver behavior | Ensure `rewriteBatchedStatements=true` in URL or properties. Verify primary key columns and table schema. | +| Schema evolution (ALTER TABLE) issues | DDL inherited from MySQL dialect | Test ADD/MODIFY/DROP COLUMN on your SingleStore version; document any differences. | + +## Manual integration testing + +There is no Testcontainers image for SingleStore in this project. To validate the connector against a real SingleStore instance: + +1. Start SingleStore 7.1+ (e.g. Docker or cloud). +2. Create a database and table, then run a small job with the JDBC source (and optionally sink) using the config examples above. +3. Verify split behavior (parallelism), upsert, and batch writes if using the sink. +4. If you use Schema Evolution, run ADD/MODIFY/DROP COLUMN and confirm the job continues correctly. + +## Source Options + +All options of the [JDBC Source](Jdbc.md) connector apply. Key options for SingleStore: + +| Name | Type | Required | Default | Description | +|-------------|--------|----------|---------|-----------------------------------------------------------------------------| +| url | String | Yes | - | JDBC connection URL. Example: `jdbc:singlestore://localhost:3306/test` | +| driver | String | Yes | - | JDBC driver class: `com.singlestore.jdbc.Driver` | +| username | String | No | - | Database user name | +| password | String | No | - | Database password | +| query | String | No | - | Query statement. Use either `query` or `table_path` / `table_list` | +| table_path | String | No | - | Full table path, e.g. `mydb.mytable` | +| dialect | String | No | - | Optional. Set to `SingleStore` when URL does not start with `jdbc:singlestore:` | + +## Example + +### Read by table_path + +```hocon +source { + Jdbc { + url = "jdbc:singlestore://localhost:3306/test" + driver = "com.singlestore.jdbc.Driver" + user = "root" + password = "myPassword" + table_path = "test.my_table" + } +} +``` + +### Read by query + +```hocon +source { + Jdbc { + url = "jdbc:singlestore://localhost:3306/test" + driver = "com.singlestore.jdbc.Driver" + user = "root" + password = "myPassword" + query = "SELECT * FROM my_table WHERE id > 100" + } +} +``` + +### With connection parameters + +```hocon +source { + Jdbc { + url = "jdbc:singlestore://localhost:3306/test?rewriteBatchedStatements=true" + driver = "com.singlestore.jdbc.Driver" + user = "root" Review Comment: ditto ########## seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/singlestore/SingleStoreDialect.java: ########## @@ -0,0 +1,77 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.singlestore; + +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.JdbcRowConverter; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.mysql.MysqlDialect; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.mysql.MysqlJdbcRowConverter; + +/** + * JDBC dialect for SingleStore (formerly MemSQL), a high-performance real-time analytical database. + * + * <p>SingleStore is designed to be MySQL-compatible. This dialect extends {@link MysqlDialect} and + * reuses the following MySQL behaviors without modification. Compatibility has been validated for + * the connector's use cases; if you use Schema Evolution or other advanced DDL, validate against + * your SingleStore version. + * + * <ul> + * <li>Type mapping and {@link + * org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.JdbcRowConverter} – + * delegated to the MySQL implementation while reporting SingleStore in {@code converterName} + * for clearer error messages. + * <li>Upsert syntax – {@code INSERT ... ON DUPLICATE KEY UPDATE} (see {@link + * MysqlDialect#getUpsertStatement(String, String, String[], String[])}). + * <li>Split / sampling – {@code SHOW TABLE STATUS}, {@code CRC32} for hash-based split (see + * {@link MysqlDialect#approximateRowCntStatement} and {@link MysqlDialect#hashModForField}). + * <li>Batch – {@code rewriteBatchedStatements=true} (see {@link MysqlDialect#defaultParameter}). + * <li>Schema change (DDL) – ALTER TABLE ADD/MODIFY/DROP COLUMN logic is inherited from MySQL; + * behavior on SingleStore should be validated if you use Schema Evolution. + * </ul> + * + * @see MysqlDialect + * @see org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.mysql.MysqlJdbcRowConverter + * @see org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.mysql.MySqlTypeConverter + */ +public class SingleStoreDialect extends MysqlDialect { + + public SingleStoreDialect() {} + + /** + * @param fieldIde field identifier mode (e.g. LOWERCASE, UPPERCASE, ORIGINAL); null or empty is + * treated as original by the base dialect. + */ + public SingleStoreDialect(String fieldIde) { + super(fieldIde); + } + + @Override + public JdbcRowConverter getRowConverter() { + return new MysqlJdbcRowConverter() { + @Override + public String converterName() { + return DatabaseIdentifier.SINGLESTORE; + } + }; + } Review Comment: Anonymous classes create a new instance on every call and are not serializable, which can cause issues in distributed execution.Consider extracting the anonymous class into a named ########## docs/en/connectors/source/SingleStore.md: ########## @@ -0,0 +1,142 @@ +import ChangeLog from '../changelog/connector-jdbc.md'; + +# SingleStore + +> JDBC SingleStore Source Connector + +## Description + +Read data from SingleStore (formerly MemSQL) through JDBC. SingleStore is a high-performance real-time analytical database that is MySQL-compatible. The connector uses the JDBC source with the SingleStore dialect. + +## Supported SingleStore Version + +- **SingleStore v7.1+** (tested on 7.1 and later). This version range is required for the JDBC driver and MySQL-compatible SQL (e.g. `SHOW TABLE STATUS`, `CRC32`, `ON DUPLICATE KEY UPDATE`) used by the connector. Earlier versions are not officially supported and may have compatibility differences. + +## Support Those Engines + +> Spark<br/> +> Flink<br/> +> SeaTunnel Zeta<br/> + +## Using Dependency + +### For Spark/Flink Engine + +> 1. You need to ensure that the [SingleStore JDBC driver](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) has been placed in directory `${SEATUNNEL_HOME}/plugins/`. The connector is built and tested with `singlestore-jdbc-client` 1.2.8; other versions may work but compatibility and security should be verified. + +### For SeaTunnel Zeta Engine + +> 1. You need to ensure that the [SingleStore JDBC driver](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) has been placed in directory `${SEATUNNEL_HOME}/lib/`. + +## Key Features + +- [x] [batch](../../introduction/concepts/connector-v2-features.md) +- [ ] [stream](../../introduction/concepts/connector-v2-features.md) +- [x] [exactly-once](../../introduction/concepts/connector-v2-features.md) +- [x] [column projection](../../introduction/concepts/connector-v2-features.md) +- [x] [parallelism](../../introduction/concepts/connector-v2-features.md) +- [x] [support user-defined split](../../introduction/concepts/connector-v2-features.md) +- [x] [support multiple table reading](../../introduction/concepts/connector-v2-features.md) + +## Supported DataSource Info + +| Datasource | Driver | URL | Maven | +|-------------|-----------------------------|------------------------------------------|-----------------------------------------------------------------------| +| SingleStore | com.singlestore.jdbc.Driver | jdbc:singlestore://host:3306/database | [Download](https://mvnrepository.com/artifact/com.singlestore/singlestore-jdbc-client) | + +### Connection URL Format + +The SingleStore JDBC URL has the following format: + +``` +jdbc:singlestore:[loadbalance:|sequential:]//<host>[:port]/[database][?<key1>=<value1>[&<key2>=<value2>]] +``` + +- Default port is `3306`. +- Example: `jdbc:singlestore://localhost:3306/test?user=root&password=myPassword` +- For load balancing: `jdbc:singlestore:loadbalance://host1,host2/db` +- For sequential failover: `jdbc:singlestore:sequential://host1,host2/db` + +## Data Type Mapping + +SingleStore is MySQL-compatible. Data type mapping follows the same as [MySQL JDBC Source](Mysql.md#data-type-mapping) (TINYINT, INT, BIGINT, VARCHAR, TEXT, DATETIME, etc.). + +## FAQ / Troubleshooting + +| Issue | Possible cause | Suggestion | +|-------|----------------|------------| +| Connection refused or timeout | Wrong host/port, firewall, or SingleStore not running | Check URL format `jdbc:singlestore://host:port/database`, default port 3306. Ensure the database is reachable. | +| "No suitable driver" or ClassNotFoundException | JDBC driver not on classpath | Place `singlestore-jdbc-client` JAR in `${SEATUNNEL_HOME}/plugins/` (Spark/Flink) or `${SEATUNNEL_HOME}/lib/` (Zeta). | +| Split or sampling errors | SingleStore version or SQL differences | Use SingleStore 7.1+. If you see errors on `SHOW TABLE STATUS` or `CRC32`, report the SingleStore version. | +| Upsert or batch write failures | Syntax or driver behavior | Ensure `rewriteBatchedStatements=true` in URL or properties. Verify primary key columns and table schema. | +| Schema evolution (ALTER TABLE) issues | DDL inherited from MySQL dialect | Test ADD/MODIFY/DROP COLUMN on your SingleStore version; document any differences. | + +## Manual integration testing + +There is no Testcontainers image for SingleStore in this project. To validate the connector against a real SingleStore instance: + +1. Start SingleStore 7.1+ (e.g. Docker or cloud). +2. Create a database and table, then run a small job with the JDBC source (and optionally sink) using the config examples above. +3. Verify split behavior (parallelism), upsert, and batch writes if using the sink. +4. If you use Schema Evolution, run ADD/MODIFY/DROP COLUMN and confirm the job continues correctly. + +## Source Options + +All options of the [JDBC Source](Jdbc.md) connector apply. Key options for SingleStore: + +| Name | Type | Required | Default | Description | +|-------------|--------|----------|---------|-----------------------------------------------------------------------------| +| url | String | Yes | - | JDBC connection URL. Example: `jdbc:singlestore://localhost:3306/test` | +| driver | String | Yes | - | JDBC driver class: `com.singlestore.jdbc.Driver` | +| username | String | No | - | Database user name | +| password | String | No | - | Database password | +| query | String | No | - | Query statement. Use either `query` or `table_path` / `table_list` | +| table_path | String | No | - | Full table path, e.g. `mydb.mytable` | +| dialect | String | No | - | Optional. Set to `SingleStore` when URL does not start with `jdbc:singlestore:` | + +## Example + +### Read by table_path + +```hocon +source { + Jdbc { + url = "jdbc:singlestore://localhost:3306/test" + driver = "com.singlestore.jdbc.Driver" + user = "root" + password = "myPassword" + table_path = "test.my_table" + } +} +``` + +### Read by query + +```hocon +source { + Jdbc { + url = "jdbc:singlestore://localhost:3306/test" + driver = "com.singlestore.jdbc.Driver" + user = "root" Review Comment: ditto ########## seatunnel-connectors-v2/connector-jdbc/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/singlestore/SingleStoreDialectTest.java: ########## @@ -0,0 +1,161 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.singlestore; + +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.DatabaseIdentifier; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.Optional; + +/** Unit tests for {@link SingleStoreDialect}. */ +public class SingleStoreDialectTest { + + @Test + public void testDialectName() { + SingleStoreDialect dialect = new SingleStoreDialect(); + Assertions.assertEquals(DatabaseIdentifier.SINGLESTORE, dialect.dialectName()); + } + + @Test + public void testRowConverter() { + SingleStoreDialect dialect = new SingleStoreDialect(); + Assertions.assertNotNull(dialect.getRowConverter()); + Assertions.assertEquals( + DatabaseIdentifier.SINGLESTORE, dialect.getRowConverter().converterName()); + } + + @Test + public void testTypeConverter() { + SingleStoreDialect dialect = new SingleStoreDialect(); + Assertions.assertNotNull(dialect.getTypeConverter()); + } + + @Test + public void testQuoteIdentifier() { + SingleStoreDialect dialect = new SingleStoreDialect(); + Assertions.assertEquals("`col`", dialect.quoteIdentifier("col")); + } + + @Test + public void testTableIdentifier() { + SingleStoreDialect dialect = new SingleStoreDialect(); + Assertions.assertEquals("`mydb`.`mytable`", dialect.tableIdentifier("mydb", "mytable")); + } + + @Test + public void testUpsertStatement() { + SingleStoreDialect dialect = new SingleStoreDialect(); + String[] fieldNames = new String[] {"id", "name", "value"}; + String[] uniqueKeyFields = new String[] {"id"}; + Optional<String> upsert = + dialect.getUpsertStatement("db", "t", fieldNames, uniqueKeyFields); + Assertions.assertTrue(upsert.isPresent()); + Assertions.assertTrue(upsert.get().contains("ON DUPLICATE KEY UPDATE")); + Assertions.assertTrue(upsert.get().contains("`id`=VALUES(`id`)")); + Assertions.assertTrue(upsert.get().contains("`name`=VALUES(`name`)")); + Assertions.assertTrue(upsert.get().contains("`value`=VALUES(`value`)")); + } + + @Test + public void testHashModForField() { + SingleStoreDialect dialect = new SingleStoreDialect(); + String expr = dialect.hashModForField("pk", 10); + Assertions.assertTrue(expr.contains("CRC32")); + Assertions.assertTrue(expr.contains("`pk`")); + Assertions.assertTrue(expr.contains("10")); + } + + @Test + public void testDefaultParameter() { + SingleStoreDialect dialect = new SingleStoreDialect(); + Assertions.assertTrue(dialect.defaultParameter().containsKey("rewriteBatchedStatements")); + Assertions.assertEquals("true", dialect.defaultParameter().get("rewriteBatchedStatements")); + } + + @Test + public void testSingleStoreDialectFactoryAcceptsUrl() { + SingleStoreDialectFactory factory = new SingleStoreDialectFactory(); + Assertions.assertTrue(factory.acceptsURL("jdbc:singlestore://localhost:3306/test")); + Assertions.assertTrue(factory.acceptsURL("jdbc:singlestore:loadbalance://host1,host2/db")); + Assertions.assertTrue(factory.acceptsURL("jdbc:singlestore://host/database")); + Assertions.assertFalse(factory.acceptsURL("jdbc:mysql://localhost:3306/test")); + Assertions.assertFalse(factory.acceptsURL(null)); + } + + @Test + public void testSingleStoreDialectFactoryRejectsMalformedUrl() { + SingleStoreDialectFactory factory = new SingleStoreDialectFactory(); + Assertions.assertFalse(factory.acceptsURL("jdbc:singlestore://")); + Assertions.assertFalse(factory.acceptsURL("jdbc:singlestore:///database")); + Assertions.assertFalse(factory.acceptsURL("jdbc:singlestore:loadbalance://")); + Assertions.assertFalse(factory.acceptsURL("jdbc:singlestore://host:abc/db")); + Assertions.assertFalse(factory.acceptsURL("jdbc:singlestore://host:0/db")); + Assertions.assertFalse(factory.acceptsURL("jdbc:singlestore://host:65536/db")); + } + + @Test + public void testSingleStoreDialectFactoryDialectName() { + SingleStoreDialectFactory factory = new SingleStoreDialectFactory(); + Assertions.assertEquals(DatabaseIdentifier.SINGLESTORE, factory.dialectFactoryName()); Review Comment: missing validation for the SINGLESTORE constant -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
