diff --git a/docs/en/connector-v2/sink/Jdbc.md b/docs/en/connector-v2/sink/Jdbc.md index 4114b1ca1b9b..01b7b711903f 100644 --- a/docs/en/connector-v2/sink/Jdbc.md +++ b/docs/en/connector-v2/sink/Jdbc.md @@ -108,16 +108,17 @@ In the case of is_exactly_once = "true", Xa transactions are used. This requires there are some reference value for params above. -| datasource | driver | url | xa_data_source_class_name | maven | -|------------| -------------------------------------------- | ------------------------------------------------------------ | -------------------------------------------------- | ------------------------------------------------------------ | -| MySQL | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | com.mysql.cj.jdbc.MysqlXADataSource | https://mvnrepository.com/artifact/mysql/mysql-connector-java | -| PostgreSQL | org.postgresql.Driver | jdbc:postgresql://localhost:5432/postgres | org.postgresql.xa.PGXADataSource | https://mvnrepository.com/artifact/org.postgresql/postgresql | -| DM | dm.jdbc.driver.DmDriver | jdbc:dm://localhost:5236 | dm.jdbc.driver.DmdbXADataSource | https://mvnrepository.com/artifact/com.dameng/DmJdbcDriver18 | -| Phoenix | org.apache.phoenix.queryserver.client.Driver | jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF | / | https://mvnrepository.com/artifact/com.aliyun.phoenix/ali-phoenix-shaded-thin-client | -| SQL Server | com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:microsoft:sqlserver://localhost:1433 | com.microsoft.sqlserver.jdbc.SQLServerXADataSource | https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc | -| Oracle | oracle.jdbc.OracleDriver | jdbc:oracle:thin:@localhost:1521/xepdb1 | oracle.jdbc.xa.OracleXADataSource | https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 | -| GBase8a | com.gbase.jdbc.Driver | jdbc:gbase://e2e_gbase8aDb:5258/test | / | https://www.gbase8.cn/wp-content/uploads/2020/10/gbase-connector-java-8.3.81.53-build55.5.7-bin_min_mix.jar | -| StarRocks | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | / | https://mvnrepository.com/artifact/mysql/mysql-connector-java | +| datasource | driver | url | xa_data_source_class_name | maven | +|------------|----------------------------------------------|--------------------------------------------------------------------|----------------------------------------------------|-------------------------------------------------------------------------------------------------------------| +| MySQL | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | com.mysql.cj.jdbc.MysqlXADataSource | https://mvnrepository.com/artifact/mysql/mysql-connector-java | +| PostgreSQL | org.postgresql.Driver | jdbc:postgresql://localhost:5432/postgres | org.postgresql.xa.PGXADataSource | https://mvnrepository.com/artifact/org.postgresql/postgresql | +| DM | dm.jdbc.driver.DmDriver | jdbc:dm://localhost:5236 | dm.jdbc.driver.DmdbXADataSource | https://mvnrepository.com/artifact/com.dameng/DmJdbcDriver18 | +| Phoenix | org.apache.phoenix.queryserver.client.Driver | jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF | / | https://mvnrepository.com/artifact/com.aliyun.phoenix/ali-phoenix-shaded-thin-client | +| SQL Server | com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:microsoft:sqlserver://localhost:1433 | com.microsoft.sqlserver.jdbc.SQLServerXADataSource | https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc | +| Oracle | oracle.jdbc.OracleDriver | jdbc:oracle:thin:@localhost:1521/xepdb1 | oracle.jdbc.xa.OracleXADataSource | https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 | +| GBase8a | com.gbase.jdbc.Driver | jdbc:gbase://e2e_gbase8aDb:5258/test | / | https://www.gbase8.cn/wp-content/uploads/2020/10/gbase-connector-java-8.3.81.53-build55.5.7-bin_min_mix.jar | +| StarRocks | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | / | https://mvnrepository.com/artifact/mysql/mysql-connector-java | +| saphana | com.sap.db.jdbc.Driver | jdbc:sap://localhost:39015 | / | https://mvnrepository.com/artifact/com.sap.cloud.db.jdbc/ngdbc | ## Example diff --git a/docs/en/connector-v2/source/Jdbc.md b/docs/en/connector-v2/source/Jdbc.md index 79a45048f86f..65c6af87a7e1 100644 --- a/docs/en/connector-v2/source/Jdbc.md +++ b/docs/en/connector-v2/source/Jdbc.md @@ -90,16 +90,17 @@ in parallel according to the concurrency of tasks. there are some reference value for params above. -| datasource | driver | url | maven | -| ---------- | -------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------------------------ | -| mysql | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | https://mvnrepository.com/artifact/mysql/mysql-connector-java | -| postgresql | org.postgresql.Driver | jdbc:postgresql://localhost:5432/postgres | https://mvnrepository.com/artifact/org.postgresql/postgresql | -| dm | dm.jdbc.driver.DmDriver | jdbc:dm://localhost:5236 | https://mvnrepository.com/artifact/com.dameng/DmJdbcDriver18 | -| phoenix | org.apache.phoenix.queryserver.client.Driver | jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF | https://mvnrepository.com/artifact/com.aliyun.phoenix/ali-phoenix-shaded-thin-client | -| sqlserver | com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:microsoft:sqlserver://localhost:1433 | https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc | -| oracle | oracle.jdbc.OracleDriver | jdbc:oracle:thin:@localhost:1521/xepdb1 | https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 | -| gbase8a | com.gbase.jdbc.Driver | jdbc:gbase://e2e_gbase8aDb:5258/test | https://www.gbase8.cn/wp-content/uploads/2020/10/gbase-connector-java-8.3.81.53-build55.5.7-bin_min_mix.jar | -| starrocks | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | https://mvnrepository.com/artifact/mysql/mysql-connector-java | +| datasource | driver | url | maven | +|------------|----------------------------------------------|--------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------| +| mysql | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | https://mvnrepository.com/artifact/mysql/mysql-connector-java | +| postgresql | org.postgresql.Driver | jdbc:postgresql://localhost:5432/postgres | https://mvnrepository.com/artifact/org.postgresql/postgresql | +| dm | dm.jdbc.driver.DmDriver | jdbc:dm://localhost:5236 | https://mvnrepository.com/artifact/com.dameng/DmJdbcDriver18 | +| phoenix | org.apache.phoenix.queryserver.client.Driver | jdbc:phoenix:thin:url=http://localhost:8765;serialization=PROTOBUF | https://mvnrepository.com/artifact/com.aliyun.phoenix/ali-phoenix-shaded-thin-client | +| sqlserver | com.microsoft.sqlserver.jdbc.SQLServerDriver | jdbc:microsoft:sqlserver://localhost:1433 | https://mvnrepository.com/artifact/com.microsoft.sqlserver/mssql-jdbc | +| oracle | oracle.jdbc.OracleDriver | jdbc:oracle:thin:@localhost:1521/xepdb1 | https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc8 | +| gbase8a | com.gbase.jdbc.Driver | jdbc:gbase://e2e_gbase8aDb:5258/test | https://www.gbase8.cn/wp-content/uploads/2020/10/gbase-connector-java-8.3.81.53-build55.5.7-bin_min_mix.jar | +| starrocks | com.mysql.cj.jdbc.Driver | jdbc:mysql://localhost:3306/test | https://mvnrepository.com/artifact/mysql/mysql-connector-java | +| saphana | com.sap.db.jdbc.Driver | jdbc:sap://localhost:39015 | https://mvnrepository.com/artifact/com.sap.cloud.db.jdbc/ngdbc | ## Example diff --git a/seatunnel-connectors-v2/connector-jdbc/pom.xml b/seatunnel-connectors-v2/connector-jdbc/pom.xml index 7e49bcce0cea..98995b2d2ff4 100644 --- a/seatunnel-connectors-v2/connector-jdbc/pom.xml +++ b/seatunnel-connectors-v2/connector-jdbc/pom.xml @@ -36,6 +36,7 @@ 9.2.1.jre8 5.2.5-HBase-2.x 12.2.0.1 + 2.14.7 @@ -76,7 +77,13 @@ ${oracle.version} provided - + + + com.sap.cloud.db.jdbc + ngdbc + ${saphana.version} + provided + @@ -108,6 +115,11 @@ com.oracle.database.jdbc ojdbc8 + + + com.sap.cloud.db.jdbc + ngdbc + diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaDialect.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaDialect.java new file mode 100644 index 000000000000..be8819e00b7a --- /dev/null +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaDialect.java @@ -0,0 +1,40 @@ +/* + * 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.saphana; + +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.JdbcRowConverter; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; + +public class SapHanaDialect implements JdbcDialect { + @Override + public String dialectName() { + return "SapHana"; + } + + @Override + public JdbcRowConverter getRowConverter() { + return new SapHanaJdbcRowConverter(); + } + + @Override + public JdbcDialectTypeMapper getJdbcDialectTypeMapper() { + return new SapHanaTypeMapper(); + } +} diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaDialectFactory.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaDialectFactory.java new file mode 100644 index 000000000000..592059449679 --- /dev/null +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaDialectFactory.java @@ -0,0 +1,41 @@ +/* + * 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.saphana; + +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialect; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectFactory; + +import com.google.auto.service.AutoService; + +/** + * Dialect Factory of {@link SapHanaDialect} + */ + +@AutoService(JdbcDialectFactory.class) +public class SapHanaDialectFactory implements JdbcDialectFactory { + @Override + public boolean acceptsURL(String url) { + return url.startsWith("jdbc:sap://"); + } + + @Override + public JdbcDialect create() { + return new SapHanaDialect(); + } +} diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaJdbcRowConverter.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaJdbcRowConverter.java new file mode 100644 index 000000000000..c524b7cfc169 --- /dev/null +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaJdbcRowConverter.java @@ -0,0 +1,28 @@ +/* + * 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.saphana; + +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.converter.AbstractJdbcRowConverter; + +public class SapHanaJdbcRowConverter extends AbstractJdbcRowConverter { + @Override + public String converterName() { + return "SapHana"; + } +} diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaTypeMapper.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaTypeMapper.java new file mode 100644 index 000000000000..2e4291d65a26 --- /dev/null +++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/saphana/SapHanaTypeMapper.java @@ -0,0 +1,107 @@ +/* + * 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.saphana; + +import org.apache.seatunnel.api.table.type.BasicType; +import org.apache.seatunnel.api.table.type.DecimalType; +import org.apache.seatunnel.api.table.type.LocalTimeType; +import org.apache.seatunnel.api.table.type.PrimitiveByteArrayType; +import org.apache.seatunnel.api.table.type.SeaTunnelDataType; +import org.apache.seatunnel.connectors.seatunnel.jdbc.internal.dialect.JdbcDialectTypeMapper; + +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.Locale; + +public class SapHanaTypeMapper implements JdbcDialectTypeMapper { + + // refer to https://help.sap.com/docs/SAP_BUSINESSOBJECTS_BUSINESS_INTELLIGENCE_PLATFORM/aa4cb9ab429349e49678e146f05d7341/ec3313286fdb101497906a7cb0e91070.html?locale=zh-CN + private static final String SAP_HANA_BLOB = "blob"; + private static final String SAP_HANA_VARBINARY = "varbinary"; + private static final String SAP_HANA_DATE = "date"; + private static final String SAP_HANA_TIME = "time"; + private static final String SAP_HANA_LONGDATE = "longtime"; + private static final String SAP_HANA_SECONDDATE = "seconddate"; + private static final String SAP_HANA_TIMESTAMP = "timestamp"; + private static final String SAP_HANA_DECIMAL = "decimal"; + private static final String SAP_HANA_REAL = "real"; + private static final String SAP_HANA_SMALLDECIMAL = "smalldecimal"; + private static final String SAP_HANA_BIGINT = "bigint"; + private static final String SAP_HANA_INTEGER = "integer"; + private static final String SAP_HANA_SMALLINT = "smallint"; + private static final String SAP_HANA_TINYINT = "tinyint"; + private static final String SAP_HANA_DOUBLE = "double"; + private static final String SAP_HANA_CLOB = "clob"; + private static final String SAP_HANA_NCLOB = "nclob"; + private static final String SAP_HANA_TEXT = "text"; + private static final String SAP_HANA_ALPHANUM = "alphanum"; + private static final String SAP_HANA_NVARCHAR = "nvarchar"; + private static final String SAP_HANA_SHORTTEXT = "shorttext"; + private static final String SAP_HANA_VARCHAR = "varchar"; + private static final String SAP_HANA_BINARY = "binary"; + + @Override + public SeaTunnelDataType mapping(ResultSetMetaData metadata, int colIndex) throws SQLException { + String typeName = metadata.getColumnTypeName(colIndex).toLowerCase(Locale.ROOT); + + int precision = metadata.getPrecision(colIndex); + int scale = metadata.getScale(colIndex); + + switch (typeName) { + case SAP_HANA_BLOB: + case SAP_HANA_VARBINARY: + case SAP_HANA_BINARY: + return PrimitiveByteArrayType.INSTANCE; + case SAP_HANA_DATE: + return LocalTimeType.LOCAL_DATE_TYPE; + case SAP_HANA_TIME: + return LocalTimeType.LOCAL_TIME_TYPE; + case SAP_HANA_TIMESTAMP: + case SAP_HANA_LONGDATE: + case SAP_HANA_SECONDDATE: + return LocalTimeType.LOCAL_DATE_TIME_TYPE; + case SAP_HANA_DECIMAL: + return new DecimalType(precision, scale); + case SAP_HANA_REAL: + case SAP_HANA_SMALLDECIMAL: + return BasicType.FLOAT_TYPE; + case SAP_HANA_BIGINT: + case SAP_HANA_INTEGER: + case SAP_HANA_SMALLINT: + case SAP_HANA_TINYINT: + return BasicType.INT_TYPE; + case SAP_HANA_DOUBLE: + return BasicType.DOUBLE_TYPE; + case SAP_HANA_CLOB: + case SAP_HANA_NCLOB: + case SAP_HANA_TEXT: + case SAP_HANA_ALPHANUM: + case SAP_HANA_NVARCHAR: + case SAP_HANA_SHORTTEXT: + case SAP_HANA_VARCHAR: + return BasicType.STRING_TYPE; + default: + final String jdbcColumnName = metadata.getColumnName(colIndex); + throw new UnsupportedOperationException( + String.format( + "Doesn't support SapHana type '%s' on column '%s' yet.", + typeName, jdbcColumnName)); + } + } +} diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/pom.xml b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/pom.xml index 2a65167729da..975a8f31307f 100644 --- a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/pom.xml +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/pom.xml @@ -76,6 +76,11 @@ ojdbc8 test + + com.sap.cloud.db.jdbc + ngdbc + test + diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/AbstractJdbcIT.java b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/AbstractJdbcIT.java index 4e9088003c1b..84eb95dd8154 100644 --- a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/AbstractJdbcIT.java +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/java/org/apache/seatunnel/connectors/seatunnel/jdbc/AbstractJdbcIT.java @@ -37,6 +37,7 @@ import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.output.Slf4jLogConsumer; import org.testcontainers.lifecycle.Startables; +import org.testcontainers.utility.DockerLoggerFactory; import java.io.IOException; import java.net.MalformedURLException; @@ -83,7 +84,7 @@ private void getContainer() throws SQLException, MalformedURLException, ClassNot .withNetwork(NETWORK) .withNetworkAliases(jdbcCase.getNetworkAliases()) .withEnv(jdbcCase.getContainerEnv()) - .withLogConsumer(new Slf4jLogConsumer(log)); + .withLogConsumer(new Slf4jLogConsumer(DockerLoggerFactory.getLogger(jdbcCase.getDockerImage()))); dbServer.setPortBindings(Lists.newArrayList( String.format("%s:%s", jdbcCase.getPort(), jdbcCase.getPort()))); Startables.deepStart(Stream.of(dbServer)).join(); diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/resources/init/saphana_init.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/resources/init/saphana_init.conf new file mode 100644 index 000000000000..a2a727e176db --- /dev/null +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/resources/init/saphana_init.conf @@ -0,0 +1,89 @@ +# +# 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. +# + +sap_hana_table_source = """ +-- auto-generated definition +create table E2E_TEST.E2E_TABLE_SOURCE +( + BLOB_VAL BLOB, + VARBINARY_VAL VARBINARY(1), + DATE_VAL DATE(10), + TIME_VAL TIME(8), + LONGDATE_VAL TIMESTAMP(27, 7), + SECONDDATE_VAL SECONDDATE(19), + TIMESTAMP_VAL TIMESTAMP(27,7), + DECIMAL_VAL DECIMAL(34), + REAL_VAL REAL(7), + SMALLDECIMAL_VAL SMALLDECIMAL(16), + BIGINT_VAL BIGINT(19), + INTEGER_VAL INTEGER, + SMALLINT_VAL SMALLINT(5), + TINYINT_VAL TINYINT(3), + DOUBLE_VAL DOUBLE(15), + CLOB_VAL CLOB, + NCLOB_VAL NCLOB(715827882), + TEXT_VAL TEXT(0) + constraint "_SYS_FULLTEXT_166583_#0_#TEXT_VAL" + unique, + ALPHANUM_VAL ALPHANUM(1), + NVARCHAR_VAL NVARCHAR(1), + SHORTTEXT_VAL VARCHAR(1), + VARCHAR_VAL VARCHAR(1) +); +""" + +sap_hana_table_sink = """ +-- auto-generated definition +create table E2E_TEST.E2E_TABLE_SINK +( + BLOB_VAL BLOB, + VARBINARY_VAL VARBINARY(1), + DATE_VAL DATE(10), + TIME_VAL TIME(8), + LONGDATE_VAL TIMESTAMP(27, 7), + SECONDDATE_VAL SECONDDATE(19), + TIMESTAMP_VAL TIMESTAMP(27,7), + DECIMAL_VAL DECIMAL(34), + REAL_VAL REAL(7), + SMALLDECIMAL_VAL SMALLDECIMAL(16), + BIGINT_VAL BIGINT(19), + INTEGER_VAL INTEGER, + SMALLINT_VAL SMALLINT(5), + TINYINT_VAL TINYINT(3), + DOUBLE_VAL DOUBLE(15), + CLOB_VAL CLOB, + NCLOB_VAL NCLOB(715827882), + TEXT_VAL TEXT(0) + constraint "_SYS_FULLTEXT_166583_#0_#TEXT_VAL" + unique, + ALPHANUM_VAL ALPHANUM(1), + NVARCHAR_VAL NVARCHAR(1), + SHORTTEXT_VAL VARCHAR(1), + VARCHAR_VAL VARCHAR(1) +); +""" + +// only for sap_hana_table_source +DML = """ +insert into E2E_TEST.E2E_TABLE_SOURCE (BLOB_VAL, VARBINARY_VAL, DATE_VAL, TIME_VAL, LONGDATE_VAL, SECONDDATE_VAL, + TIMESTAMP_VAL, DECIMAL_VAL, REAL_VAL, SMALLDECIMAL_VAL, BIGINT_VAL, INTEGER_VAL, + SMALLINT_VAL, TINYINT_VAL, DOUBLE_VAL, CLOB_VAL, NCLOB_VAL, TEXT_VAL, ALPHANUM_VAL, + NVARCHAR_VAL, SHORTTEXT_VAL, VARCHAR_VAL) +values (TO_BLOB(TO_BINARY('abc')), '1', '2022-10-08', '13:14:00', '2022-10-08', '2022-10-08', '2022-10-08 13:14:00', + 13.14, 13.14, 13.14, 11, 22, 33, 1, 13.14, TO_CLOB('xxx'), 'xxx', 'xxx', TO_ALPHANUM(1), 'x', 'x', + TO_VARCHAR('x')); +""" \ No newline at end of file diff --git a/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/resources/jdbc_sap_hana_source_and_sink.conf b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/resources/jdbc_sap_hana_source_and_sink.conf new file mode 100644 index 000000000000..ccaeaeedb7c4 --- /dev/null +++ b/seatunnel-e2e/seatunnel-connector-v2-e2e/connector-jdbc-e2e/src/test/resources/jdbc_sap_hana_source_and_sink.conf @@ -0,0 +1,54 @@ +# +# 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. +# + +env { + execution.parallelism = 1 + job.mode = "BATCH" +} + +source { + Jdbc { + url = "jdbc:sap://e2e_saphana:39015" + driver = "com.sap.db.jdbc.Driver" + connection_check_timeout_sec = 1000 + user = "SYSDBA" + password = "SYSDBA" + query = """select * from E2E_TEST.E2E_TABLE_SOURCE""" + } + +} + +transform { +} + +sink { + Jdbc { + url = "jdbc:sap://e2e_saphana:39015" + driver = "com.sap.db.jdbc.Driver" + connection_check_timeout_sec = 1000 + user = "SYSDBA" + password = "SYSDBA" + query = """ +INSERT INTO E2E_TEST.E2E_TABLE_SOURCE (BLOB_VAL, VARBINARY_VAL, DATE_VAL, TIME_VAL, LONGDATE_VAL, SECONDDATE_VAL, + TIMESTAMP_VAL, DECIMAL_VAL, REAL_VAL, SMALLDECIMAL_VAL, BIGINT_VAL, INTEGER_VAL, + SMALLINT_VAL, TINYINT_VAL, DOUBLE_VAL, CLOB_VAL, NCLOB_VAL, TEXT_VAL, ALPHANUM_VAL, + NVARCHAR_VAL, SHORTTEXT_VAL, VARCHAR_VAL) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?); +""" + } +} +