diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseConfigBuilder.java b/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseConfigBuilder.java new file mode 100644 index 000000000..95b92abf2 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseConfigBuilder.java @@ -0,0 +1,31 @@ +/* + * 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 io.datavines.connector.plugin; + + +import io.datavines.common.param.form.type.InputParam; + +public class ClickHouseConfigBuilder extends JdbcConfigBuilder { + + @Override + protected InputParam getPasswordInput(boolean isEn) { + return getInputParam("password", + isEn ? "password" : "密码", + isEn ? "please enter password" : "请填入密码", 1, null, + null); + } +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseConnectorFactory.java b/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseConnectorFactory.java index fa41e34de..ae3e5e6d7 100644 --- a/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseConnectorFactory.java +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseConnectorFactory.java @@ -44,4 +44,14 @@ public Executor getExecutor() { public MetricScript getMetricScript() { return new ClickHouseMetricScript(); } + + @Override + public ConfigBuilder getConfigBuilder() { + return new ClickHouseConfigBuilder(); + } + + @Override + public TypeConverter getTypeConverter() { + return new ClickHouseTypeConverter(); + } } diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseTypeConverter.java b/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseTypeConverter.java new file mode 100644 index 000000000..a5a661cc4 --- /dev/null +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-clickhouse/src/main/java/io/datavines/connector/plugin/ClickHouseTypeConverter.java @@ -0,0 +1,39 @@ +/* + * 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 io.datavines.connector.plugin; + + +import io.datavines.common.enums.DataType; +import io.datavines.common.utils.StringUtils; + +public class ClickHouseTypeConverter extends JdbcTypeConverter { + @Override + public DataType convert(String originType) { + if (StringUtils.isEmpty(originType)) { + throw new UnsupportedOperationException("sql type id null error"); + } + + switch (originType.toUpperCase()) { + case "DECIMAL32": + case "DECIMAL64": + return DataType.BIG_DECIMAL_TYPE; + default: + return super.convert(originType); + } + + } +} diff --git a/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java b/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java index 54a9f11c9..e3b7eee17 100644 --- a/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java +++ b/datavines-connector/datavines-connector-plugins/datavines-connector-jdbc/src/main/java/io/datavines/connector/plugin/JdbcConnector.java @@ -45,8 +45,6 @@ public abstract class JdbcConnector implements Connector, IJdbcDataSourceInfo { protected static final String TABLE = "TABLE"; - protected static final String DATABASE = "DATABASE"; - protected static final String VIEW = "VIEW"; protected static final String[] TABLE_TYPES = new String[]{TABLE, VIEW}; diff --git a/datavines-engine/datavines-engine-config/src/main/java/io/datavines/engine/config/MetricParserUtils.java b/datavines-engine/datavines-engine-config/src/main/java/io/datavines/engine/config/MetricParserUtils.java index d9cc63f67..eb4a4f7d3 100644 --- a/datavines-engine/datavines-engine-config/src/main/java/io/datavines/engine/config/MetricParserUtils.java +++ b/datavines-engine/datavines-engine-config/src/main/java/io/datavines/engine/config/MetricParserUtils.java @@ -174,9 +174,9 @@ public static String getTableAliasColumns(List mappingColumnList, for (int i = 0; i < mappingColumnList.size(); i++) { MappingColumn column = mappingColumnList.get(i); if (index == 1) { - columnList[i] = tableAlias + "." + QuoteIdentifier.quote(column.getColumn(), needQuote) + " AS " + QuoteIdentifier.quote(column.getColumn() + "_" + index, needQuote);; + columnList[i] = tableAlias + "." + QuoteIdentifier.quote(column.getColumn(), needQuote) + " AS " + QuoteIdentifier.quote(column.getColumn() + "_" + index, needQuote); } else if (index == 2){ - columnList[i] = tableAlias + "." + QuoteIdentifier.quote(column.getColumn2(), needQuote) + " AS " + QuoteIdentifier.quote(column.getColumn2() + "_" + index, needQuote);; + columnList[i] = tableAlias + "." + QuoteIdentifier.quote(column.getColumn2(), needQuote) + " AS " + QuoteIdentifier.quote(column.getColumn2() + "_" + index, needQuote); } } @@ -191,7 +191,7 @@ public static String getWhereClause(List mappingColumnList,Map columns, boolean needQuote) { diff --git a/datavines-server/src/main/java/io/datavines/server/config/JacksonConfig.java b/datavines-server/src/main/java/io/datavines/server/config/JacksonConfig.java new file mode 100644 index 000000000..28131ceff --- /dev/null +++ b/datavines-server/src/main/java/io/datavines/server/config/JacksonConfig.java @@ -0,0 +1,45 @@ +/* + * 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 io.datavines.server.config; + +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; + +import java.math.BigDecimal; +import java.math.BigInteger; + +@Configuration +public class JacksonConfig { + + /** + * Configure Jackson to serialize long, Long, BigInteger, BigDecimal as JSON strings + * to preserve precision for large numeric values in JavaScript frontends. + */ + @Bean + public Jackson2ObjectMapperBuilderCustomizer jacksonLongToString() { + return builder -> { + // Serialize primitive long and Long wrapper as String + builder.serializerByType(Long.class, ToStringSerializer.instance); + builder.serializerByType(long.class, ToStringSerializer.instance); + // Also handle BigInteger and BigDecimal as String + builder.serializerByType(BigInteger.class, ToStringSerializer.instance); + builder.serializerByType(BigDecimal.class, ToStringSerializer.instance); + }; + } +} \ No newline at end of file diff --git a/datavines-server/src/main/resources/mapper/JobMapper.xml b/datavines-server/src/main/resources/mapper/JobMapper.xml index 75713879a..f3ef9475b 100644 --- a/datavines-server/src/main/resources/mapper/JobMapper.xml +++ b/datavines-server/src/main/resources/mapper/JobMapper.xml @@ -38,7 +38,7 @@