Skip to content

Commit

Permalink
[feat] Upgrade Gradle to 7.3, upgrade JDK to 17, and fix interval and…
Browse files Browse the repository at this point in the history
… extract functions
  • Loading branch information
wt0530 committed Feb 21, 2025
1 parent 7e3a7be commit c0b64fa
Show file tree
Hide file tree
Showing 90 changed files with 1,640 additions and 308 deletions.
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
image: gradle:6.9.0-jdk8
image: gradle:7.3-jdk17

variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
Expand Down
12 changes: 9 additions & 3 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ allprojects {
mavenCentral()
maven {
url 'http://packages.confluent.io/maven/'
allowInsecureProtocol = true
}
// maven {
// url 'http://maven.aliyun.com/nexus/content/groups/public/'
// }
}
}

tasks.withType(Jar).configureEach {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/java-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
languageVersion.set(JavaLanguageVersion.of(17))
}
}

Expand Down
2 changes: 2 additions & 0 deletions dingo-calcite/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies {
implementation group: 'org.apache.commons', name: 'commons-lang3', version: 'commons-lang3'.v()
implementation group: 'net.agkn', name: 'hll', version: 'hll'.v()
implementation group: 'io.dingodb.expr', name: 'dingo-expr-coding', version: 'dingo-expr'.v()
implementation group: 'io.dingodb.expr', name: 'dingo-expr-common', version: 'dingo-expr'.v()
implementation group: 'io.dropwizard.metrics', name: 'metrics-core', version: 'metrics-core'.v()

api group: 'io.dingodb.expr', name: 'dingo-expr-parser', version: 'dingo-expr'.v()
api group: 'io.dingodb.expr', name: 'dingo-expr-rel', version: 'dingo-expr'.v()
Expand Down
2 changes: 1 addition & 1 deletion dingo-calcite/src/main/codegen/includes/parserImpls.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -731,7 +731,7 @@ Number number(): {
t = <DECIMAL_NUMERIC_LITERAL>
{

return new Double(t.image);
return Double.valueOf(t.image);
}
) | (
<MINUS>
Expand Down
5 changes: 3 additions & 2 deletions dingo-calcite/src/main/codegen/templates/Parser.jj
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import org.apache.calcite.sql.parser.SqlParserPos;
import org.apache.calcite.sql.parser.SqlParserUtil;
import org.apache.calcite.sql.type.SqlTypeName;
import org.apache.calcite.sql.validate.SqlConformance;
import org.apache.calcite.util.DingoParserUtils;
import org.apache.calcite.util.Glossary;
import org.apache.calcite.util.Pair;
import org.apache.calcite.util.SourceStringReader;
Expand Down Expand Up @@ -5175,7 +5176,7 @@ SqlLiteral IntervalLiteral() :
]
p = SimpleStringLiteral()
intervalQualifier = IntervalQualifier() {
return SqlParserUtil.parseIntervalLiteral(s.end(intervalQualifier),
return DingoParserUtils.parseIntervalLiteral(s.end(intervalQualifier),
sign, p, intervalQualifier);
}
}
Expand All @@ -5202,7 +5203,7 @@ SqlNode IntervalLiteralOrExpression() :
// literal (with quoted string)
p = SimpleStringLiteral()
intervalQualifier = IntervalQualifier() {
return SqlParserUtil.parseIntervalLiteral(s.end(intervalQualifier),
return DingoParserUtils.parseIntervalLiteral(s.end(intervalQualifier),
sign, p, intervalQualifier);
}
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
import org.apache.calcite.schema.ColumnStrategy;
import org.apache.calcite.schema.Schema;
import org.apache.calcite.server.DdlExecutorImpl;
import org.apache.calcite.sql.DingoAnsiSqlDialect;
import org.apache.calcite.sql.SqlBasicTypeNameSpec;
import org.apache.calcite.sql.SqlCall;
import org.apache.calcite.sql.SqlDataTypeSpec;
Expand All @@ -161,7 +162,6 @@
import org.apache.calcite.sql.ddl.SqlDropTable;
import org.apache.calcite.sql.ddl.SqlDropView;
import org.apache.calcite.sql.ddl.SqlKeyConstraint;
import org.apache.calcite.sql.dialect.AnsiSqlDialect;
import org.apache.calcite.sql.dialect.CalciteSqlDialect;
import org.apache.calcite.sql.fun.SqlStdOperatorTable;
import org.apache.calcite.sql.parser.SqlParserPos;
Expand Down Expand Up @@ -2502,7 +2502,7 @@ private static IndexDefinition fromSqlIndexDeclaration(
if (strategy == ColumnStrategy.DEFAULT) {
SqlNode expr = scd.expression;
if (expr != null) {
defaultValue = expr.toSqlString(c -> c.withDialect(AnsiSqlDialect.DEFAULT)
defaultValue = expr.toSqlString(c -> c.withDialect(DingoAnsiSqlDialect.DEFAULT)
.withAlwaysUseParentheses(false)
.withSelectListItemsOnSeparateLines(false)
.withUpdateSetListNewline(false)
Expand Down
10 changes: 6 additions & 4 deletions dingo-calcite/src/main/java/io/dingodb/calcite/DingoParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,19 +258,21 @@ public RelRoot convert(@NonNull SqlNode sqlNode) {

public RelRoot convert(@NonNull SqlNode sqlNode, boolean needsValidation) {
HintPredicate hintPredicate = (hint, rel) -> true;
HintStrategyTable hintStrategyTable = new HintStrategyTable.Builder()
HintStrategyTable.Builder hintStrategyBuilder = new HintStrategyTable.Builder()
.hintStrategy("vector_pre", hintPredicate)
.hintStrategy(HybridSearchTable.HINT_NAME, hintPredicate)
.hintStrategy("disable_index", hintPredicate)
.hintStrategy("text_search_pre", hintPredicate)
.build();
.hintStrategy("text_search_pre", hintPredicate);
if (forUpdate(sqlNode)) {
hintStrategyBuilder.hintStrategy("for_update", hintPredicate);
}
SqlToRelConverter sqlToRelConverter = new DingoSqlToRelConverter(
ViewExpanders.simpleContext(cluster),
sqlValidator,
context.getCatalogReader(),
cluster,
sqlNode.getKind() == SqlKind.EXPLAIN,
hintStrategyTable
hintStrategyBuilder.build()
);

RelRoot relRoot = sqlToRelConverter.convertQuery(sqlNode, needsValidation, true);
Expand Down
11 changes: 10 additions & 1 deletion dingo-calcite/src/main/java/io/dingodb/calcite/DingoTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.google.common.collect.ImmutableList;
import io.dingodb.calcite.rel.LogicalDingoTableScan;
import io.dingodb.calcite.rel.LogicalForUpdate;
import io.dingodb.calcite.schema.SubSnapshotSchema;
import io.dingodb.calcite.type.converter.DefinitionMapper;
import io.dingodb.calcite.utils.HybridNodeUtils;
Expand All @@ -37,6 +38,7 @@
import org.apache.calcite.rel.RelNode;
import org.apache.calcite.rel.hint.HintPredicate;
import org.apache.calcite.rel.hint.HintStrategyTable;
import org.apache.calcite.rel.hint.RelHint;
import org.apache.calcite.rel.type.RelDataType;
import org.apache.calcite.rel.type.RelDataTypeFactory;
import org.apache.calcite.runtime.CalciteContextException;
Expand Down Expand Up @@ -116,10 +118,13 @@ public RelDataType getRowType(RelDataTypeFactory typeFactory) {
@Override
public RelNode toRel(RelOptTable.@NonNull ToRelContext context, RelOptTable relOptTable) {
DingoTable dingoTable = relOptTable.unwrap(DingoTable.class);
boolean forUpdate = context.getCluster()
.getHintStrategies()
.validateHint(RelHint.builder("for_update").build());
if (dingoTable.getTable().getTableType() == null
|| (!dingoTable.getTable().getTableType().equalsIgnoreCase("VIEW"))
|| dingoTable.getSchema().getSchemaName().equalsIgnoreCase("INFORMATION_SCHEMA")) {
return new LogicalDingoTableScan(
LogicalDingoTableScan logicalDingoTableScan = new LogicalDingoTableScan(
context.getCluster(),
context.getCluster().traitSet(),
context.getTableHints(),
Expand All @@ -132,6 +137,10 @@ public RelNode toRel(RelOptTable.@NonNull ToRelContext context, RelOptTable relO
((DingoParserContext) context.getCluster().getPlanner().getContext()).isPushDown(),
false
);
if (forUpdate) {
return new LogicalForUpdate(context.getCluster(), context.getCluster().traitSet(), logicalDingoTableScan, relOptTable);
}
return logicalDingoTableScan;
} else {
SqlParser.Config config = SqlParser.config().withParserFactory(DingoSqlParserImpl::new);
SqlParser parser = SqlParser.create(dingoTable.getTable().createSql, config);
Expand Down
Loading

0 comments on commit c0b64fa

Please sign in to comment.