diff --git a/.idea/misc.xml b/.idea/misc.xml
index cf384b50c..7da9f6957 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,3 +1,4 @@
+
@@ -18,7 +19,7 @@
-
+
\ No newline at end of file
diff --git a/annotations/src/main/java/io/dingodb/expr/annotations/OperatorsProcessor.java b/annotations/src/main/java/io/dingodb/expr/annotations/OperatorsProcessor.java
index 6d47d233d..e743a4bc1 100644
--- a/annotations/src/main/java/io/dingodb/expr/annotations/OperatorsProcessor.java
+++ b/annotations/src/main/java/io/dingodb/expr/annotations/OperatorsProcessor.java
@@ -27,7 +27,11 @@
import com.squareup.javapoet.TypeName;
import com.squareup.javapoet.TypeSpec;
import io.dingodb.expr.common.type.IntervalDayType;
+import io.dingodb.expr.common.type.IntervalHourType;
+import io.dingodb.expr.common.type.IntervalMinuteType;
import io.dingodb.expr.common.type.IntervalMonthType;
+import io.dingodb.expr.common.type.IntervalSecondType;
+import io.dingodb.expr.common.type.IntervalWeekType;
import io.dingodb.expr.common.type.IntervalYearType;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.nullness.qual.NonNull;
@@ -168,6 +172,14 @@ private static String getType(@NonNull TypeName typeName) {
return "MONTH";
} else if (typeName.equals(TypeName.get(IntervalDayType.IntervalDay.class))) {
return "DAY";
+ } else if (typeName.equals(TypeName.get(IntervalWeekType.IntervalWeek.class))) {
+ return "WEEK";
+ } else if (typeName.equals(TypeName.get(IntervalHourType.IntervalHour.class))) {
+ return "HOUR";
+ } else if (typeName.equals(TypeName.get(IntervalMinuteType.IntervalMinute.class))) {
+ return "MINUTE";
+ } else if (typeName.equals(TypeName.get(IntervalSecondType.IntervalSecond.class))) {
+ return "SECOND";
}
return "ANY";
}
diff --git a/buildSrc/src/main/groovy/java-conventions.gradle b/buildSrc/src/main/groovy/java-conventions.gradle
index c7bdf0f69..7f4b14f5e 100644
--- a/buildSrc/src/main/groovy/java-conventions.gradle
+++ b/buildSrc/src/main/groovy/java-conventions.gradle
@@ -22,7 +22,7 @@ plugins {
java {
toolchain {
- languageVersion.set(JavaLanguageVersion.of(8))
+ languageVersion.set(JavaLanguageVersion.of(17))
}
withSourcesJar()
withJavadocJar()
diff --git a/common/src/main/java/io/dingodb/expr/common/type/IntervalHourType.java b/common/src/main/java/io/dingodb/expr/common/type/IntervalHourType.java
index 875e7b1bc..9955a882a 100644
--- a/common/src/main/java/io/dingodb/expr/common/type/IntervalHourType.java
+++ b/common/src/main/java/io/dingodb/expr/common/type/IntervalHourType.java
@@ -16,9 +16,25 @@
package io.dingodb.expr.common.type;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
-public final class IntervalHourType extends ScalarType {
+import java.math.BigDecimal;
+
+public class IntervalHourType extends IntervalType {
+
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class IntervalHour extends IntervalHourType {
+ public BigDecimal value;
+ public Type elementType;
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof IntervalHour;
+ }
+ }
public static final String NAME = "INTERVAL_HOUR";
diff --git a/common/src/main/java/io/dingodb/expr/common/type/IntervalMinuteType.java b/common/src/main/java/io/dingodb/expr/common/type/IntervalMinuteType.java
index b3b23c191..932ffef3f 100644
--- a/common/src/main/java/io/dingodb/expr/common/type/IntervalMinuteType.java
+++ b/common/src/main/java/io/dingodb/expr/common/type/IntervalMinuteType.java
@@ -16,9 +16,26 @@
package io.dingodb.expr.common.type;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
-public final class IntervalMinuteType extends ScalarType {
+import java.math.BigDecimal;
+
+public class IntervalMinuteType extends IntervalType {
+
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class IntervalMinute extends IntervalMinuteType {
+ public BigDecimal value;
+ public Type elementType;
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof IntervalMinute;
+ }
+ }
+
public static final String NAME = "INTERVAL_MINUTE";
private static final int CODE = 205;
diff --git a/common/src/main/java/io/dingodb/expr/common/type/IntervalSecondType.java b/common/src/main/java/io/dingodb/expr/common/type/IntervalSecondType.java
index 46e04a997..829b0d96c 100644
--- a/common/src/main/java/io/dingodb/expr/common/type/IntervalSecondType.java
+++ b/common/src/main/java/io/dingodb/expr/common/type/IntervalSecondType.java
@@ -16,9 +16,25 @@
package io.dingodb.expr.common.type;
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
import org.checkerframework.checker.nullness.qual.NonNull;
-public final class IntervalSecondType extends ScalarType {
+import java.math.BigDecimal;
+
+public class IntervalSecondType extends IntervalType {
+
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class IntervalSecond extends IntervalSecondType {
+ public BigDecimal value;
+ public Type elementType;
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof IntervalSecond;
+ }
+ }
public static final String NAME = "INTERVAL_SECOND";
private static final int CODE = 206;
diff --git a/common/src/main/java/io/dingodb/expr/common/type/IntervalWeekType.java b/common/src/main/java/io/dingodb/expr/common/type/IntervalWeekType.java
new file mode 100644
index 000000000..8bf044bf8
--- /dev/null
+++ b/common/src/main/java/io/dingodb/expr/common/type/IntervalWeekType.java
@@ -0,0 +1,65 @@
+/*
+ * 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 lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import org.checkerframework.checker.nullness.qual.NonNull;
+
+import java.math.BigDecimal;
+
+public class IntervalWeekType extends IntervalType {
+
+ @NoArgsConstructor
+ @AllArgsConstructor
+ public static class IntervalWeek extends IntervalWeekType {
+ public BigDecimal value;
+ public Type elementType;
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof IntervalWeek;
+ }
+ }
+
+ public static final String NAME = "INTERVAL_WEEK";
+ private static final int CODE = 207;
+
+ IntervalWeekType() {
+ super();
+ }
+
+ @Override
+ public R accept(@NonNull TypeVisitor visitor, T obj) {
+ return visitor.visitIntervalWeekType(this, obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return CODE * 31;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof IntervalWeekType;
+ }
+
+ @Override
+ public String toString() {
+ return NAME;
+ }
+}
diff --git a/common/src/main/java/io/dingodb/expr/common/type/TypeVisitor.java b/common/src/main/java/io/dingodb/expr/common/type/TypeVisitor.java
index 8cb158159..a7b795fe3 100644
--- a/common/src/main/java/io/dingodb/expr/common/type/TypeVisitor.java
+++ b/common/src/main/java/io/dingodb/expr/common/type/TypeVisitor.java
@@ -59,6 +59,8 @@ public interface TypeVisitor {
R visitIntervalDayType(@NonNull IntervalDayType type, T obj);
+ R visitIntervalWeekType(@NonNull IntervalWeekType type, T obj);
+
R visitIntervalHourType(@NonNull IntervalHourType type, T obj);
R visitIntervalMinuteType(@NonNull IntervalMinuteType type, T obj);
diff --git a/common/src/main/java/io/dingodb/expr/common/type/TypeVisitorBase.java b/common/src/main/java/io/dingodb/expr/common/type/TypeVisitorBase.java
index 7c4eff0a8..5d5cfcf86 100644
--- a/common/src/main/java/io/dingodb/expr/common/type/TypeVisitorBase.java
+++ b/common/src/main/java/io/dingodb/expr/common/type/TypeVisitorBase.java
@@ -127,6 +127,11 @@ public R visitIntervalDayType(@NonNull IntervalDayType type, T obj) {
return null;
}
+ @Override
+ public R visitIntervalWeekType(@NonNull IntervalWeekType type, T obj) {
+ return null;
+ }
+
@Override
public R visitIntervalHourType(@NonNull IntervalHourType type, T obj) {
return null;
diff --git a/common/src/main/java/io/dingodb/expr/common/type/Types.java b/common/src/main/java/io/dingodb/expr/common/type/Types.java
index 20dc7d642..8f0f22d0f 100644
--- a/common/src/main/java/io/dingodb/expr/common/type/Types.java
+++ b/common/src/main/java/io/dingodb/expr/common/type/Types.java
@@ -50,9 +50,14 @@ public final class Types {
public static final IntervalMonthType.IntervalMonth MONTH = new IntervalMonthType.IntervalMonth();
public static final IntervalDayType INTERVAL_DAY = new IntervalDayType();
public static final IntervalDayType.IntervalDay DAY = new IntervalDayType.IntervalDay();
+ public static final IntervalWeekType INTERVAL_WEEK = new IntervalWeekType();
+ public static final IntervalWeekType.IntervalWeek WEEK = new IntervalWeekType.IntervalWeek();
public static final IntervalHourType INTERVAL_HOUR = new IntervalHourType();
+ public static final IntervalHourType.IntervalHour HOUR = new IntervalHourType.IntervalHour();
public static final IntervalMinuteType INTERVAL_MINUTE = new IntervalMinuteType();
+ public static final IntervalMinuteType.IntervalMinute MINUTE = new IntervalMinuteType.IntervalMinute();
public static final IntervalSecondType INTERVAL_SECOND = new IntervalSecondType();
+ public static final IntervalSecondType.IntervalSecond SECOND = new IntervalSecondType.IntervalSecond();
public static final IntervalDayTimeType INTERVAL_DAY_TIME = new IntervalDayTimeType();
public static final ArrayType ARRAY_INT = new ArrayType(INT);
diff --git a/console/build.gradle b/console/build.gradle
index 1a96e18ee..c179adc5d 100644
--- a/console/build.gradle
+++ b/console/build.gradle
@@ -20,7 +20,7 @@ plugins {
}
application {
- mainClass = 'io.dingodb.expr.console.DingoExprConsole'
+ getMainClass().set('io.dingodb.expr.console.DingoExprConsole')
}
dependencies {
diff --git a/gradle.properties b/gradle.properties
index 348123473..303e5d1b0 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -32,14 +32,14 @@ VERSION=2.0.0-SNAPSHOT
jackson.version=2.13.4
# facilities
-lombok.version=1.18.16
+lombok.version=1.18.30
javapoet.version=1.13.0
mapstruct.version=1.5.5.Final
antlr.version=4.9.3
# google
auto-service.version=1.0
-guava.version=31.1-jre
+guava.version=33.4.0-jre
# apache commons
commons-lang.version=2.6
@@ -64,7 +64,7 @@ logback.version=1.2.3
checkerframework.version=3.12.0
checkstyle.version=8.30
-gradleGitPropertiesVersion=2.4.1
+gradleGitPropertiesVersion=2.4.2
#
# For release script. These are not the real credentials.
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index e708b1c02..7454180f2 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 28ff446a2..e750102e0 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
index 4f906e0c8..1b6c78733 100755
--- a/gradlew
+++ b/gradlew
@@ -1,7 +1,7 @@
-#!/usr/bin/env sh
+#!/bin/sh
#
-# Copyright 2015 the original author or authors.
+# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -17,67 +17,101 @@
#
##############################################################################
-##
-## Gradle start up script for UN*X
-##
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
##############################################################################
# Attempt to set APP_HOME
+
# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=${0##*/}
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
+MAX_FD=maximum
warn () {
echo "$*"
-}
+} >&2
die () {
echo
echo "$*"
echo
exit 1
-}
+} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -87,9 +121,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
+ JAVACMD=$JAVA_HOME/jre/sh/java
else
- JAVACMD="$JAVA_HOME/bin/java"
+ JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -98,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
- JAVACMD="java"
+ JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
@@ -106,80 +140,95 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
fi
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
-if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
fi
- i=`expr $i + 1`
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
done
- case $i in
- 0) set -- ;;
- 1) set -- "$args0" ;;
- 2) set -- "$args0" "$args1" ;;
- 3) set -- "$args0" "$args1" "$args2" ;;
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
-}
-APP_ARGS=`save "$@"`
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
exec "$JAVACMD" "$@"
diff --git a/jni/src/main/java/io/dingodb/expr/jni/LibExprJni.java b/jni/src/main/java/io/dingodb/expr/jni/LibExprJni.java
index 479e4df4d..99e461930 100644
--- a/jni/src/main/java/io/dingodb/expr/jni/LibExprJni.java
+++ b/jni/src/main/java/io/dingodb/expr/jni/LibExprJni.java
@@ -16,11 +16,21 @@
package io.dingodb.expr.jni;
+import java.nio.file.Paths;
+
public class LibExprJni {
public static final LibExprJni INSTANCE = new LibExprJni();
private LibExprJni() {
- System.loadLibrary("expr_jni");
+ String name = System.getProperty("os.name").toLowerCase();
+ String path = Paths.get("").toAbsolutePath().getParent().toString();
+ if (name.indexOf("win") >= 0) {
+ System.load(path + "/jni/src/main/cpp/build/libexpr_jni.dll");
+ } else if (name.indexOf("mac") >= 0) {
+ System.load(path + "/jni/src/main/cpp/build/libexpr_jni.dylib");
+ } else {
+ System.load(path + "/jni/src/main/cpp/build/libexpr_jni.so");
+ }
}
public native Object decode(final byte[] exprBytes);
diff --git a/json/src/main/java/io/dingodb/expr/json/runtime/Parser.java b/json/src/main/java/io/dingodb/expr/json/runtime/Parser.java
index 6b7e8621c..ca9e037b1 100644
--- a/json/src/main/java/io/dingodb/expr/json/runtime/Parser.java
+++ b/json/src/main/java/io/dingodb/expr/json/runtime/Parser.java
@@ -16,6 +16,8 @@
package io.dingodb.expr.json.runtime;
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
@@ -55,6 +57,8 @@ protected Parser(@NonNull DataFormat format) {
mapper = setJsonFeature(JsonMapper.builder())
.addModule(new AfterburnerModule())
.build();
+ mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
+ mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
break;
case APPLICATION_YAML:
YAMLFactory yamlFactory = new YAMLFactory()
@@ -62,9 +66,13 @@ protected Parser(@NonNull DataFormat format) {
mapper = setJsonFeature(JsonMapper.builder(yamlFactory))
.addModule(new AfterburnerModule())
.build();
+ mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
+ mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
break;
case TEXT_CSV:
mapper = setCsvFeature(new CsvMapper());
+ mapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
+ mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
break;
default:
throw new IllegalArgumentException("Invalid DataFormat value \"" + format
diff --git a/rel/src/main/java/io/dingodb/expr/rel/op/CsvValuesOp.java b/rel/src/main/java/io/dingodb/expr/rel/op/CsvValuesOp.java
index d87df3171..00ddaf3d8 100644
--- a/rel/src/main/java/io/dingodb/expr/rel/op/CsvValuesOp.java
+++ b/rel/src/main/java/io/dingodb/expr/rel/op/CsvValuesOp.java
@@ -31,6 +31,7 @@
import io.dingodb.expr.common.type.IntervalMinuteType;
import io.dingodb.expr.common.type.IntervalMonthType;
import io.dingodb.expr.common.type.IntervalSecondType;
+import io.dingodb.expr.common.type.IntervalWeekType;
import io.dingodb.expr.common.type.IntervalYearType;
import io.dingodb.expr.common.type.ListType;
import io.dingodb.expr.common.type.LongType;
@@ -218,6 +219,11 @@ public Object visitIntervalDayType(@NonNull IntervalDayType type, @NonNull Objec
return obj;
}
+ @Override
+ public Object visitIntervalWeekType(@NonNull IntervalWeekType type, @NonNull Object obj) {
+ return obj;
+ }
+
@Override
public Object visitIntervalHourType(@NonNull IntervalHourType type, @NonNull Object obj) {
return obj;
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/compiler/CastingFactory.java b/runtime/src/main/java/io/dingodb/expr/runtime/compiler/CastingFactory.java
index da5bef8c8..4df6274dc 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/compiler/CastingFactory.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/compiler/CastingFactory.java
@@ -29,6 +29,7 @@
import io.dingodb.expr.common.type.IntervalMinuteType;
import io.dingodb.expr.common.type.IntervalMonthType;
import io.dingodb.expr.common.type.IntervalSecondType;
+import io.dingodb.expr.common.type.IntervalWeekType;
import io.dingodb.expr.common.type.IntervalYearType;
import io.dingodb.expr.common.type.ListType;
import io.dingodb.expr.common.type.LongType;
@@ -143,6 +144,11 @@ public UnaryOp visitIntervalDayType(@NonNull IntervalDayType type, ExprConfig ob
return Exprs.TO_STRING;
}
+ @Override
+ public UnaryOp visitIntervalWeekType(@NonNull IntervalWeekType type, ExprConfig obj) {
+ return Exprs.TO_STRING;
+ }
+
@Override
public UnaryOp visitIntervalHourType(@NonNull IntervalHourType type, ExprConfig obj) {
return Exprs.TO_STRING;
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/op/OpKeys.java b/runtime/src/main/java/io/dingodb/expr/runtime/op/OpKeys.java
index 21d382fea..54d5c1942 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/op/OpKeys.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/op/OpKeys.java
@@ -60,6 +60,8 @@ public static final class DefaultOpKeys {
return type0;
} else if (type0.equals(Types.NULL)) {
return type1;
+ } else if (!type0.matches(type1)) {
+ return Types.ANY;
}
return null;
}
@@ -149,20 +151,31 @@ public static final class BinaryOpKeys {
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public static final class BinaryOtherOpKeys {
- private static final List types = Arrays.asList(
+ private static final List types0 = Arrays.asList(
+ Types.DATE,
+ Types.TIME,
+ Types.TIMESTAMP);
+
+ private static final List types1 = Arrays.asList(
Types.INTERVAL_YEAR,
Types.YEAR,
Types.INTERVAL_MONTH,
Types.MONTH,
Types.INTERVAL_DAY,
Types.DAY,
+ Types.INTERVAL_WEEK,
+ Types.WEEK,
Types.INTERVAL_DAY_TIME,
Types.INTERVAL_HOUR,
+ Types.HOUR,
Types.INTERVAL_MINUTE,
- Types.INTERVAL_SECOND);
+ Types.MINUTE,
+ Types.INTERVAL_SECOND,
+ Types.SECOND);
public @Nullable OpKey keyOf(Type type0, Type type1) {
- return types.stream().anyMatch(type1::matches) ? type1 : null;
+ return types0.stream().anyMatch(type0::matches)
+ ? (types1.stream().anyMatch(type1::matches) ? Types.tuple(type0, type1) : null) : null;
}
}
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/op/collection/ArrayBuilder.java b/runtime/src/main/java/io/dingodb/expr/runtime/op/collection/ArrayBuilder.java
index 6ed7b1564..4ba7e2a32 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/op/collection/ArrayBuilder.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/op/collection/ArrayBuilder.java
@@ -30,6 +30,7 @@
import io.dingodb.expr.common.type.IntervalMinuteType;
import io.dingodb.expr.common.type.IntervalMonthType;
import io.dingodb.expr.common.type.IntervalSecondType;
+import io.dingodb.expr.common.type.IntervalWeekType;
import io.dingodb.expr.common.type.IntervalYearType;
import io.dingodb.expr.common.type.ListType;
import io.dingodb.expr.common.type.LongType;
@@ -149,6 +150,11 @@ public Object visitIntervalDayType(@NonNull IntervalDayType type, @NonNull Integ
return new Object[obj];
}
+ @Override
+ public Object visitIntervalWeekType(@NonNull IntervalWeekType type, @NonNull Integer obj) {
+ return new Object[obj];
+ }
+
@Override
public Object visitIntervalHourType(@NonNull IntervalHourType type, @NonNull Integer obj) {
return new Object[obj];
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/op/date/MinuteFun.java b/runtime/src/main/java/io/dingodb/expr/runtime/op/date/MinuteFun.java
index 869104224..28c18b9b5 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/op/date/MinuteFun.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/op/date/MinuteFun.java
@@ -40,7 +40,7 @@ static int extractMinute(@NonNull Time value, ExprConfig config) {
}
static int extractMinute(@NonNull Timestamp value, ExprConfig config) {
- return DateTimeUtils.extractHour(value);
+ return DateTimeUtils.extractMinute(value);
}
@Override
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/op/date/WeekFun.java b/runtime/src/main/java/io/dingodb/expr/runtime/op/date/WeekFun.java
index 2c932a9bf..8d9a3175b 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/op/date/WeekFun.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/op/date/WeekFun.java
@@ -23,6 +23,7 @@
import org.checkerframework.checker.nullness.qual.NonNull;
import java.sql.Date;
+import java.sql.Timestamp;
@Operators
abstract class WeekFun extends UnaryOp {
@@ -34,6 +35,10 @@ static int extractWeek(@NonNull Date value, @NonNull ExprConfig config) {
return DateTimeUtils.extractWeek(value);
}
+ static int extractWeek(@NonNull Timestamp value0, @NonNull ExprConfig config) {
+ return DateTimeUtils.extractWeek(value0);
+ }
+
@Override
public @NonNull String getName() {
return NAME;
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/AddOp.java b/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/AddOp.java
index 1fd5edb35..423eab917 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/AddOp.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/AddOp.java
@@ -19,14 +19,22 @@
import io.dingodb.expr.annotations.Operators;
import io.dingodb.expr.common.type.IntervalDayTimeType;
import io.dingodb.expr.common.type.IntervalDayType;
+import io.dingodb.expr.common.type.IntervalHourType;
+import io.dingodb.expr.common.type.IntervalMinuteType;
import io.dingodb.expr.common.type.IntervalMonthType;
+import io.dingodb.expr.common.type.IntervalSecondType;
+import io.dingodb.expr.common.type.IntervalWeekType;
import io.dingodb.expr.common.type.IntervalYearType;
import io.dingodb.expr.runtime.op.BinaryIntervalOp;
import io.dingodb.expr.runtime.op.OpType;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.sql.Date;
+import java.sql.Timestamp;
+import java.time.Duration;
import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.temporal.ChronoUnit;
@Operators
public class AddOp extends BinaryIntervalOp {
@@ -44,24 +52,113 @@ static Date add(Date value0, IntervalYearType.IntervalYear value1) {
return Date.valueOf(resultDate);
}
- static Date sub(Date value0, IntervalMonthType.IntervalMonth value1) {
+ static Date add(Date value0, IntervalMonthType.IntervalMonth value1) {
LocalDate localDate = value0.toLocalDate();
LocalDate resultDate = localDate.plusMonths(value1.value.intValue());
return Date.valueOf(resultDate);
}
- static Date sub(Date value0, IntervalDayType.IntervalDay value1) {
+ static Date add(Date value0, IntervalDayType.IntervalDay value1) {
LocalDate localDate = value0.toLocalDate();
- long daysToSubtract;
+ long daysToAdd;
if (value1.elementType instanceof IntervalDayTimeType) {
- daysToSubtract = value1.value.longValue() / (24 * 60 * 60 * 1000);
+ daysToAdd = value1.value.longValue() / (24 * 60 * 60 * 1000);
} else {
- daysToSubtract = value1.value.longValue();
+ daysToAdd = value1.value.longValue();
}
- LocalDate resultDate = localDate.plusDays(daysToSubtract);
+ LocalDate resultDate = localDate.plusDays(daysToAdd);
return Date.valueOf(resultDate);
}
+ static Date add(Date value0, IntervalWeekType.IntervalWeek value1) {
+ LocalDate localDate = value0.toLocalDate();
+ long week;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ week = value1.value.longValue() / (60 * 60 * 1000);
+ } else {
+ week = value1.value.longValue();
+ }
+ LocalDate resultDate = localDate.plusWeeks(week);
+ return Date.valueOf(resultDate);
+ }
+
+ static Timestamp add(Timestamp value0, IntervalYearType.IntervalYear value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ LocalDateTime resultDateTime;
+ if (value1.elementType instanceof IntervalMonthType) {
+ resultDateTime = localDateTime.plusMonths(value1.value.longValue());
+ } else {
+ resultDateTime = localDateTime.plusYears(value1.value.longValue());
+ }
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp add(Timestamp value0, IntervalMonthType.IntervalMonth value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ LocalDateTime resultDateTime = localDateTime.plusMonths(value1.value.longValue());
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp add(Timestamp value0, IntervalDayType.IntervalDay value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long daysToAdd;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ daysToAdd = value1.value.longValue() / (24 * 60 * 60 * 1000);
+ } else {
+ daysToAdd = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.plusDays(daysToAdd);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp add(Timestamp value0, IntervalWeekType.IntervalWeek value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long week;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ week = value1.value.longValue() / (60 * 60 * 1000);
+ } else {
+ week = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.plusWeeks(week);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp add(Timestamp value0, IntervalHourType.IntervalHour value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long hours;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ hours = value1.value.longValue() / (60 * 60 * 1000);
+ } else {
+ hours = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.plusHours(hours);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp add(Timestamp value0, IntervalMinuteType.IntervalMinute value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long minute;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ minute = value1.value.longValue() / (60 * 1000);
+ } else {
+ minute = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.plusMinutes(minute);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp add(Timestamp value0, IntervalSecondType.IntervalSecond value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long second;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ second = value1.value.longValue() / 1000;
+ } else {
+ second = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.plusSeconds(second);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
@Override
public @NonNull OpType getOpType() {
return OpType.ADD;
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/SubOp.java b/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/SubOp.java
index 3b7466d1f..f162b366a 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/SubOp.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/op/interval/SubOp.java
@@ -19,14 +19,20 @@
import io.dingodb.expr.annotations.Operators;
import io.dingodb.expr.common.type.IntervalDayTimeType;
import io.dingodb.expr.common.type.IntervalDayType;
+import io.dingodb.expr.common.type.IntervalHourType;
+import io.dingodb.expr.common.type.IntervalMinuteType;
import io.dingodb.expr.common.type.IntervalMonthType;
+import io.dingodb.expr.common.type.IntervalSecondType;
+import io.dingodb.expr.common.type.IntervalWeekType;
import io.dingodb.expr.common.type.IntervalYearType;
import io.dingodb.expr.runtime.op.BinaryIntervalOp;
import io.dingodb.expr.runtime.op.OpType;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.sql.Date;
+import java.sql.Timestamp;
import java.time.LocalDate;
+import java.time.LocalDateTime;
@Operators
public abstract class SubOp extends BinaryIntervalOp {
@@ -62,6 +68,95 @@ static Date sub(Date value0, IntervalDayType.IntervalDay value1) {
return Date.valueOf(resultDate);
}
+ static Date sub(Date value0, IntervalWeekType.IntervalWeek value1) {
+ LocalDate localDate = value0.toLocalDate();
+ long week;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ week = value1.value.longValue() / (60 * 60 * 1000);
+ } else {
+ week = value1.value.longValue();
+ }
+ LocalDate resultDate = localDate.minusWeeks(week);
+ return Date.valueOf(resultDate);
+ }
+
+ static Timestamp sub(Timestamp value0, IntervalYearType.IntervalYear value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ LocalDateTime resultDateTime;
+ if (value1.elementType instanceof IntervalMonthType) {
+ resultDateTime = localDateTime.minusMonths(value1.value.longValue());
+ } else {
+ resultDateTime = localDateTime.minusYears(value1.value.longValue());
+ }
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp sub(Timestamp value0, IntervalMonthType.IntervalMonth value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ LocalDateTime resultDateTime = localDateTime.minusMonths(value1.value.longValue());
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp sub(Timestamp value0, IntervalDayType.IntervalDay value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long daysToSubtract;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ daysToSubtract = value1.value.longValue() / (24 * 60 * 60 * 1000);
+ } else {
+ daysToSubtract = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.minusDays(daysToSubtract);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp sub(Timestamp value0, IntervalWeekType.IntervalWeek value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long week;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ week = value1.value.longValue() / (60 * 60 * 1000);
+ } else {
+ week = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.minusWeeks(week);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp sub(Timestamp value0, IntervalHourType.IntervalHour value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long hours;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ hours = value1.value.longValue() / (60 * 60 * 1000);
+ } else {
+ hours = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.minusHours(hours);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp sub(Timestamp value0, IntervalMinuteType.IntervalMinute value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long minute;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ minute = value1.value.longValue() / (60 * 1000);
+ } else {
+ minute = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.minusMinutes(minute);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
+ static Timestamp sub(Timestamp value0, IntervalSecondType.IntervalSecond value1) {
+ LocalDateTime localDateTime = value0.toLocalDateTime();
+ long second;
+ if (value1.elementType instanceof IntervalDayTimeType) {
+ second = value1.value.longValue() / 1000;
+ } else {
+ second = value1.value.longValue();
+ }
+ LocalDateTime resultDateTime = localDateTime.minusSeconds(second);
+ return Timestamp.valueOf(resultDateTime);
+ }
+
@Override
public @NonNull OpType getOpType() {
return OpType.SUB;
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/op/special/IfNullFun.java b/runtime/src/main/java/io/dingodb/expr/runtime/op/special/IfNullFun.java
index b37b25f2b..4823374dd 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/op/special/IfNullFun.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/op/special/IfNullFun.java
@@ -19,6 +19,7 @@
import io.dingodb.expr.annotations.Operators;
import io.dingodb.expr.runtime.op.BinarySpecialOp;
import org.checkerframework.checker.nullness.qual.NonNull;
+import org.checkerframework.checker.nullness.qual.Nullable;
import java.math.BigDecimal;
import java.sql.Date;
@@ -74,6 +75,14 @@ static Timestamp ifNull(Timestamp value0, Timestamp value1) {
return value0 == null ? value1 : value0;
}
+ static Object ifNull(Object value0, Object value1) {
+ return value0 == null ? value1 : value0;
+ }
+
+ static @Nullable Object ifNull(Void value0, Void value1) {
+ return null;
+ }
+
@Override
public @NonNull String getName() {
return NAME;
diff --git a/runtime/src/main/java/io/dingodb/expr/runtime/utils/DateTimeUtils.java b/runtime/src/main/java/io/dingodb/expr/runtime/utils/DateTimeUtils.java
index 2983e4f46..7a3d7f72a 100644
--- a/runtime/src/main/java/io/dingodb/expr/runtime/utils/DateTimeUtils.java
+++ b/runtime/src/main/java/io/dingodb/expr/runtime/utils/DateTimeUtils.java
@@ -32,6 +32,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
@@ -39,6 +40,7 @@
import java.time.format.DateTimeParseException;
import java.time.format.ResolverStyle;
import java.time.format.SignStyle;
+import java.time.temporal.IsoFields;
import java.util.Arrays;
import java.util.TimeZone;
@@ -337,7 +339,7 @@ public static int extractDay(Object value) {
public static int extractWeek(Object value) {
LocalDateTime localDateTime = toLocalDateTime(value);
- return localDateTime.getDayOfWeek().getValue();
+ return localDateTime.get(IsoFields.WEEK_OF_WEEK_BASED_YEAR);
}
public static int extractHour(Object value) {
diff --git a/test/src/main/java/io/dingodb/expr/test/LibExprJniUtils.java b/test/src/main/java/io/dingodb/expr/test/LibExprJniUtils.java
index a405d3ce9..6831102b2 100644
--- a/test/src/main/java/io/dingodb/expr/test/LibExprJniUtils.java
+++ b/test/src/main/java/io/dingodb/expr/test/LibExprJniUtils.java
@@ -25,7 +25,8 @@ private LibExprJniUtils() {
}
public static void setLibPath() {
- System.setProperty("java.library.path", System.getProperty("java.library.path") + ":" + LIB_PATH);
+ String property = System.getProperty("user.home");
+ /*System.setProperty("java.library.path", System.getProperty("java.library.path") + ":" + LIB_PATH);
try {
// Refresh lib path.
Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
@@ -33,6 +34,6 @@ public static void setLibPath() {
fieldSysPath.set(null, null);
} catch (NoSuchFieldException | IllegalAccessException e) {
throw new RuntimeException(e);
- }
+ }*/
}
}