Carl-Zhou-CN commented on code in PR #6975: URL: https://github.com/apache/seatunnel/pull/6975#discussion_r1637649181
########## seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/source/ClickhouseSourceFactory.java: ########## @@ -37,11 +61,60 @@ public String factoryIdentifier() { return "Clickhouse"; } + @Override + public <T, SplitT extends SourceSplit, StateT extends Serializable> + TableSource<T, SplitT, StateT> createSource(TableSourceFactoryContext context) { + ReadonlyConfig readonlyConfig = context.getOptions(); + List<ClickHouseNode> nodes = ClickhouseUtil.createNodes(readonlyConfig); + + String sql = readonlyConfig.get(SQL); + ClickHouseNode currentServer = nodes.get(ThreadLocalRandom.current().nextInt(nodes.size())); + try (ClickHouseClient client = ClickHouseClient.newInstance(currentServer.getProtocol()); + ClickHouseResponse response = + client.connect(currentServer) + .format(ClickHouseFormat.RowBinaryWithNamesAndTypes) + .query(modifySQLToLimit1(sql)) + .executeAndWait()) { + TableSchema.Builder builder = TableSchema.builder(); + int columnSize = response.getColumns().size(); + for (int i = 0; i < columnSize; i++) { + String columnName = response.getColumns().get(i).getColumnName(); + SeaTunnelDataType<?> seaTunnelDataType = + TypeConvertUtil.convert(response.getColumns().get(i)); + builder.column( + PhysicalColumn.of( + columnName, seaTunnelDataType, Long.MAX_VALUE, true, null, null)); Review Comment: PhysicalColumn.of( column.getColumnName(), TypeConvertUtil.convert(column), Long.valueOf(column.getEstimatedLength()), column.getScale(), column.isNullable(), null, null); Isn't that better? -- 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: commits-unsubscr...@seatunnel.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org