This is an automated email from the ASF dual-hosted git repository. jackietien pushed a commit to branch ty/mysql-connector in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit 3c8478c107c15b8962f8724b8e94f4bd4ac1c6c4 Author: JackieTien97 <[email protected]> AuthorDate: Fri Jun 27 16:45:15 2025 +0800 Add support for pg --- library-udf/pom.xml | 7 +- ...on.java => BaseJDBCConnectorTableFunction.java} | 68 ++++-- .../connector/CassandraConnectorTableFunction.java | 22 ++ .../ClickhouseConnectorTableFunction.java | 22 ++ .../connector/DorisConnectorTableFunction.java | 22 ++ .../connector/MongoDBConnectorTableFunction.java | 22 ++ .../connector/MySqlConnectorTableFunction.java | 245 ++------------------- .../PostgreSqlConnectorTableFunction.java | 62 ++++++ .../connector/RedisConnectorTableFunction.java | 22 ++ .../connector/SnowflakeConnectorTableFunction.java | 22 ++ pom.xml | 1 - 11 files changed, 267 insertions(+), 248 deletions(-) diff --git a/library-udf/pom.xml b/library-udf/pom.xml index f51d839ca59..d2a78b6e4ab 100644 --- a/library-udf/pom.xml +++ b/library-udf/pom.xml @@ -46,7 +46,12 @@ <dependency> <groupId>com.mysql</groupId> <artifactId>mysql-connector-j</artifactId> - <version>${mysql.jdbc.version}</version> + <version>9.3.0</version> + </dependency> + <dependency> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>42.7.7</version> </dependency> <dependency> <groupId>org.apache.iotdb</groupId> diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MySqlConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/BaseJDBCConnectorTableFunction.java similarity index 79% copy from library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MySqlConnectorTableFunction.java copy to library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/BaseJDBCConnectorTableFunction.java index d7745e545d9..908b39916cd 100644 --- a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MySqlConnectorTableFunction.java +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/BaseJDBCConnectorTableFunction.java @@ -1,3 +1,22 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; import org.apache.iotdb.library.relational.tablefunction.connector.converter.ResultSetConverter; @@ -37,18 +56,18 @@ import java.util.Map; import static org.apache.iotdb.library.relational.tablefunction.connector.JDBCConnectionPool.translateJDBCTypeToUDFType; -public class MySqlConnectorTableFunction implements TableFunction { +abstract class BaseJDBCConnectorTableFunction implements TableFunction { - private static class MySqlConnectorTableFunctionHandle implements TableFunctionHandle { + static class BaseJDBCConnectorTableFunctionHandle implements TableFunctionHandle { String sql; String url; String userName; String password; int[] types; - public MySqlConnectorTableFunctionHandle() {} + public BaseJDBCConnectorTableFunctionHandle() {} - public MySqlConnectorTableFunctionHandle( + public BaseJDBCConnectorTableFunctionHandle( String sql, String url, String userName, String password, int[] types) { this.sql = sql; this.url = url; @@ -109,7 +128,6 @@ public class MySqlConnectorTableFunction implements TableFunction { private static final String DEFAULT_USERNAME = "root"; private static final String PASSWORD = "PASSWORD"; private static final String DEFAULT_PASSWORD = "iotdb2025"; - private static final String MYSQL = "MYSQL"; @Override public List<ParameterSpecification> getArgumentsSpecifications() { @@ -118,20 +136,30 @@ public class MySqlConnectorTableFunction implements TableFunction { ScalarParameterSpecification.builder() .name(URL) .type(Type.STRING) - .defaultValue(DEFAULT_URL) + .defaultValue(getDefaultUrl()) .build(), ScalarParameterSpecification.builder() .name(USERNAME) .type(Type.STRING) - .defaultValue(DEFAULT_USERNAME) + .defaultValue(getDefaultUser()) .build(), ScalarParameterSpecification.builder() .name(PASSWORD) .type(Type.STRING) - .defaultValue(DEFAULT_PASSWORD) + .defaultValue(getDefaultPassword()) .build()); } + abstract String getDefaultUrl(); + + String getDefaultUser() { + return DEFAULT_USERNAME; + } + + String getDefaultPassword() { + return DEFAULT_PASSWORD; + } + @Override public TableFunctionAnalysis analyze(Map<String, Argument> arguments) throws UDFException { @@ -154,8 +182,8 @@ public class MySqlConnectorTableFunction implements TableFunction { } catch (SQLException e) { throw new UDFException("Get ResultSetMetaData failed.", e); } - MySqlConnectorTableFunctionHandle handle = - new MySqlConnectorTableFunctionHandle(sql, url, userName, password, types); + BaseJDBCConnectorTableFunctionHandle handle = + new BaseJDBCConnectorTableFunctionHandle(sql, url, userName, password, types); return TableFunctionAnalysis.builder() .properColumnSchema(schemaBuilder.build()) .handle(handle) @@ -164,7 +192,7 @@ public class MySqlConnectorTableFunction implements TableFunction { @Override public TableFunctionHandle createTableFunctionHandle() { - return new MySqlConnectorTableFunctionHandle(); + return new BaseJDBCConnectorTableFunctionHandle(); } @Override @@ -173,28 +201,32 @@ public class MySqlConnectorTableFunction implements TableFunction { return new TableFunctionProcessorProvider() { @Override public TableFunctionLeafProcessor getSplitProcessor() { - return new MysqlProcessor((MySqlConnectorTableFunctionHandle) tableFunctionHandle); + return getProcessor((BaseJDBCConnectorTableFunctionHandle) tableFunctionHandle); } }; } - private static class MysqlProcessor implements TableFunctionLeafProcessor { + abstract JDBCProcessor getProcessor(BaseJDBCConnectorTableFunctionHandle tableFunctionHandle); + + abstract static class JDBCProcessor implements TableFunctionLeafProcessor { private static final int MAX_TSBLOCK_SIZE_IN_BYTES = TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes(); private static final int MAX_TSBLOCK_LINE_NUMBER = TSFileDescriptor.getInstance().getConfig().getMaxTsBlockLineNumber(); - private final MySqlConnectorTableFunctionHandle handle; + private final BaseJDBCConnectorTableFunctionHandle handle; private final List<ResultSetConverter> converters; private Connection connection; private Statement statement; private ResultSet resultSet; private boolean finished = false; - MysqlProcessor(MySqlConnectorTableFunctionHandle handle) { + JDBCProcessor(BaseJDBCConnectorTableFunctionHandle handle) { this.handle = handle; this.converters = handle.getConverters(); } + abstract String getDBName(); + @Override public void beforeStart() { try { @@ -203,7 +235,7 @@ public class MySqlConnectorTableFunction implements TableFunction { this.statement = connection.createStatement(); this.resultSet = statement.executeQuery(handle.sql); } catch (SQLException e) { - throw new ExecutionFailedInExternalDB(MYSQL, e); + throw new ExecutionFailedInExternalDB(getDBName(), e); } } @@ -225,7 +257,7 @@ public class MySqlConnectorTableFunction implements TableFunction { } } } catch (SQLException e) { - throw new ExecutionFailedInExternalDB(MYSQL, e); + throw new ExecutionFailedInExternalDB(getDBName(), e); } } @@ -247,7 +279,7 @@ public class MySqlConnectorTableFunction implements TableFunction { connection.close(); } } catch (SQLException e) { - throw new CloseFailedInExternalDB(MYSQL, e); + throw new CloseFailedInExternalDB(getDBName(), e); } } } diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/CassandraConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/CassandraConnectorTableFunction.java new file mode 100644 index 00000000000..b8a23163458 --- /dev/null +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/CassandraConnectorTableFunction.java @@ -0,0 +1,22 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; + +public class CassandraConnectorTableFunction {} diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/ClickhouseConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/ClickhouseConnectorTableFunction.java new file mode 100644 index 00000000000..9d743ee8c5f --- /dev/null +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/ClickhouseConnectorTableFunction.java @@ -0,0 +1,22 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; + +public class ClickhouseConnectorTableFunction {} diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/DorisConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/DorisConnectorTableFunction.java new file mode 100644 index 00000000000..2cb68caf2dc --- /dev/null +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/DorisConnectorTableFunction.java @@ -0,0 +1,22 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; + +public class DorisConnectorTableFunction {} diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MongoDBConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MongoDBConnectorTableFunction.java new file mode 100644 index 00000000000..2ad4bfaa9b0 --- /dev/null +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MongoDBConnectorTableFunction.java @@ -0,0 +1,22 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; + +public class MongoDBConnectorTableFunction {} diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MySqlConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MySqlConnectorTableFunction.java index d7745e545d9..90b447aa8c5 100644 --- a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MySqlConnectorTableFunction.java +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/MySqlConnectorTableFunction.java @@ -1,254 +1,43 @@ package org.apache.iotdb.library.relational.tablefunction.connector; -import org.apache.iotdb.library.relational.tablefunction.connector.converter.ResultSetConverter; -import org.apache.iotdb.udf.api.exception.CloseFailedInExternalDB; -import org.apache.iotdb.udf.api.exception.ExecutionFailedInExternalDB; -import org.apache.iotdb.udf.api.exception.UDFException; -import org.apache.iotdb.udf.api.relational.TableFunction; -import org.apache.iotdb.udf.api.relational.table.TableFunctionAnalysis; -import org.apache.iotdb.udf.api.relational.table.TableFunctionHandle; -import org.apache.iotdb.udf.api.relational.table.TableFunctionProcessorProvider; -import org.apache.iotdb.udf.api.relational.table.argument.Argument; -import org.apache.iotdb.udf.api.relational.table.argument.DescribedSchema; -import org.apache.iotdb.udf.api.relational.table.argument.ScalarArgument; -import org.apache.iotdb.udf.api.relational.table.processor.TableFunctionLeafProcessor; -import org.apache.iotdb.udf.api.relational.table.specification.ParameterSpecification; -import org.apache.iotdb.udf.api.relational.table.specification.ScalarParameterSpecification; -import org.apache.iotdb.udf.api.type.Type; +public class MySqlConnectorTableFunction extends BaseJDBCConnectorTableFunction { -import org.apache.tsfile.block.column.ColumnBuilder; -import org.apache.tsfile.common.conf.TSFileDescriptor; -import org.apache.tsfile.utils.PublicBAOS; -import org.apache.tsfile.utils.ReadWriteIOUtils; - -import java.io.DataOutputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.sql.Statement; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -import static org.apache.iotdb.library.relational.tablefunction.connector.JDBCConnectionPool.translateJDBCTypeToUDFType; - -public class MySqlConnectorTableFunction implements TableFunction { - - private static class MySqlConnectorTableFunctionHandle implements TableFunctionHandle { - String sql; - String url; - String userName; - String password; - int[] types; - - public MySqlConnectorTableFunctionHandle() {} - - public MySqlConnectorTableFunctionHandle( - String sql, String url, String userName, String password, int[] types) { - this.sql = sql; - this.url = url; - this.userName = userName; - this.password = password; - this.types = types; - } - - List<ResultSetConverter> getConverters() { - List<ResultSetConverter> converters = new ArrayList<>(types.length); - for (int type : types) { - converters.add(JDBCConnectionPool.getResultSetConverter(type)); - } - return converters; - } - - @Override - public byte[] serialize() { - try (PublicBAOS publicBAOS = new PublicBAOS(); - DataOutputStream outputStream = new DataOutputStream(publicBAOS)) { - ReadWriteIOUtils.write(sql, outputStream); - ReadWriteIOUtils.write(url, outputStream); - ReadWriteIOUtils.write(userName, outputStream); - ReadWriteIOUtils.write(password, outputStream); - ReadWriteIOUtils.write(types.length, outputStream); - for (int type : types) { - ReadWriteIOUtils.write(type, outputStream); - } - outputStream.flush(); - return publicBAOS.toByteArray(); - } catch (IOException e) { - throw new UDFException( - String.format( - "Error occurred while serializing MySqlConnectorTableFunctionHandle: %s", - e.getMessage())); - } - } - - @Override - public void deserialize(byte[] bytes) { - ByteBuffer buffer = ByteBuffer.wrap(bytes); - this.sql = ReadWriteIOUtils.readString(buffer); - this.url = ReadWriteIOUtils.readString(buffer); - this.userName = ReadWriteIOUtils.readString(buffer); - this.password = ReadWriteIOUtils.readString(buffer); - this.types = new int[ReadWriteIOUtils.readInt(buffer)]; - for (int i = 0; i < types.length; i++) { - types[i] = ReadWriteIOUtils.readInt(buffer); - } - } - } - - private static final String SQL = "SQL"; - private static final String URL = "URL"; private static final String DEFAULT_URL = "jdbc:mysql://localhost:3306?allowPublicKeyRetrieval=true"; - private static final String USERNAME = "USERNAME"; private static final String DEFAULT_USERNAME = "root"; - private static final String PASSWORD = "PASSWORD"; - private static final String DEFAULT_PASSWORD = "iotdb2025"; - private static final String MYSQL = "MYSQL"; + private static final String DEFAULT_PASSWORD = "root"; + private static final String MYSQL = "MySQL"; @Override - public List<ParameterSpecification> getArgumentsSpecifications() { - return Arrays.asList( - ScalarParameterSpecification.builder().name(SQL).type(Type.STRING).build(), - ScalarParameterSpecification.builder() - .name(URL) - .type(Type.STRING) - .defaultValue(DEFAULT_URL) - .build(), - ScalarParameterSpecification.builder() - .name(USERNAME) - .type(Type.STRING) - .defaultValue(DEFAULT_USERNAME) - .build(), - ScalarParameterSpecification.builder() - .name(PASSWORD) - .type(Type.STRING) - .defaultValue(DEFAULT_PASSWORD) - .build()); + String getDefaultUrl() { + return DEFAULT_URL; } @Override - public TableFunctionAnalysis analyze(Map<String, Argument> arguments) throws UDFException { - - String sql = (String) ((ScalarArgument) arguments.get(SQL)).getValue(); - String url = (String) ((ScalarArgument) arguments.get(URL)).getValue(); - String userName = (String) ((ScalarArgument) arguments.get(USERNAME)).getValue(); - String password = (String) ((ScalarArgument) arguments.get(PASSWORD)).getValue(); - - DescribedSchema.Builder schemaBuilder = DescribedSchema.builder(); - int[] types; - try (Connection connection = JDBCConnectionPool.getConnection(url, userName, password); - PreparedStatement statement = connection.prepareStatement(sql)) { - ResultSetMetaData metaData = statement.getMetaData(); - types = new int[metaData.getColumnCount()]; - for (int i = 1, size = metaData.getColumnCount(); i <= size; i++) { - int type = metaData.getColumnType(i); - schemaBuilder.addField(metaData.getColumnName(i), translateJDBCTypeToUDFType(type)); - types[i - 1] = type; - } - } catch (SQLException e) { - throw new UDFException("Get ResultSetMetaData failed.", e); - } - MySqlConnectorTableFunctionHandle handle = - new MySqlConnectorTableFunctionHandle(sql, url, userName, password, types); - return TableFunctionAnalysis.builder() - .properColumnSchema(schemaBuilder.build()) - .handle(handle) - .build(); + String getDefaultUser() { + return DEFAULT_PASSWORD; } @Override - public TableFunctionHandle createTableFunctionHandle() { - return new MySqlConnectorTableFunctionHandle(); + String getDefaultPassword() { + return DEFAULT_USERNAME; } @Override - public TableFunctionProcessorProvider getProcessorProvider( - TableFunctionHandle tableFunctionHandle) { - return new TableFunctionProcessorProvider() { - @Override - public TableFunctionLeafProcessor getSplitProcessor() { - return new MysqlProcessor((MySqlConnectorTableFunctionHandle) tableFunctionHandle); - } - }; + BaseJDBCConnectorTableFunction.JDBCProcessor getProcessor( + BaseJDBCConnectorTableFunction.BaseJDBCConnectorTableFunctionHandle tableFunctionHandle) { + return new MysqlProcessor(tableFunctionHandle); } - private static class MysqlProcessor implements TableFunctionLeafProcessor { - private static final int MAX_TSBLOCK_SIZE_IN_BYTES = - TSFileDescriptor.getInstance().getConfig().getMaxTsBlockSizeInBytes(); - private static final int MAX_TSBLOCK_LINE_NUMBER = - TSFileDescriptor.getInstance().getConfig().getMaxTsBlockLineNumber(); - private final MySqlConnectorTableFunctionHandle handle; - private final List<ResultSetConverter> converters; - private Connection connection; - private Statement statement; - private ResultSet resultSet; - private boolean finished = false; - - MysqlProcessor(MySqlConnectorTableFunctionHandle handle) { - this.handle = handle; - this.converters = handle.getConverters(); - } - - @Override - public void beforeStart() { - try { - this.connection = - JDBCConnectionPool.getConnection(handle.url, handle.userName, handle.password); - this.statement = connection.createStatement(); - this.resultSet = statement.executeQuery(handle.sql); - } catch (SQLException e) { - throw new ExecutionFailedInExternalDB(MYSQL, e); - } - } + private static class MysqlProcessor extends JDBCProcessor { - @Override - public void process(List<ColumnBuilder> columnBuilders) { - finished = true; - try { - int count = 0; - while (resultSet.next()) { - long retainedSize = 0; - for (int i = 0, size = columnBuilders.size(); i < size; i++) { - converters.get(i).append(resultSet, i + 1, columnBuilders.get(i)); - retainedSize += columnBuilders.get(i).getRetainedSizeInBytes(); - } - count++; - if (retainedSize >= MAX_TSBLOCK_SIZE_IN_BYTES || count >= MAX_TSBLOCK_LINE_NUMBER) { - finished = false; - break; - } - } - } catch (SQLException e) { - throw new ExecutionFailedInExternalDB(MYSQL, e); - } - } - - @Override - public boolean isFinish() { - return finished; + MysqlProcessor(BaseJDBCConnectorTableFunction.BaseJDBCConnectorTableFunctionHandle handle) { + super(handle); } @Override - public void beforeDestroy() { - try { - if (resultSet != null) { - resultSet.close(); - } - if (statement != null) { - statement.close(); - } - if (connection != null) { - connection.close(); - } - } catch (SQLException e) { - throw new CloseFailedInExternalDB(MYSQL, e); - } + String getDBName() { + return MYSQL; } } } diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/PostgreSqlConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/PostgreSqlConnectorTableFunction.java new file mode 100644 index 00000000000..b1accbf1724 --- /dev/null +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/PostgreSqlConnectorTableFunction.java @@ -0,0 +1,62 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; + +public class PostgreSqlConnectorTableFunction extends BaseJDBCConnectorTableFunction { + + private static final String DEFAULT_URL = "jdbc:postgresql://localhost:5432"; + private static final String DEFAULT_USERNAME = "postgres"; + private static final String DEFAULT_PASSWORD = ""; + private static final String PG = "PostgreSQL"; + + @Override + String getDefaultUrl() { + return DEFAULT_URL; + } + + @Override + String getDefaultUser() { + return DEFAULT_PASSWORD; + } + + @Override + String getDefaultPassword() { + return DEFAULT_USERNAME; + } + + @Override + BaseJDBCConnectorTableFunction.JDBCProcessor getProcessor( + BaseJDBCConnectorTableFunction.BaseJDBCConnectorTableFunctionHandle tableFunctionHandle) { + return new PostgreSqlProcessor(tableFunctionHandle); + } + + private static class PostgreSqlProcessor extends JDBCProcessor { + + PostgreSqlProcessor( + BaseJDBCConnectorTableFunction.BaseJDBCConnectorTableFunctionHandle handle) { + super(handle); + } + + @Override + String getDBName() { + return PG; + } + } +} diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/RedisConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/RedisConnectorTableFunction.java new file mode 100644 index 00000000000..d8b9df06924 --- /dev/null +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/RedisConnectorTableFunction.java @@ -0,0 +1,22 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; + +public class RedisConnectorTableFunction {} diff --git a/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/SnowflakeConnectorTableFunction.java b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/SnowflakeConnectorTableFunction.java new file mode 100644 index 00000000000..e9d0d972fc1 --- /dev/null +++ b/library-udf/src/main/java/org/apache/iotdb/library/relational/tablefunction/connector/SnowflakeConnectorTableFunction.java @@ -0,0 +1,22 @@ +/* + * 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.iotdb.library.relational.tablefunction.connector; + +public class SnowflakeConnectorTableFunction {} diff --git a/pom.xml b/pom.xml index 624d6bad129..0f2cc724f15 100644 --- a/pom.xml +++ b/pom.xml @@ -176,7 +176,6 @@ <xz.version>1.9</xz.version> <zstd-jni.version>1.5.6-3</zstd-jni.version> <tsfile.version>2.1.0-250616-SNAPSHOT</tsfile.version> - <mysql.jdbc.version>9.3.0</mysql.jdbc.version> </properties> <!-- if we claim dependencies in dependencyManagement, then we do not claim
