Skip to content

Commit

Permalink
[feat] Support date calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
wt0530 authored and ketor committed Dec 13, 2024
1 parent a0144ff commit 4f418e0
Show file tree
Hide file tree
Showing 185 changed files with 1,285 additions and 441 deletions.
1 change: 1 addition & 0 deletions annotations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies {
compileOnly group: 'com.google.auto.service', name: 'auto-service', version: 'auto-service'.v()
implementation group: 'com.squareup', name: 'javapoet', version: 'javapoet'.v()
implementation group: 'org.apache.commons', name: 'commons-lang3', version: 'commons-lang3'.v()
implementation project(':dingo-expr-common')
}

publishing {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
import com.squareup.javapoet.ParameterizedTypeName;
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import io.dingodb.expr.common.type.IntervalDayType;
import io.dingodb.expr.common.type.IntervalMonthType;
import io.dingodb.expr.common.type.IntervalYearType;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand Down Expand Up @@ -73,7 +76,7 @@ public class OperatorsProcessor extends AbstractProcessor {
private static final String OP_MAP_VAR_NAME = "opMap";
private static final String INSTANCE_VAR_NAME = "INSTANCE";

private static final String TYPES_CLASS_NAME = "io.dingodb.expr.runtime.type.Types";
private static final String TYPES_CLASS_NAME = "io.dingodb.expr.common.type.Types";
private static final String EXPR_CONFIG_CLASS_NAME = "io.dingodb.expr.runtime.ExprConfig";

private static final Pattern NAME_PATTERN = Pattern.compile("^([a-zA-Z]+)\\d*$");
Expand Down Expand Up @@ -159,6 +162,12 @@ private static String getType(@NonNull TypeName typeName) {
return "TIMESTAMP";
} else if (typeName.equals(TypeName.get(Void.class))) {
return "NULL";
} else if (typeName.equals(TypeName.get(IntervalYearType.IntervalYear.class))) {
return "YEAR";
} else if (typeName.equals(TypeName.get(IntervalMonthType.IntervalMonth.class))) {
return "MONTH";
} else if (typeName.equals(TypeName.get(IntervalDayType.IntervalDay.class))) {
return "DAY";
}
return "ANY";
}
Expand Down
1 change: 1 addition & 0 deletions coding/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ gitProperties {

dependencies {
api project(':dingo-expr-rel')
implementation project(':dingo-expr-common')
}

publishing {
Expand Down
4 changes: 2 additions & 2 deletions coding/src/main/java/io/dingodb/expr/coding/ArrayCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package io.dingodb.expr.coding;

import io.dingodb.expr.runtime.type.IntType;
import io.dingodb.expr.runtime.type.TypeVisitorBase;
import io.dingodb.expr.common.type.IntType;
import io.dingodb.expr.common.type.TypeVisitorBase;
import io.dingodb.expr.runtime.utils.CodecUtils;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
Expand Down
2 changes: 1 addition & 1 deletion coding/src/main/java/io/dingodb/expr/coding/ExprCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.dingodb.expr.coding;

import io.dingodb.expr.common.type.Type;
import io.dingodb.expr.runtime.expr.BinaryOpExpr;
import io.dingodb.expr.runtime.expr.Expr;
import io.dingodb.expr.runtime.expr.ExprVisitorBase;
Expand Down Expand Up @@ -44,7 +45,6 @@
import io.dingodb.expr.runtime.op.special.IsFalseFunFactory;
import io.dingodb.expr.runtime.op.special.IsNullFunFactory;
import io.dingodb.expr.runtime.op.special.IsTrueFunFactory;
import io.dingodb.expr.runtime.type.Type;
import io.dingodb.expr.runtime.utils.CodecUtils;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
Expand Down
2 changes: 1 addition & 1 deletion coding/src/main/java/io/dingodb/expr/coding/FunIndex.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.dingodb.expr.coding;

import io.dingodb.expr.common.type.Types;
import io.dingodb.expr.runtime.op.BinaryOp;
import io.dingodb.expr.runtime.op.TertiaryOp;
import io.dingodb.expr.runtime.op.UnaryOp;
Expand Down Expand Up @@ -44,7 +45,6 @@
import io.dingodb.expr.runtime.op.string.Substr3FunFactory;
import io.dingodb.expr.runtime.op.string.Trim1FunFactory;
import io.dingodb.expr.runtime.op.string.UpperFunFactory;
import io.dingodb.expr.runtime.type.Types;
import org.checkerframework.checker.nullness.qual.NonNull;

final class FunIndex {
Expand Down
16 changes: 8 additions & 8 deletions coding/src/main/java/io/dingodb/expr/coding/TypeCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@

package io.dingodb.expr.coding;

import io.dingodb.expr.runtime.type.BoolType;
import io.dingodb.expr.runtime.type.DecimalType;
import io.dingodb.expr.runtime.type.DoubleType;
import io.dingodb.expr.runtime.type.FloatType;
import io.dingodb.expr.runtime.type.IntType;
import io.dingodb.expr.runtime.type.LongType;
import io.dingodb.expr.runtime.type.StringType;
import io.dingodb.expr.runtime.type.TypeVisitorBase;
import io.dingodb.expr.common.type.BoolType;
import io.dingodb.expr.common.type.DecimalType;
import io.dingodb.expr.common.type.DoubleType;
import io.dingodb.expr.common.type.FloatType;
import io.dingodb.expr.common.type.IntType;
import io.dingodb.expr.common.type.LongType;
import io.dingodb.expr.common.type.StringType;
import io.dingodb.expr.common.type.TypeVisitorBase;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
Expand Down
16 changes: 8 additions & 8 deletions coding/src/main/java/io/dingodb/expr/coding/ValCoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package io.dingodb.expr.coding;

import io.dingodb.expr.common.type.ArrayType;
import io.dingodb.expr.common.type.BoolType;
import io.dingodb.expr.common.type.DoubleType;
import io.dingodb.expr.common.type.FloatType;
import io.dingodb.expr.common.type.IntType;
import io.dingodb.expr.common.type.LongType;
import io.dingodb.expr.common.type.StringType;
import io.dingodb.expr.common.type.TypeVisitorBase;
import io.dingodb.expr.runtime.expr.Val;
import io.dingodb.expr.runtime.type.ArrayType;
import io.dingodb.expr.runtime.type.BoolType;
import io.dingodb.expr.runtime.type.DoubleType;
import io.dingodb.expr.runtime.type.FloatType;
import io.dingodb.expr.runtime.type.IntType;
import io.dingodb.expr.runtime.type.LongType;
import io.dingodb.expr.runtime.type.StringType;
import io.dingodb.expr.runtime.type.TypeVisitorBase;
import io.dingodb.expr.runtime.utils.CodecUtils;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.dingodb.expr.coding;

import io.dingodb.expr.common.type.Types;
import io.dingodb.expr.runtime.ExprCompiler;
import io.dingodb.expr.runtime.expr.Expr;
import io.dingodb.expr.runtime.type.Types;
import io.dingodb.expr.runtime.utils.CodecUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.jupiter.api.TestInstance;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@

package io.dingodb.expr.coding;

import io.dingodb.expr.common.type.TupleType;
import io.dingodb.expr.common.type.Types;
import io.dingodb.expr.parser.exception.ExprParseException;
import io.dingodb.expr.rel.RelConfig;
import io.dingodb.expr.rel.RelOp;
import io.dingodb.expr.rel.TupleCompileContextImpl;
import io.dingodb.expr.rel.op.RelOpStringBuilder;
import io.dingodb.expr.runtime.type.TupleType;
import io.dingodb.expr.runtime.type.Types;
import io.dingodb.expr.runtime.utils.CodecUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down
51 changes: 51 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright 2021 DataCanvas
*
* Licensed 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.
*/

plugins {
id 'java-conventions'
id 'java-library'
id 'com.gorylenko.gradle-git-properties' version "${gradleGitPropertiesVersion}"
id 'maven-publish'
}

gitProperties {
keys = gradle.gitPropertiesKeys
}

dependencies {

}

publishing {
publications {
common(MavenPublication) {
artifactId = 'dingo-expr-common'
from components.java
pom {
name = 'dingo-expr-common'
description = 'Relational expression library of Dingo Expression.'
}
gradle.setPom(it)
}
}
repositories {
gradle.setOssrhRepo(it, project)
}
}

signing {
sign publishing.publications.common
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import lombok.AccessLevel;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package io.dingodb.expr.runtime.type;
package io.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2021 DataCanvas
*
* Licensed 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.dingodb.expr.common.type;

import org.checkerframework.checker.nullness.qual.NonNull;

public class IntervalDayTimeType extends IntervalType {

public static final String NAME = "INTERVAL_DAY_TIME";

private static final int CODE = 207;

@Override
public <R, T> R accept(@NonNull TypeVisitor<R, T> visitor, T obj) {
return null;
}

@Override
public int hashCode() {
return CODE * 31;
}

@Override
public boolean equals(Object obj) {
return obj instanceof IntervalDayTimeType;
}

@Override
public String toString() {
return NAME;
}
}
Loading

0 comments on commit 4f418e0

Please sign in to comment.