Unverified Commit e8665012 authored by gaoyan's avatar gaoyan Committed by GitHub

[Feature] Support paimon Datasource (#3641)

parent 778d482b
...@@ -31,6 +31,7 @@ import org.dinky.data.model.DataBase; ...@@ -31,6 +31,7 @@ import org.dinky.data.model.DataBase;
import org.dinky.data.model.QueryData; import org.dinky.data.model.QueryData;
import org.dinky.data.model.Schema; import org.dinky.data.model.Schema;
import org.dinky.data.model.SqlGeneration; import org.dinky.data.model.SqlGeneration;
import org.dinky.data.model.Table;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.metadata.driver.DriverPool; import org.dinky.metadata.driver.DriverPool;
import org.dinky.metadata.result.JdbcSelectResult; import org.dinky.metadata.result.JdbcSelectResult;
...@@ -443,4 +444,53 @@ public class DataSourceController { ...@@ -443,4 +444,53 @@ public class DataSourceController {
return Result.failed(Status.COPY_FAILED); return Result.failed(Status.COPY_FAILED);
} }
} }
/**
* get columns of table
*
* @param id {@link Integer}
* @param schemaName {@link String}
* @param tableName {@link String}
* @return {@link Result}< {@link List}< {@link Column}>>
*/
@GetMapping("/getTable")
@ApiOperation("Get Columns Of Table")
@ApiImplicitParams(
value = {
@ApiImplicitParam(
name = "id",
value = "DataBase Id",
required = true,
dataType = "Integer",
paramType = "path",
dataTypeClass = Integer.class,
example = "1"),
@ApiImplicitParam(
name = "schemaName",
value = "Schema Name",
required = true,
dataType = "String",
paramType = "query",
dataTypeClass = String.class,
example = "public"),
@ApiImplicitParam(
name = "tableName",
value = "Table Name",
required = true,
dataType = "String",
paramType = "query",
dataTypeClass = String.class,
example = "user")
})
@SaCheckPermission(
value = {
PermissionConstants.REGISTRATION_DATA_SOURCE_DETAIL_REFRESH,
PermissionConstants.REGISTRATION_DATA_SOURCE_DETAIL_TREE,
PermissionConstants.REGISTRATION_DATA_SOURCE_DETAIL_DESC,
},
mode = SaMode.OR)
public Result<Table> getTable(
@RequestParam Integer id, @RequestParam String schemaName, @RequestParam String tableName) {
return Result.succeed(databaseService.getTable(id, schemaName, tableName));
}
} }
...@@ -27,6 +27,7 @@ import org.dinky.data.model.DataBase; ...@@ -27,6 +27,7 @@ import org.dinky.data.model.DataBase;
import org.dinky.data.model.QueryData; import org.dinky.data.model.QueryData;
import org.dinky.data.model.Schema; import org.dinky.data.model.Schema;
import org.dinky.data.model.SqlGeneration; import org.dinky.data.model.SqlGeneration;
import org.dinky.data.model.Table;
import org.dinky.data.result.SqlExplainResult; import org.dinky.data.result.SqlExplainResult;
import org.dinky.job.JobResult; import org.dinky.job.JobResult;
import org.dinky.metadata.result.JdbcSelectResult; import org.dinky.metadata.result.JdbcSelectResult;
...@@ -213,4 +214,14 @@ public interface DataBaseService extends ISuperService<DataBase> { ...@@ -213,4 +214,14 @@ public interface DataBaseService extends ISuperService<DataBase> {
* @return {@link Boolean} true: has relationship, false: no relationship * @return {@link Boolean} true: has relationship, false: no relationship
*/ */
boolean hasRelationShip(Integer id); boolean hasRelationShip(Integer id);
/**
* get table
*
* @param id {@link Integer}
* @param schemaName {@link String}
* @param tableName {@link String}
* @return {@link List}< {@link Column}>
*/
Table getTable(Integer id, String schemaName, String tableName);
} }
...@@ -196,8 +196,7 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa ...@@ -196,8 +196,7 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
DataBase dataBase = getById(queryData.getId()); DataBase dataBase = getById(queryData.getId());
Asserts.checkNotNull(dataBase, Status.DATASOURCE_NOT_EXIST.getMessage()); Asserts.checkNotNull(dataBase, Status.DATASOURCE_NOT_EXIST.getMessage());
Driver driver = Driver.build(dataBase.getDriverConfig()); Driver driver = Driver.build(dataBase.getDriverConfig());
StringBuilder queryOption = driver.genQueryOption(queryData); return driver.query(queryData);
return driver.query(queryOption.toString(), null);
} }
@Override @Override
...@@ -389,4 +388,15 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa ...@@ -389,4 +388,15 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
.list(new LambdaQueryWrapper<Task>().eq(Task::getAlertGroupId, id)) .list(new LambdaQueryWrapper<Task>().eq(Task::getAlertGroupId, id))
.isEmpty(); .isEmpty();
} }
@Override
public Table getTable(Integer id, String schemaName, String tableName) {
DataBase dataBase = getById(id);
Asserts.checkNotNull(dataBase, Status.DATASOURCE_NOT_EXIST.getMessage());
try (Driver driver = Driver.build(dataBase.getDriverConfig())) {
return driver.getTable(schemaName, tableName);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} }
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
*/ */
package org.dinky.gateway.model; package org.dinky.data.model;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
......
...@@ -81,13 +81,13 @@ public class QueryData { ...@@ -81,13 +81,13 @@ public class QueryData {
dataType = "String", dataType = "String",
example = "0", example = "0",
notes = "Starting row number for the LIMIT clause") notes = "Starting row number for the LIMIT clause")
private String limitStart; private int limitStart;
@ApiModelProperty( @ApiModelProperty(
value = "Ending row for LIMIT", value = "Ending row for LIMIT",
dataType = "String", dataType = "String",
example = "10", example = "10",
notes = "Ending row number for the LIMIT clause") notes = "Ending row number for the LIMIT clause")
private String limitEnd; private int limitEnd;
} }
} }
...@@ -32,16 +32,20 @@ import java.util.List; ...@@ -32,16 +32,20 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import lombok.Getter; import lombok.AllArgsConstructor;
import lombok.Setter; import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/** /**
* Table * Table
* *
* @since 2021/7/19 23:27 * @since 2021/7/19 23:27
*/ */
@Getter @Data
@Setter @Builder
@AllArgsConstructor
@NoArgsConstructor
public class Table implements Serializable, Comparable<Table>, Cloneable { public class Table implements Serializable, Comparable<Table>, Cloneable {
private static final long serialVersionUID = 4209205512472367171L; private static final long serialVersionUID = 4209205512472367171L;
...@@ -66,7 +70,9 @@ public class Table implements Serializable, Comparable<Table>, Cloneable { ...@@ -66,7 +70,9 @@ public class Table implements Serializable, Comparable<Table>, Cloneable {
/** 驱动类型, @see org.dinky.metadata.enums.DriverType */ /** 驱动类型, @see org.dinky.metadata.enums.DriverType */
private String driverType; private String driverType;
public Table() {} public Table(String name) {
this.name = name;
}
public Table(String name, String schema, List<Column> columns) { public Table(String name, String schema, List<Column> columns) {
this.name = name; this.name = name;
......
...@@ -84,6 +84,11 @@ ...@@ -84,6 +84,11 @@
<artifactId>dinky-alert-http</artifactId> <artifactId>dinky-alert-http</artifactId>
<scope>${scope.runtime}</scope> <scope>${scope.runtime}</scope>
</dependency> </dependency>
<dependency>
<groupId>org.dinky</groupId>
<artifactId>dinky-metadata-paimon</artifactId>
<scope>${scope.runtime}</scope>
</dependency>
<dependency> <dependency>
<groupId>org.dinky</groupId> <groupId>org.dinky</groupId>
<artifactId>dinky-metadata-mysql</artifactId> <artifactId>dinky-metadata-mysql</artifactId>
......
...@@ -22,11 +22,11 @@ package org.dinky.job; ...@@ -22,11 +22,11 @@ package org.dinky.job;
import org.dinky.assertion.Asserts; import org.dinky.assertion.Asserts;
import org.dinky.data.constant.NetConstant; import org.dinky.data.constant.NetConstant;
import org.dinky.data.enums.GatewayType; import org.dinky.data.enums.GatewayType;
import org.dinky.data.model.CustomConfig;
import org.dinky.executor.ExecutorConfig; import org.dinky.executor.ExecutorConfig;
import org.dinky.gateway.config.FlinkConfig; import org.dinky.gateway.config.FlinkConfig;
import org.dinky.gateway.config.GatewayConfig; import org.dinky.gateway.config.GatewayConfig;
import org.dinky.gateway.enums.SavePointStrategy; import org.dinky.gateway.enums.SavePointStrategy;
import org.dinky.gateway.model.CustomConfig;
import org.dinky.gateway.model.FlinkClusterConfig; import org.dinky.gateway.model.FlinkClusterConfig;
import org.apache.flink.configuration.Configuration; import org.apache.flink.configuration.Configuration;
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
package org.dinky.gateway.config; package org.dinky.gateway.config;
import org.dinky.gateway.model.CustomConfig; import org.dinky.data.model.CustomConfig;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
......
...@@ -20,9 +20,9 @@ ...@@ -20,9 +20,9 @@
package org.dinky.gateway.config; package org.dinky.gateway.config;
import org.dinky.assertion.Asserts; import org.dinky.assertion.Asserts;
import org.dinky.data.model.CustomConfig;
import org.dinky.gateway.enums.ActionType; import org.dinky.gateway.enums.ActionType;
import org.dinky.gateway.enums.SavePointType; import org.dinky.gateway.enums.SavePointType;
import org.dinky.gateway.model.CustomConfig;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
......
...@@ -23,6 +23,7 @@ import org.dinky.assertion.Asserts; ...@@ -23,6 +23,7 @@ import org.dinky.assertion.Asserts;
import org.dinky.constant.CustomerConfigureOptions; import org.dinky.constant.CustomerConfigureOptions;
import org.dinky.context.FlinkUdfPathContextHolder; import org.dinky.context.FlinkUdfPathContextHolder;
import org.dinky.data.enums.JobStatus; import org.dinky.data.enums.JobStatus;
import org.dinky.data.model.CustomConfig;
import org.dinky.data.model.SystemConfiguration; import org.dinky.data.model.SystemConfiguration;
import org.dinky.executor.ClusterDescriptorAdapterImpl; import org.dinky.executor.ClusterDescriptorAdapterImpl;
import org.dinky.gateway.AbstractGateway; import org.dinky.gateway.AbstractGateway;
...@@ -32,7 +33,6 @@ import org.dinky.gateway.config.GatewayConfig; ...@@ -32,7 +33,6 @@ import org.dinky.gateway.config.GatewayConfig;
import org.dinky.gateway.enums.ActionType; import org.dinky.gateway.enums.ActionType;
import org.dinky.gateway.enums.SavePointType; import org.dinky.gateway.enums.SavePointType;
import org.dinky.gateway.exception.GatewayException; import org.dinky.gateway.exception.GatewayException;
import org.dinky.gateway.model.CustomConfig;
import org.dinky.gateway.result.SavePointResult; import org.dinky.gateway.result.SavePointResult;
import org.dinky.gateway.result.TestResult; import org.dinky.gateway.result.TestResult;
import org.dinky.gateway.result.YarnResult; import org.dinky.gateway.result.YarnResult;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
package org.dinky.gateway.model; package org.dinky.gateway.model;
import org.dinky.data.model.CustomConfig;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
......
...@@ -21,12 +21,14 @@ package org.dinky.metadata.driver; ...@@ -21,12 +21,14 @@ package org.dinky.metadata.driver;
import org.dinky.assertion.Asserts; import org.dinky.assertion.Asserts;
import org.dinky.data.model.Column; import org.dinky.data.model.Column;
import org.dinky.data.model.QueryData;
import org.dinky.data.model.Schema; import org.dinky.data.model.Schema;
import org.dinky.data.model.Table; import org.dinky.data.model.Table;
import org.dinky.metadata.config.DriverConfig; import org.dinky.metadata.config.DriverConfig;
import org.dinky.metadata.config.IConnectConfig; import org.dinky.metadata.config.IConnectConfig;
import org.dinky.metadata.convert.ITypeConvert; import org.dinky.metadata.convert.ITypeConvert;
import org.dinky.metadata.query.IDBQuery; import org.dinky.metadata.query.IDBQuery;
import org.dinky.metadata.result.JdbcSelectResult;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -45,6 +47,12 @@ public abstract class AbstractDriver<T extends IConnectConfig> implements Driver ...@@ -45,6 +47,12 @@ public abstract class AbstractDriver<T extends IConnectConfig> implements Driver
public abstract ITypeConvert<T> getTypeConvert(); public abstract ITypeConvert<T> getTypeConvert();
@Override
public JdbcSelectResult query(QueryData queryData) {
StringBuilder queryOption = genQueryOption(queryData);
return query(queryOption.toString(), null);
}
public boolean canHandle(String type) { public boolean canHandle(String type) {
return Asserts.isEqualsIgnoreCase(getType(), type); return Asserts.isEqualsIgnoreCase(getType(), type);
} }
......
...@@ -38,7 +38,6 @@ import org.dinky.metadata.query.IDBQuery; ...@@ -38,7 +38,6 @@ import org.dinky.metadata.query.IDBQuery;
import org.dinky.metadata.result.JdbcSelectResult; import org.dinky.metadata.result.JdbcSelectResult;
import org.dinky.utils.JsonUtils; import org.dinky.utils.JsonUtils;
import org.dinky.utils.LogUtil; import org.dinky.utils.LogUtil;
import org.dinky.utils.TextUtil;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
...@@ -525,8 +524,8 @@ public abstract class AbstractJdbcDriver extends AbstractDriver<AbstractJdbcConf ...@@ -525,8 +524,8 @@ public abstract class AbstractJdbcDriver extends AbstractDriver<AbstractJdbcConf
String where = queryData.getOption().getWhere(); String where = queryData.getOption().getWhere();
String order = queryData.getOption().getOrder(); String order = queryData.getOption().getOrder();
String limitStart = queryData.getOption().getLimitStart(); int limitStart = queryData.getOption().getLimitStart();
String limitEnd = queryData.getOption().getLimitEnd(); int limitEnd = queryData.getOption().getLimitEnd();
StringBuilder optionBuilder = new StringBuilder() StringBuilder optionBuilder = new StringBuilder()
.append("select * from ") .append("select * from ")
...@@ -541,12 +540,6 @@ public abstract class AbstractJdbcDriver extends AbstractDriver<AbstractJdbcConf ...@@ -541,12 +540,6 @@ public abstract class AbstractJdbcDriver extends AbstractDriver<AbstractJdbcConf
optionBuilder.append(" order by ").append(order); optionBuilder.append(" order by ").append(order);
} }
if (TextUtil.isEmpty(limitStart)) {
limitStart = "0";
}
if (TextUtil.isEmpty(limitEnd)) {
limitEnd = "100";
}
optionBuilder.append(" limit ").append(limitStart).append(",").append(limitEnd); optionBuilder.append(" limit ").append(limitStart).append(",").append(limitEnd);
return optionBuilder; return optionBuilder;
......
...@@ -217,6 +217,8 @@ public interface Driver extends AutoCloseable { ...@@ -217,6 +217,8 @@ public interface Driver extends AutoCloseable {
JdbcSelectResult query(String sql, Integer limit); JdbcSelectResult query(String sql, Integer limit);
JdbcSelectResult query(QueryData queryData);
StringBuilder genQueryOption(QueryData queryData); StringBuilder genQueryOption(QueryData queryData);
JdbcSelectResult executeSql(String sql, Integer limit); JdbcSelectResult executeSql(String sql, Integer limit);
......
...@@ -30,6 +30,7 @@ import java.util.stream.Collectors; ...@@ -30,6 +30,7 @@ import java.util.stream.Collectors;
* @since 2024/2/6 * @since 2024/2/6
*/ */
public enum DriverType { public enum DriverType {
Paimon("Paimon"),
MYSQL("MySQL"), MYSQL("MySQL"),
ORACLE("Oracle"), ORACLE("Oracle"),
POSTGRESQL("PostgreSql"), POSTGRESQL("PostgreSql"),
......
...@@ -29,7 +29,6 @@ import org.dinky.metadata.convert.MySqlTypeConvert; ...@@ -29,7 +29,6 @@ import org.dinky.metadata.convert.MySqlTypeConvert;
import org.dinky.metadata.enums.DriverType; import org.dinky.metadata.enums.DriverType;
import org.dinky.metadata.query.IDBQuery; import org.dinky.metadata.query.IDBQuery;
import org.dinky.metadata.query.MySqlQuery; import org.dinky.metadata.query.MySqlQuery;
import org.dinky.utils.TextUtil;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
...@@ -170,8 +169,8 @@ public class MySqlDriver extends AbstractJdbcDriver { ...@@ -170,8 +169,8 @@ public class MySqlDriver extends AbstractJdbcDriver {
String where = queryData.getOption().getWhere(); String where = queryData.getOption().getWhere();
String order = queryData.getOption().getOrder(); String order = queryData.getOption().getOrder();
String limitStart = queryData.getOption().getLimitStart(); int limitStart = queryData.getOption().getLimitStart();
String limitEnd = queryData.getOption().getLimitEnd(); int limitEnd = queryData.getOption().getLimitEnd();
StringBuilder optionBuilder = new StringBuilder() StringBuilder optionBuilder = new StringBuilder()
.append(String.format("select * from `%s`.`%s`", queryData.getSchemaName(), queryData.getTableName())); .append(String.format("select * from `%s`.`%s`", queryData.getSchemaName(), queryData.getTableName()));
...@@ -182,13 +181,6 @@ public class MySqlDriver extends AbstractJdbcDriver { ...@@ -182,13 +181,6 @@ public class MySqlDriver extends AbstractJdbcDriver {
if (order != null && !order.isEmpty()) { if (order != null && !order.isEmpty()) {
optionBuilder.append(" order by ").append(order); optionBuilder.append(" order by ").append(order);
} }
if (TextUtil.isEmpty(limitStart)) {
limitStart = "0";
}
if (TextUtil.isEmpty(limitEnd)) {
limitEnd = "100";
}
optionBuilder.append(" limit ").append(limitStart).append(",").append(limitEnd); optionBuilder.append(" limit ").append(limitStart).append(",").append(limitEnd);
return optionBuilder; return optionBuilder;
......
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.dinky</groupId>
<artifactId>dinky-metadata</artifactId>
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>dinky-metadata-paimon</artifactId>
<packaging>jar</packaging>
<name>Dinky : Metadata : Paimon</name>
<dependencies>
<dependency>
<groupId>org.dinky</groupId>
<artifactId>dinky-metadata-base</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.paimon/paimon-bundle -->
<dependency>
<groupId>org.apache.paimon</groupId>
<artifactId>paimon-bundle</artifactId>
<version>0.8.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.paimon/paimon-s3 -->
<dependency>
<groupId>org.apache.paimon</groupId>
<artifactId>paimon-s3</artifactId>
<version>0.8.1</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-s3-fs-presto</artifactId>
<version>${flink.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.flink/flink-shaded-hadoop-2-uber -->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-shaded-hadoop-2-uber</artifactId>
<version>2.8.3-10.0</version>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
/*
*
* 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.dinky.metadata.config;
public enum CatalogType {
Hive("Hive"),
JDBC("JDBC"),
FileSystem("FileSystem");
private final String name;
CatalogType(String name) {
this.name = name;
}
public String getName() {
return name;
}
public static CatalogType getByName(String name) {
for (CatalogType catalogType : CatalogType.values()) {
if (catalogType.getName().equals(name)) {
return catalogType;
}
}
return null;
}
}
/*
*
* 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.dinky.metadata.config;
public enum FileSystemType {
LOCAL("local"),
HDFS("hdfs"),
S3("s3"),
OSS("oss"),
;
private final String type;
FileSystemType(String type) {
this.type = type;
}
public String getType() {
return type;
}
public static FileSystemType fromType(String type) {
for (FileSystemType value : FileSystemType.values()) {
if (value.getType().equalsIgnoreCase(type)) {
return value;
}
}
return null;
}
}
/*
*
* 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.dinky.metadata.config;
import org.dinky.data.model.CustomConfig;
import org.apache.paimon.options.Options;
import java.util.List;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PaimonConfig implements IConnectConfig {
private List<CustomConfig> paimonConfig;
private String warehouse;
private S3 s3;
private String fileSystemType;
private String catalogType;
public Options getOptions() {
Options options = new Options();
options.set("warehouse", warehouse);
if (Objects.requireNonNull(FileSystemType.fromType(fileSystemType)) == FileSystemType.S3) {
if (s3 != null) {
options.set("s3.endpoint", s3.getEndpoint());
options.set("s3.access-key", s3.getAccessKey());
options.set("s3.secret-key", s3.getSecretKey());
options.set("s3.path.style.access", String.valueOf(s3.isPathStyle()));
} else {
throw new IllegalArgumentException("S3 config is required for S3 file system");
}
}
if (paimonConfig != null) {
for (CustomConfig customConfig : paimonConfig) {
options.set(customConfig.getName(), customConfig.getValue());
}
}
return options;
}
@Data
public static class S3 {
private String endpoint;
private String accessKey;
private String secretKey;
private boolean pathStyle;
}
}
/*
*
* 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.dinky.metadata.convert;
import org.dinky.assertion.Asserts;
import org.dinky.data.enums.ColumnType;
import org.dinky.data.model.Column;
import org.dinky.metadata.config.AbstractJdbcConfig;
import org.dinky.metadata.config.DriverConfig;
import org.apache.paimon.data.GenericRow;
import org.apache.paimon.data.InternalRow;
import org.apache.paimon.types.DataField;
import org.apache.paimon.types.DataTypeRoot;
import java.time.LocalDate;
import java.util.Optional;
/**
* MySqlTypeConvert
*
* @since 2021/7/20 15:21
*/
public class PaimonTypeConvert extends AbstractJdbcTypeConvert {
public PaimonTypeConvert() {
this.convertMap.clear();
register("numeric", ColumnType.DECIMAL);
register("decimal", ColumnType.DECIMAL);
register("bigint", ColumnType.LONG, ColumnType.JAVA_LANG_LONG);
register("float", ColumnType.FLOAT, ColumnType.JAVA_LANG_FLOAT);
register("double", ColumnType.DOUBLE, ColumnType.JAVA_LANG_DOUBLE);
register("boolean", ColumnType.BOOLEAN, ColumnType.JAVA_LANG_BOOLEAN);
register("bit", ColumnType.BOOLEAN, ColumnType.JAVA_LANG_BOOLEAN);
register("datetime", ColumnType.TIMESTAMP);
register("date", ColumnType.DATE);
register("timestamp", ColumnType.TIMESTAMP);
register("time", ColumnType.TIME);
register("char", ColumnType.STRING);
register("text", ColumnType.STRING);
register("binary", ColumnType.BYTES);
register("blob", ColumnType.BYTES);
register("tinyint", PaimonTypeConvert::convertTinyint);
register("mediumint", ColumnType.INT, ColumnType.INTEGER);
register("smallint", ColumnType.INT, ColumnType.INTEGER);
register("int", ColumnType.INT, ColumnType.INTEGER);
}
public static Object SafeGetRowData(DataField fieldType, InternalRow row, int ordinal) {
if (row.isNullAt(ordinal)) {
return null;
}
DataTypeRoot root = fieldType.type().getTypeRoot();
switch (root) {
case CHAR:
case VARCHAR:
return row.getString(ordinal).toString();
case BOOLEAN:
return row.getBoolean(ordinal);
case BINARY:
case VARBINARY:
return "<Binary Type>";
// case DECIMAL:
// return "<DECIMAL Type>";
case TINYINT:
case SMALLINT:
case INTEGER:
return row.getInt(ordinal);
case BIGINT:
return row.getLong(ordinal);
case FLOAT:
return row.getFloat(ordinal);
case DOUBLE:
return row.getDouble(ordinal);
case DATE:
int timeInt = row.getInt(ordinal);
return LocalDate.of(1970, 1, 1).plusDays(timeInt);
case TIME_WITHOUT_TIME_ZONE:
case TIMESTAMP_WITHOUT_TIME_ZONE:
case TIMESTAMP_WITH_LOCAL_TIME_ZONE:
return row.getTimestamp(ordinal, 3).toLocalDateTime();
case ARRAY:
case MULTISET:
return row.getArray(ordinal).toString();
case MAP:
return row.getMap(ordinal).toString();
// case ROW:
// return row.getRow(ordinal).toString();
default:
if (row instanceof GenericRow) {
return ((GenericRow) row).getField(ordinal).toString();
}
return row.getString(ordinal);
}
}
private static Optional<ColumnType> convertTinyint(Column column, DriverConfig<AbstractJdbcConfig> driverConfig) {
Integer length = Asserts.isNull(column.getLength()) ? 0 : column.getLength();
if (!length.equals(1)) {
return Optional.empty();
}
boolean isNullable = !column.isKeyFlag() && column.isNullable();
boolean tinyInt1isBit =
Asserts.isNotNullString(driverConfig.getConnectConfig().getUrl())
&& !driverConfig.getConnectConfig().getUrl().contains("tinyInt1isBit=false");
if (tinyInt1isBit) {
if (isNullable) {
return Optional.of(ColumnType.JAVA_LANG_BOOLEAN);
}
return Optional.of(ColumnType.BOOLEAN);
}
if (isNullable) {
return Optional.of(ColumnType.INTEGER);
}
return Optional.of(ColumnType.INT);
}
@Override
public ColumnType convert(Column column, DriverConfig<AbstractJdbcConfig> driverConfig) {
ColumnType columnType = ColumnType.STRING;
if (Asserts.isNull(column)) {
return columnType;
}
Integer length = Asserts.isNull(column.getLength()) ? 0 : column.getLength();
String t = Asserts.isNull(column.getType()) ? "" : column.getType().toLowerCase();
boolean isNullable = !column.isKeyFlag() && column.isNullable();
boolean tinyInt1isBit =
Asserts.isNotNullString(driverConfig.getConnectConfig().getUrl())
&& !driverConfig.getConnectConfig().getUrl().contains("tinyInt1isBit=false");
if (t.contains("numeric") || t.contains("decimal")) {
columnType = ColumnType.DECIMAL;
} else if (t.contains("bigint")) {
if (isNullable) {
columnType = ColumnType.JAVA_LANG_LONG;
} else {
columnType = ColumnType.LONG;
}
} else if (t.contains("float")) {
if (isNullable) {
columnType = ColumnType.JAVA_LANG_FLOAT;
} else {
columnType = ColumnType.FLOAT;
}
} else if (t.contains("double")) {
if (isNullable) {
columnType = ColumnType.JAVA_LANG_DOUBLE;
} else {
columnType = ColumnType.DOUBLE;
}
} else if (t.contains("boolean")
|| (tinyInt1isBit && t.contains("tinyint") && length.equals(1))
|| t.contains("bit")) {
if (isNullable) {
columnType = ColumnType.JAVA_LANG_BOOLEAN;
} else {
columnType = ColumnType.BOOLEAN;
}
} else if (t.contains("datetime")) {
columnType = ColumnType.TIMESTAMP;
} else if (t.contains("date")) {
columnType = ColumnType.DATE;
} else if (t.contains("timestamp")) {
columnType = ColumnType.TIMESTAMP;
} else if (t.contains("time")) {
columnType = ColumnType.TIME;
} else if (t.contains("char") || t.contains("text")) {
columnType = ColumnType.STRING;
} else if (t.contains("binary") || t.contains("blob")) {
columnType = ColumnType.BYTES;
} else if (t.contains("tinyint") || t.contains("mediumint") || t.contains("smallint") || t.contains("int")) {
if (isNullable) {
columnType = ColumnType.INTEGER;
} else {
columnType = ColumnType.INT;
}
}
return columnType;
}
@Override
public String convertToDB(ColumnType columnType) {
switch (columnType) {
case STRING:
return "varchar";
case BYTE:
return "tinyint";
case SHORT:
return "smallint";
case DECIMAL:
return "decimal";
case LONG:
case JAVA_LANG_LONG:
return "bigint";
case FLOAT:
case JAVA_LANG_FLOAT:
return "float";
case DOUBLE:
case JAVA_LANG_DOUBLE:
return "double";
case BOOLEAN:
case JAVA_LANG_BOOLEAN:
return "boolean";
case TIMESTAMP:
return "datetime";
case DATE:
return "date";
case TIME:
return "time";
case BYTES:
return "binary";
case INTEGER:
case INT:
return "int";
default:
return "varchar";
}
}
}
/*
*
* 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.dinky.metadata.query;
/**
* MySqlQuery
*
* @since 2021/7/20 14:01
*/
public class PaimonQuery extends AbstractDBQuery {
@Override
public String schemaAllSql() {
return "show databases";
}
@Override
public String tablesSql(String schemaName) {
return "select TABLE_NAME AS `NAME`,TABLE_SCHEMA AS `Database`,TABLE_COMMENT AS"
+ " COMMENT,TABLE_CATALOG AS `CATALOG`,TABLE_TYPE AS `TYPE`,ENGINE AS"
+ " `ENGINE`,CREATE_OPTIONS AS `OPTIONS`,TABLE_ROWS AS"
+ " `ROWS`,CREATE_TIME,UPDATE_TIME from information_schema.tables where"
+ " TABLE_SCHEMA = '"
+ schemaName
+ "'";
}
@Override
public String columnsSql(String schemaName, String tableName) {
return "select COLUMN_NAME,COLUMN_TYPE,COLUMN_COMMENT,COLUMN_KEY,EXTRA AS AUTO_INCREMENT"
+ ",COLUMN_DEFAULT,IS_NULLABLE,NUMERIC_PRECISION,NUMERIC_SCALE,CHARACTER_SET_NAME"
+ ",COLLATION_NAME,ORDINAL_POSITION from INFORMATION_SCHEMA.COLUMNS "
+ "where TABLE_SCHEMA = '"
+ schemaName
+ "' and TABLE_NAME = '"
+ tableName
+ "' "
+ "order by ORDINAL_POSITION";
}
@Override
public String schemaName() {
return "Database";
}
@Override
public String columnType() {
return "COLUMN_TYPE";
}
}
...@@ -29,7 +29,6 @@ import org.dinky.metadata.convert.PostgreSqlTypeConvert; ...@@ -29,7 +29,6 @@ import org.dinky.metadata.convert.PostgreSqlTypeConvert;
import org.dinky.metadata.enums.DriverType; import org.dinky.metadata.enums.DriverType;
import org.dinky.metadata.query.IDBQuery; import org.dinky.metadata.query.IDBQuery;
import org.dinky.metadata.query.PostgreSqlQuery; import org.dinky.metadata.query.PostgreSqlQuery;
import org.dinky.utils.TextUtil;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
...@@ -159,8 +158,8 @@ public class PostgreSqlDriver extends AbstractJdbcDriver { ...@@ -159,8 +158,8 @@ public class PostgreSqlDriver extends AbstractJdbcDriver {
String where = queryData.getOption().getWhere(); String where = queryData.getOption().getWhere();
String order = queryData.getOption().getOrder(); String order = queryData.getOption().getOrder();
String limitStart = queryData.getOption().getLimitStart(); int limitStart = queryData.getOption().getLimitStart();
String limitEnd = queryData.getOption().getLimitEnd(); int limitEnd = queryData.getOption().getLimitEnd();
StringBuilder optionBuilder = new StringBuilder() StringBuilder optionBuilder = new StringBuilder()
.append("select * from ") .append("select * from ")
...@@ -174,13 +173,6 @@ public class PostgreSqlDriver extends AbstractJdbcDriver { ...@@ -174,13 +173,6 @@ public class PostgreSqlDriver extends AbstractJdbcDriver {
if (order != null && !order.equals("")) { if (order != null && !order.equals("")) {
optionBuilder.append(" order by ").append(order); optionBuilder.append(" order by ").append(order);
} }
if (TextUtil.isEmpty(limitStart)) {
limitStart = "0";
}
if (TextUtil.isEmpty(limitEnd)) {
limitEnd = "100";
}
optionBuilder.append(" offset ").append(limitStart).append(" limit ").append(limitEnd); optionBuilder.append(" offset ").append(limitStart).append(" limit ").append(limitEnd);
return optionBuilder; return optionBuilder;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
<module>dinky-metadata-hive</module> <module>dinky-metadata-hive</module>
<module>dinky-metadata-starrocks</module> <module>dinky-metadata-starrocks</module>
<module>dinky-metadata-presto</module> <module>dinky-metadata-presto</module>
<module>dinky-metadata-paimon</module>
</modules> </modules>
<dependencies> <dependencies>
......
...@@ -461,6 +461,45 @@ export const PrestoIcons = (props: any) => { ...@@ -461,6 +461,45 @@ export const PrestoIcons = (props: any) => {
); );
}; };
export const PaimonIcons = (props: any) => {
const size = props.size || defaultSvgSize;
return (
<>
<Icon
style={style}
component={() => (
<svg
className='icon'
viewBox='0 0 350.43 277.75'
version='1.1'
xmlns='http://www.w3.org/2000/svg'
width={size}
height={size}
>
<g>
<path
className='cls-5'
d='m343.94,76.12l-50.19,14.1c.47.94.92,1.89,1.36,2.84l48.83-16.94Z'
/>
<path
className='cls-5'
d='m99.32,200.04l-12.62,25.69h-50.11l22.99,4.72c7.55,1.55,14.28,5.8,18.93,11.96l20.16-23.6c3.71-4.16,7.5-8.23,11.36-12.24-2.97-3.76-5.69-7.71-8.15-11.84-.86,1.74-1.72,3.51-2.56,5.31Z'
/>
<path
className='cls-5'
d='m142.18,140.85c-3.51-10.04-11.49-18.15-21.95-21.65l-12.74-4.26h80.4c19.85-7.47,43.6-13.02,72.56-17.39l19.6-3.48,13.7-3.85c-17.9-35.95-55.01-60.65-97.9-60.65-60.37,0-109.3,48.94-109.3,109.3,0,20.41,5.6,39.51,15.34,55.85,11.13-22.5,23.81-40.04,40.29-53.88Z'
/>
<path
className='cls-5'
d='m268.95,102.14c-60.11,22.53-114.4,58.22-158.92,104.43,20.02,25.34,51.02,41.61,85.82,41.61,60.37,0,109.3-48.94,109.3-109.3,0-16.36-3.6-31.88-10.04-45.81l-26.17,9.08Z'
/>
</g>
</svg>
)}
/>
</>
);
};
export const DefaultDBIcons = (props: any) => { export const DefaultDBIcons = (props: any) => {
const size = props.size || defaultSvgSize; const size = props.size || defaultSvgSize;
return ( return (
......
...@@ -31,11 +31,13 @@ import React, { useEffect, useState } from 'react'; ...@@ -31,11 +31,13 @@ import React, { useEffect, useState } from 'react';
// props // props
type SQLQueryProps = { type SQLQueryProps = {
queryParams: QueryParams; queryParams: QueryParams;
hidlenFilter?: boolean;
}; };
const SQLQuery: React.FC<SQLQueryProps> = (props) => { const SQLQuery: React.FC<SQLQueryProps> = (props) => {
const { const {
queryParams: { id: dbId, schemaName, tableName } queryParams: { id: dbId, schemaName, tableName },
hidlenFilter = false
} = props; } = props;
// state // state
...@@ -61,8 +63,8 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => { ...@@ -61,8 +63,8 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
option: { option: {
where: values.where, where: values.where,
order: values.order, order: values.order,
limitStart: '0', limitStart: 0,
limitEnd: '500' limitEnd: 1000
} }
} }
); );
...@@ -159,7 +161,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => { ...@@ -159,7 +161,7 @@ const SQLQuery: React.FC<SQLQueryProps> = (props) => {
dateFormatter='string' dateFormatter='string'
columns={tableData.columns} columns={tableData.columns}
dataSource={tableData.rowData} dataSource={tableData.rowData}
toolBarRender={renderToolBar} toolBarRender={!hidlenFilter && renderToolBar}
tableAlertRender={renderAlert} tableAlertRender={renderAlert}
options={{ options={{
density: false, density: false,
......
...@@ -24,20 +24,21 @@ import { CheckSquareOutlined, KeyOutlined } from '@ant-design/icons'; ...@@ -24,20 +24,21 @@ import { CheckSquareOutlined, KeyOutlined } from '@ant-design/icons';
import { ProTable } from '@ant-design/pro-components'; import { ProTable } from '@ant-design/pro-components';
import { ProColumns } from '@ant-design/pro-table/es/typing'; import { ProColumns } from '@ant-design/pro-table/es/typing';
import React from 'react'; import React from 'react';
import { Empty } from 'antd';
type ColumnInfoProps = { type ColumnInfoProps = {
columnInfo: Partial<DataSources.Column[]>; columnInfo?: Partial<DataSources.Column[]>;
}; };
const ColumnInfo: React.FC<ColumnInfoProps> = (props) => { const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
const { columnInfo } = props; const { columnInfo } = props;
const columns: ProColumns<DataSources.Column>[] = [ const columns: ProColumns<DataSources.Column>[] = [
{ // {
title: l('rc.ds.no'), // title: l('rc.ds.no'),
dataIndex: 'position', // dataIndex: 'position',
width: '4%' // width: '4%'
}, // },
{ {
title: l('rc.ds.columnName'), title: l('rc.ds.columnName'),
dataIndex: 'name', dataIndex: 'name',
...@@ -47,7 +48,7 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => { ...@@ -47,7 +48,7 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
{ {
title: l('rc.ds.columnType'), title: l('rc.ds.columnType'),
dataIndex: 'type', dataIndex: 'type',
width: '6%' width: '10%'
}, },
{ {
title: l('rc.ds.primarykey'), title: l('rc.ds.primarykey'),
...@@ -57,6 +58,14 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => { ...@@ -57,6 +58,14 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
return record.keyFlag ? <KeyOutlined style={{ color: '#FAA100' }} /> : undefined; return record.keyFlag ? <KeyOutlined style={{ color: '#FAA100' }} /> : undefined;
} }
}, },
{
title: 'Partition Key',
dataIndex: 'partaionKey',
width: '4%',
render: (_, record) => {
return record.partaionKey ? <KeyOutlined style={{ color: '#21da31' }} /> : undefined;
}
},
{ {
title: l('rc.ds.autoIncrement'), title: l('rc.ds.autoIncrement'),
dataIndex: 'autoIncrement', dataIndex: 'autoIncrement',
...@@ -86,17 +95,17 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => { ...@@ -86,17 +95,17 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
dataIndex: 'length', dataIndex: 'length',
width: '6%' width: '6%'
}, },
{ // {
title: l('rc.ds.precision'), // title: l('rc.ds.precision'),
dataIndex: 'precision', // dataIndex: 'precision',
width: '4%' // width: '4%'
}, // },
{ // {
title: l('rc.ds.decimalDigits'), // title: l('rc.ds.decimalDigits'),
dataIndex: 'scale', // dataIndex: 'scale',
ellipsis: true, // ellipsis: true,
width: '6%' // width: '6%'
}, // },
{ {
title: l('rc.ds.character'), title: l('rc.ds.character'),
dataIndex: 'characterSet', dataIndex: 'characterSet',
...@@ -124,19 +133,23 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => { ...@@ -124,19 +133,23 @@ const ColumnInfo: React.FC<ColumnInfoProps> = (props) => {
return ( return (
<> <>
<ProTable<DataSources.Column> {columnInfo ? (
toolBarRender={false} <ProTable<DataSources.Column>
pagination={{ toolBarRender={false}
defaultPageSize: 14, pagination={{
hideOnSinglePage: true defaultPageSize: 14,
}} hideOnSinglePage: true
search={false} }}
options={false} search={false}
size={'small'} options={false}
bordered size={'small'}
columns={columns} bordered
dataSource={transformTreeData(columnInfo) as DataSources.Column[]} columns={columns}
/> dataSource={transformTreeData(columnInfo) as DataSources.Column[]}
/>
) : (
<Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')} />
)}
</> </>
); );
}; };
......
/*
*
* 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.
*
*/
import React from 'react';
import ColumnInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/ColumnInfo';
import { DataSources } from '@/types/RegCenter/data';
const GeneralJdbcDesc: React.FC<DataSources.SchemaDescProps> = (props) => {
const { tableInfo, queryParams } = props;
return <ColumnInfo columnInfo={tableInfo?.columns} />;
};
export default GeneralJdbcDesc;
/*
*
* 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.
*
*/
import React from 'react';
import { Tabs, TabsProps } from 'antd';
import ColumnInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/ColumnInfo';
import SQLQuery from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SQLQuery';
import { DataSources } from '@/types/RegCenter/data';
const PaimonDesc: React.FC<DataSources.SchemaDescProps> = (props) => {
const { tableInfo, queryParams } = props;
const getBottomItems = () => {
const items: TabsProps['items'] = [];
items.push({
key: 'Columns',
label: 'ColumnInfo',
children: <ColumnInfo columnInfo={tableInfo?.columns} />
});
if (!queryParams) {
return;
}
items.push({
key: 'Partition',
label: 'Partation',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$partitions'
}}
/>
)
});
items.push({
key: 'snapshots',
label: 'Snapshots',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$snapshots'
}}
/>
)
});
items.push({
key: 'schemas',
label: 'Schema History',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$schemas'
}}
/>
)
});
items.push({
key: 'options',
label: 'Table options',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$options'
}}
/>
)
});
items.push({
key: 'audit_log',
label: 'AuditLog',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$audit_log'
}}
/>
)
});
items.push({
key: 'files',
label: 'Files List',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$files'
}}
/>
)
});
items.push({
key: 'tags',
label: 'Tags',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$tags'
}}
/>
)
});
items.push({
key: 'consumers',
label: 'consumers',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$consumers'
}}
/>
)
});
items.push({
key: 'manifests',
label: 'Manifests Files',
children: (
<SQLQuery
hidlenFilter={true}
queryParams={{
id: queryParams.id,
schemaName: queryParams.schemaName,
tableName: queryParams.tableName + '$manifests'
}}
/>
)
});
return items;
};
return <Tabs type={'card'} items={getBottomItems()} />;
};
export default PaimonDesc;
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
import { DataSources } from '@/types/RegCenter/data'; import { DataSources } from '@/types/RegCenter/data';
import { Descriptions } from 'antd'; import { Descriptions } from 'antd';
import React from 'react'; import React from 'react';
import EllipsisMiddle from '@/components/Typography/EllipsisMiddle';
import { DATA_SOURCE_TYPE } from '@/pages/RegCenter/DataSource/components/constants';
type TableInfoProps = { type TableInfoProps = {
tableInfo: Partial<DataSources.Table>; tableInfo: Partial<DataSources.Table>;
...@@ -28,21 +30,43 @@ type TableInfoProps = { ...@@ -28,21 +30,43 @@ type TableInfoProps = {
const TableInfo: React.FC<TableInfoProps> = (props) => { const TableInfo: React.FC<TableInfoProps> = (props) => {
const { tableInfo } = props; const { tableInfo } = props;
const splitOptions = () => {
const dt = tableInfo.driverType;
if (DATA_SOURCE_TYPE.PAIMON == dt) {
const options = JSON.parse(tableInfo.options ?? '{}');
return (
<>
{Object.entries(options).map(([key]) => (
<Descriptions.Item key={key} label={key}>
<EllipsisMiddle maxCount={20} children={options[key]} copyable={false} />
</Descriptions.Item>
))}
</>
);
} else {
return (
<>
<Descriptions.Item label='Catalog'>{tableInfo.catalog}</Descriptions.Item>
<Descriptions.Item label='Rows'>{tableInfo.rows}</Descriptions.Item>
<Descriptions.Item label='Type'>{tableInfo.type}</Descriptions.Item>
<Descriptions.Item label='Engine'>{tableInfo.engine}</Descriptions.Item>
<Descriptions.Item label='Options'>{tableInfo.options}</Descriptions.Item>
<Descriptions.Item label='CreateTime'>{tableInfo.createTime}</Descriptions.Item>
<Descriptions.Item label='UpdateTime'>{tableInfo.updateTime || '-'}</Descriptions.Item>
<Descriptions.Item label='Comment' span={3}>
{tableInfo.comment || '-'}
</Descriptions.Item>
</>
);
}
};
return ( return (
<> <>
<Descriptions size={'small'} bordered column={4}> <Descriptions size={'small'} bordered column={3}>
<Descriptions.Item label='Name'>{tableInfo.name}</Descriptions.Item> <Descriptions.Item label='Name'>{tableInfo.name}</Descriptions.Item>
<Descriptions.Item label='Schema'>{tableInfo.schema}</Descriptions.Item> <Descriptions.Item label='Schema'>{tableInfo.schema}</Descriptions.Item>
<Descriptions.Item label='Catalog'>{tableInfo.catalog}</Descriptions.Item> {splitOptions()}
<Descriptions.Item label='Rows'>{tableInfo.rows}</Descriptions.Item>
<Descriptions.Item label='Type'>{tableInfo.type}</Descriptions.Item>
<Descriptions.Item label='Engine'>{tableInfo.engine}</Descriptions.Item>
<Descriptions.Item label='Options'>{tableInfo.options}</Descriptions.Item>
<Descriptions.Item label='CreateTime'>{tableInfo.createTime}</Descriptions.Item>
<Descriptions.Item label='UpdateTime'>{tableInfo.updateTime || '-'}</Descriptions.Item>
<Descriptions.Item label='Comment' span={3}>
{tableInfo.comment || '-'}
</Descriptions.Item>
</Descriptions> </Descriptions>
</> </>
); );
......
...@@ -17,28 +17,28 @@ ...@@ -17,28 +17,28 @@
* *
*/ */
import ColumnInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/ColumnInfo';
import TableInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/TableInfo'; import TableInfo from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/TableInfo';
import { DataSources } from '@/types/RegCenter/data'; import { DataSources } from '@/types/RegCenter/data';
import { l } from '@/utils/intl';
import { Empty } from 'antd';
import React from 'react'; import React from 'react';
import PaimonDesc from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/PaimonDesc/PaimonDesc';
import { DATA_SOURCE_TYPE } from '@/pages/RegCenter/DataSource/components/constants';
import GeneralJdbcDesc from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/SchemaDesc/GeneralJdbcDesc/GeneralJdbcDesc';
type SchemaDescProps = { const SchemaDesc: React.FC<DataSources.SchemaDescProps> = (props) => {
tableInfo?: Partial<DataSources.Table>; const { tableInfo, queryParams } = props;
tableColumns?: Partial<DataSources.Column[]>;
};
const SchemaDesc: React.FC<SchemaDescProps> = (props) => { const getBottomItems = () => {
const { tableInfo, tableColumns } = props; if (tableInfo?.driverType == DATA_SOURCE_TYPE.PAIMON) {
return <PaimonDesc tableInfo={tableInfo} queryParams={queryParams} />;
} else {
return <GeneralJdbcDesc tableInfo={tableInfo} />;
}
};
return ( return (
<> <>
{tableInfo && <TableInfo tableInfo={tableInfo} />} {tableInfo && <TableInfo tableInfo={tableInfo} />}
{tableColumns && <ColumnInfo columnInfo={tableColumns} />} {getBottomItems()}
{!tableInfo && !tableColumns && (
<Empty className={'code-content-empty'} description={l('rc.ds.detail.tips')} />
)}
</> </>
); );
}; };
......
...@@ -48,15 +48,12 @@ type RightTagsRouterProps = { ...@@ -48,15 +48,12 @@ type RightTagsRouterProps = {
const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => { const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
const access = useAccess(); const access = useAccess();
const { tableInfo, queryParams, tagDisabled = false, rightButtons } = props; const { queryParams, tagDisabled = false, rightButtons } = props;
const [tableColumns, setTableColumns] = useState<Partial<DataSources.Column[]>>([]); const [tableInfo, setTableInfo] = useState<Partial<DataSources.Table>>({});
useEffect(() => { useEffect(() => {
const fetchData = async () => { const fetchData = async () => {
const result = await queryDataByParams( const result = await queryDataByParams(API_CONSTANTS.DATASOURCE_GET_TABLE, queryParams);
API_CONSTANTS.DATASOURCE_GET_COLUMNS_BY_TABLE, setTableInfo(result as DataSources.Table);
queryParams
);
setTableColumns(result as DataSources.Column[]);
}; };
if (queryParams.id !== 0) { if (queryParams.id !== 0) {
fetchData(); fetchData();
...@@ -75,7 +72,7 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => { ...@@ -75,7 +72,7 @@ const RightTagsRouter: React.FC<RightTagsRouterProps> = (props) => {
{l('rc.ds.detail.tag.desc')} {l('rc.ds.detail.tag.desc')}
</Space> </Space>
), ),
children: <SchemaDesc tableInfo={tableInfo} tableColumns={tableColumns} />, children: <SchemaDesc queryParams={queryParams} tableInfo={tableInfo} />,
disabled: tagDisabled, disabled: tagDisabled,
auth: PermissionConstants.REGISTRATION_DATA_SOURCE_DETAIL_DESC auth: PermissionConstants.REGISTRATION_DATA_SOURCE_DETAIL_DESC
}, },
......
...@@ -20,17 +20,26 @@ ...@@ -20,17 +20,26 @@
import CodeEdit from '@/components/CustomEditor/CodeEdit'; import CodeEdit from '@/components/CustomEditor/CodeEdit';
import { import {
AUTO_COMPLETE_TYPE, AUTO_COMPLETE_TYPE,
DATA_SOURCE_TYPE,
DATA_SOURCE_TYPE_OPTIONS, DATA_SOURCE_TYPE_OPTIONS,
GROUP_TYPE GROUP_TYPE
} from '@/pages/RegCenter/DataSource/components/constants'; } from '@/pages/RegCenter/DataSource/components/constants';
import { DataSources } from '@/types/RegCenter/data.d'; import { DataSources } from '@/types/RegCenter/data.d';
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
import { ProForm, ProFormGroup, ProFormSelect, ProFormText } from '@ant-design/pro-components'; import {
ProForm,
ProFormGroup,
ProFormSelect,
ProFormText,
ProFormTextArea
} from '@ant-design/pro-components';
import { AutoComplete, Form } from 'antd'; import { AutoComplete, Form } from 'antd';
import { FormInstance } from 'antd/es/form/hooks/useForm'; import { FormInstance } from 'antd/es/form/hooks/useForm';
import TextArea from 'antd/es/input/TextArea'; import TextArea from 'antd/es/input/TextArea';
import { Values } from 'async-validator'; import { Values } from 'async-validator';
import React from 'react'; import React, { useState } from 'react';
import PaimonSourceForm from '@/pages/RegCenter/DataSource/components/DataSourceView/GeneralJdbc/PaimonSourceForm';
import JdbcSourceForm from '@/pages/RegCenter/DataSource/components/DataSourceView/GeneralJdbc/JdbcSourceForm';
type DataSourceProFormProps = { type DataSourceProFormProps = {
values: Partial<DataSources.DataSource>; values: Partial<DataSources.DataSource>;
...@@ -50,8 +59,17 @@ const CodeEditProps = { ...@@ -50,8 +59,17 @@ const CodeEditProps = {
const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
const { values, form, dbType, excludeFormItem, flinkTemplateChange, flinkConfigChange } = props; const { values, form, dbType, excludeFormItem, flinkTemplateChange, flinkConfigChange } = props;
const [selectDbType, setSelectDbType] = useState<string>(dbType);
const renderDataSourceForm = () => { const renderDataSourceForm = (type?: string) => {
switch (type) {
case DATA_SOURCE_TYPE.PAIMON:
return <PaimonSourceForm form={form} />;
default:
return <JdbcSourceForm form={form} />;
}
};
const renderForm = () => {
return ( return (
<> <>
<ProForm.Group> <ProForm.Group>
...@@ -74,60 +92,13 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { ...@@ -74,60 +92,13 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
width={'sm'} width={'sm'}
label={l('rc.ds.type')} label={l('rc.ds.type')}
showSearch showSearch
onChange={(v: string) => setSelectDbType(v)}
initialValue={dbType} initialValue={dbType}
options={DATA_SOURCE_TYPE_OPTIONS} options={DATA_SOURCE_TYPE_OPTIONS}
rules={[{ required: true, message: l('rc.ds.typePlaceholder') }]} rules={[{ required: true, message: l('rc.ds.typePlaceholder') }]}
placeholder={l('rc.ds.typePlaceholder')} placeholder={l('rc.ds.typePlaceholder')}
/> />
{renderDataSourceForm(selectDbType)}
<ProFormText
name={['connectConfig', 'username']}
width={'sm'}
label={l('rc.ds.username')}
rules={[{ required: true, message: l('rc.ds.usernamePlaceholder') }]}
placeholder={l('rc.ds.usernamePlaceholder')}
/>
<ProFormText.Password
name={['connectConfig', 'password']}
width={'sm'}
label={l('rc.ds.password')}
placeholder={l('rc.ds.passwordPlaceholder')}
/>
<ProFormText
name='note'
width={'md'}
label={l('global.table.note')}
placeholder={l('global.table.notePlaceholder')}
/>
</ProForm.Group>
<ProForm.Group>
<Form.Item
name={['connectConfig', 'url']}
label={l('rc.ds.url')}
rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}
>
<AutoComplete
virtual
placement={'topLeft'}
autoClearSearchValue
options={AUTO_COMPLETE_TYPE}
style={{
width: parent.innerWidth / 2 - 80
}}
filterOption
onSelect={(value) => form && form.setFieldsValue({ url: value })}
>
<TextArea placeholder={l('rc.ds.urlPlaceholder')} />
{/*<ProFormTextArea*/}
{/* name='url'*/}
{/* width={parent.innerWidth / 2 - 80}*/}
{/* label={l('rc.ds.url')}*/}
{/* rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}*/}
{/* placeholder={l('rc.ds.urlPlaceholder')}*/}
{/*/>*/}
</AutoComplete>
</Form.Item>
</ProForm.Group> </ProForm.Group>
{!excludeFormItem && ( {!excludeFormItem && (
...@@ -157,10 +128,15 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => { ...@@ -157,10 +128,15 @@ const DataSourceProForm: React.FC<DataSourceProFormProps> = (props) => {
</ProForm.Item> </ProForm.Item>
</ProFormGroup> </ProFormGroup>
)} )}
<ProFormText
name='note'
label={l('global.table.note')}
placeholder={l('global.table.notePlaceholder')}
/>
</> </>
); );
}; };
return renderDataSourceForm(); return renderForm();
}; };
export default DataSourceProForm; export default DataSourceProForm;
/*
*
* 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.
*
*/
import { ProForm, ProFormText } from '@ant-design/pro-components';
import { l } from '@/utils/intl';
import React from 'react';
import { AutoComplete, Form } from 'antd';
import { AUTO_COMPLETE_TYPE } from '@/pages/RegCenter/DataSource/components/constants';
import TextArea from 'antd/es/input/TextArea';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import { Values } from 'async-validator';
type DataSourceJdbcProps = {
form: FormInstance<Values>;
};
const JdbcSourceForm: React.FC<DataSourceJdbcProps> = (props) => {
const { form } = props;
return (
<ProForm.Group>
<ProFormText
name={['connectConfig', 'username']}
width={'sm'}
label={l('rc.ds.username')}
rules={[{ required: true, message: l('rc.ds.usernamePlaceholder') }]}
placeholder={l('rc.ds.usernamePlaceholder')}
/>
<ProFormText.Password
name={['connectConfig', 'password']}
width={'sm'}
label={l('rc.ds.password')}
placeholder={l('rc.ds.passwordPlaceholder')}
/>
<ProForm.Group>
<Form.Item
name={['connectConfig', 'url']}
label={l('rc.ds.url')}
rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}
>
<AutoComplete
virtual
placement={'topLeft'}
autoClearSearchValue
options={AUTO_COMPLETE_TYPE}
style={{
width: parent.innerWidth / 2 - 80
}}
filterOption
onSelect={(value) => form && form.setFieldsValue({ url: value })}
>
<TextArea placeholder={l('rc.ds.urlPlaceholder')} />
{/*<ProFormTextArea*/}
{/* name='url'*/}
{/* width={parent.innerWidth / 2 - 80}*/}
{/* label={l('rc.ds.url')}*/}
{/* rules={[{ required: true, message: l('rc.ds.urlPlaceholder') }]}*/}
{/* placeholder={l('rc.ds.urlPlaceholder')}*/}
{/*/>*/}
</AutoComplete>
</Form.Item>
</ProForm.Group>
</ProForm.Group>
);
};
export default JdbcSourceForm;
/*
*
* 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.
*
*/
import {
ProFormGroup,
ProFormList,
ProFormRadio,
ProFormSegmented,
ProFormText
} from '@ant-design/pro-components';
import { l } from '@/utils/intl';
import React from 'react';
import { Segmented, Space } from 'antd';
import { FormInstance } from 'antd/es/form/hooks/useForm';
import { Values } from 'async-validator';
type DataSourceJdbcProps = {
form: FormInstance<Values>;
};
const PaimonSourceForm: React.FC<DataSourceJdbcProps> = (props) => {
const { form } = props;
const [fileSystemType, setFileSystemType] = React.useState<string | number>('S3'); // ['S3', 'HDFS', 'LOCAL']
const [catalogType, setCatalogType] = React.useState<string | number>('FileSystem'); // ['FileSystem', 'JDBC', 'Hive']
const renderConfig = () => {
return (
<Space direction={'horizontal'} size={60}>
<ProFormSegmented
name={['connectConfig', 'catalogType']}
label='Catalog Type'
request={async () => [
{ label: 'FileSystem', value: 'FileSystem', disabled: false },
{ label: 'JDBC', value: 'JDBC', disabled: true },
{ label: 'Hive', value: 'Hive', disabled: true }
]}
required
fieldProps={{
onChange: (value) => setCatalogType(value)
}}
/>
<ProFormSegmented
name={['connectConfig', 'fileSystemType']}
label='File System Type'
request={async () => [
{ label: 'S3', value: 'S3', disabled: false },
{ label: 'HDFS', value: 'HDFS', disabled: true },
{ label: 'LOCAL', value: 'LOCAL', disabled: false }
]}
required
fieldProps={{
onChange: (value) => setFileSystemType(value)
}}
/>
</Space>
);
};
const renderS3Config = () => {
return (
<>
<ProFormText
name={['connectConfig', 's3', 'endpoint']}
label='s3.endpoint'
width={'md'}
required={true}
/>
<ProFormText
name={['connectConfig', 's3', 'accessKey']}
label='s3.access-key'
width={'md'}
required={true}
/>
<ProFormText
name={['connectConfig', 's3', 'secretKey']}
label='s3.secret-key'
width={'md'}
required={true}
/>
<ProFormRadio.Group
name={['connectConfig', 's3', 'pathStyle']}
label='s3.path.style.access'
required
options={[
{
label: 'true',
value: true
},
{
label: 'false',
value: false
}
]}
/>
</>
);
};
return (
<div>
{renderConfig()}
<br />
<ProFormGroup>
<ProFormText
name={['connectConfig', 'warehouse']}
label='warehouse'
width={'md'}
required={true}
/>
{fileSystemType === 'S3' && renderS3Config()}
</ProFormGroup>
<ProFormList
label={'Paimon Other Config Options'}
name={['connectConfig', 'paimonConfig']}
copyIconProps={false}
deleteIconProps={{
tooltipText: l('rc.cc.deleteConfig')
}}
creatorButtonProps={{
creatorButtonText: l('rc.cc.addConfig')
}}
>
<ProFormGroup key='headersGroup' style={{ width: '100%' }}>
<Space key={'config'}>
<ProFormText name='name' width={'md'} placeholder={l('rc.cc.key')} />
<ProFormText name='value' width={'xl'} placeholder={l('rc.cc.value')} />
</Space>
</ProFormGroup>
</ProFormList>
</div>
);
};
export default PaimonSourceForm;
...@@ -19,6 +19,22 @@ ...@@ -19,6 +19,22 @@
import { l } from '@/utils/intl'; import { l } from '@/utils/intl';
/**
* data source type
*/
export const DATA_SOURCE_TYPE = {
MYSQL: 'MySQL',
ORACLE: 'Oracle',
POSTGRESQL: 'PostgreSQL',
SQLSERVER: 'SQLServer',
CLICKHOUSE: 'ClickHouse',
DORIS: 'Doris',
STARROCKS: 'StarRocks',
PRESTO: 'Presto',
PHOENIX: 'Phoenix',
HIVE: 'Hive',
PAIMON: 'Paimon'
};
/** /**
* data source type * data source type
*/ */
...@@ -29,23 +45,23 @@ export const DATA_SOURCE_TYPE_OPTIONS = [ ...@@ -29,23 +45,23 @@ export const DATA_SOURCE_TYPE_OPTIONS = [
options: [ options: [
{ {
label: 'MySQL', label: 'MySQL',
value: 'MySQL' value: DATA_SOURCE_TYPE.MYSQL
}, },
{ {
label: 'Oracle', label: 'Oracle',
value: 'Oracle' value: DATA_SOURCE_TYPE.ORACLE
}, },
{ {
label: 'PostgreSQL', label: 'PostgreSQL',
value: 'PostgreSQL' value: DATA_SOURCE_TYPE.POSTGRESQL
}, },
{ {
label: 'SQLServer', label: 'SQLServer',
value: 'SQLServer' value: DATA_SOURCE_TYPE.SQLSERVER
}, },
{ {
label: 'Phoenix', label: 'Phoenix',
value: 'Phoenix' value: DATA_SOURCE_TYPE.PHOENIX
} }
] ]
}, },
...@@ -54,19 +70,23 @@ export const DATA_SOURCE_TYPE_OPTIONS = [ ...@@ -54,19 +70,23 @@ export const DATA_SOURCE_TYPE_OPTIONS = [
options: [ options: [
{ {
label: 'ClickHouse', label: 'ClickHouse',
value: 'ClickHouse' value: DATA_SOURCE_TYPE.CLICKHOUSE
}, },
{ {
label: 'Doris', label: 'Doris',
value: 'Doris' value: DATA_SOURCE_TYPE.DORIS
}, },
{ {
label: 'StarRocks', label: 'StarRocks',
value: 'StarRocks' value: DATA_SOURCE_TYPE.STARROCKS
}, },
{ {
label: 'Presto', label: 'Presto',
value: 'Presto' value: DATA_SOURCE_TYPE.PRESTO
},
{
label: 'Paimon',
value: DATA_SOURCE_TYPE.PAIMON
} }
] ]
}, },
...@@ -75,7 +95,7 @@ export const DATA_SOURCE_TYPE_OPTIONS = [ ...@@ -75,7 +95,7 @@ export const DATA_SOURCE_TYPE_OPTIONS = [
options: [ options: [
{ {
label: 'Hive', label: 'Hive',
value: 'Hive' value: DATA_SOURCE_TYPE.HIVE
} }
] ]
} }
......
...@@ -24,6 +24,7 @@ import { ...@@ -24,6 +24,7 @@ import {
HiveIcons, HiveIcons,
MysqlIcons, MysqlIcons,
OracleIcons, OracleIcons,
PaimonIcons,
PhoenixIcons, PhoenixIcons,
PostgresqlIcons, PostgresqlIcons,
PrestoIcons, PrestoIcons,
...@@ -60,6 +61,8 @@ export const renderDBIcon = (type: string, size?: number) => { ...@@ -60,6 +61,8 @@ export const renderDBIcon = (type: string, size?: number) => {
return <StarRocksIcons size={size} />; return <StarRocksIcons size={size} />;
case DIALECT.PRESTO: case DIALECT.PRESTO:
return <PrestoIcons size={size} />; return <PrestoIcons size={size} />;
case DIALECT.PAIMON:
return <PaimonIcons size={size} />;
default: default:
return <DefaultDBIcons size={size} />; return <DefaultDBIcons size={size} />;
} }
......
...@@ -224,7 +224,8 @@ export const DIALECT = { ...@@ -224,7 +224,8 @@ export const DIALECT = {
PHOENIX: 'phoenix', PHOENIX: 'phoenix',
STARROCKS: 'starrocks', STARROCKS: 'starrocks',
PRESTO: 'presto', PRESTO: 'presto',
TERMINAL: 'terminal' TERMINAL: 'terminal',
PAIMON: 'paimon'
}; };
export const RUN_MODE = { export const RUN_MODE = {
......
...@@ -110,6 +110,7 @@ export enum API_CONSTANTS { ...@@ -110,6 +110,7 @@ export enum API_CONSTANTS {
DATASOURCE_UN_CACHE_SCHEMA_TABLES = '/api/database/unCacheSchemasAndTables', DATASOURCE_UN_CACHE_SCHEMA_TABLES = '/api/database/unCacheSchemasAndTables',
DATASOURCE_LIST_ENABLE_ALL = '/api/database/listEnabledAll', DATASOURCE_LIST_ENABLE_ALL = '/api/database/listEnabledAll',
DATASOURCE_GET_COLUMNS_BY_TABLE = '/api/database/listColumns', DATASOURCE_GET_COLUMNS_BY_TABLE = '/api/database/listColumns',
DATASOURCE_GET_TABLE = '/api/database/getTable',
DATASOURCE_GET_GEN_SQL = '/api/database/getSqlGeneration', DATASOURCE_GET_GEN_SQL = '/api/database/getSqlGeneration',
DATASOURCE_QUERY_DATA = '/api/database/queryData', DATASOURCE_QUERY_DATA = '/api/database/queryData',
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
import { BaseBeanColumns } from '@/types/Public/data'; import { BaseBeanColumns } from '@/types/Public/data';
import { ConfigItem } from '@/types/Studio/data.d'; import { ConfigItem } from '@/types/Studio/data.d';
import { QueryParams } from '@/pages/RegCenter/DataSource/components/DataSourceDetail/RightTagsRouter/data';
/** /**
* about alert * about alert
...@@ -214,6 +215,15 @@ declare namespace Cluster { ...@@ -214,6 +215,15 @@ declare namespace Cluster {
* about database and metadata * about database and metadata
*/ */
declare namespace DataSources { declare namespace DataSources {
/**
* SchemaDescProps info
*/
export type SchemaDescProps = {
tableInfo?: Partial<DataSources.Table>;
tableColumns?: Partial<DataSources.Column[]>;
queryParams?: QueryParams;
};
/** /**
* database info * database info
*/ */
...@@ -243,6 +253,8 @@ declare namespace DataSources { ...@@ -243,6 +253,8 @@ declare namespace DataSources {
type: string; type: string;
engine: string; engine: string;
options: string; options: string;
driverType: string;
columns?: Column[];
rows: number; rows: number;
createTime: string; createTime: string;
updateTime: string; updateTime: string;
...@@ -256,6 +268,7 @@ declare namespace DataSources { ...@@ -256,6 +268,7 @@ declare namespace DataSources {
type: string; type: string;
comment: string; comment: string;
keyFlag: boolean; keyFlag: boolean;
partaionKey: boolean;
autoIncrement: boolean; autoIncrement: boolean;
defaultValue: string; defaultValue: string;
nullable: string; nullable: string;
...@@ -355,6 +368,7 @@ export interface UDFRegisterInfo { ...@@ -355,6 +368,7 @@ export interface UDFRegisterInfo {
// createTime: string; // createTime: string;
updateTime: Date; updateTime: Date;
} }
export interface UDFRegisterInfoParent { export interface UDFRegisterInfoParent {
num: number; num: number;
resourcesId: number; resourcesId: number;
...@@ -362,6 +376,7 @@ export interface UDFRegisterInfoParent { ...@@ -362,6 +376,7 @@ export interface UDFRegisterInfoParent {
source: string; source: string;
fileName: string; fileName: string;
} }
export interface UDFRegisterInfoChild { export interface UDFRegisterInfoChild {
id: number; id: number;
resourcesId: number; resourcesId: number;
......
...@@ -481,6 +481,11 @@ ...@@ -481,6 +481,11 @@
<artifactId>dinky-common</artifactId> <artifactId>dinky-common</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.dinky</groupId>
<artifactId>dinky-metadata-paimon</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.dinky</groupId> <groupId>org.dinky</groupId>
<artifactId>dinky-metadata-base</artifactId> <artifactId>dinky-metadata-base</artifactId>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment