[feature-wip] (datev2) modify datev2 format in memory (#10873)

* [feature-wip] (datev2) modify datev2 format in memory

* update
This commit is contained in:
Gabriel
2022-07-15 19:57:38 +08:00
committed by GitHub
parent 401203da6a
commit dc6fbcce14
13 changed files with 40 additions and 53 deletions

View File

@ -383,7 +383,7 @@ public class DateLiteral extends LiteralExpr {
} else if (type.equals(Type.DATETIME)) {
return (year * 10000 + month * 100 + day) * 1000000L + hour * 10000 + minute * 100 + second;
} else if (type.equals(Type.DATEV2)) {
return (year << 16) | (month << 8) | day;
return (year << 9) | (month << 5) | day;
} else if (type.equals(Type.DATETIMEV2)) {
return (year << 50) | (month << 46) | (day << 41) | (hour << 36)
| (minute << 30) | (second << 24) | microsecond;

View File

@ -87,6 +87,7 @@ public enum PrimitiveType {
builder.add(DECIMAL32);
builder.add(DECIMAL64);
builder.add(DECIMAL128);
builder.add(DATETIMEV2);
typeWithPrecision = builder.build();
}

View File

@ -721,6 +721,9 @@ public class ScalarType extends Type {
if (isDecimalV3() && scalarType.isDecimalV3()) {
return precision == scalarType.precision && scale == scalarType.scale;
}
if (isDatetimeV2() && scalarType.isDatetimeV2()) {
return true;
}
return false;
}

View File

@ -56,7 +56,6 @@ import com.google.common.collect.Maps;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import java.io.File;
@ -962,8 +961,6 @@ public class AlterTest {
alterTable(changeOrderStmt, true);
}
// Open it when date v2 is ready
@Ignore
@Test
public void testAlterDateV2Schema() throws Exception {
createTable("CREATE TABLE test.unique_partition_datev2\n" + "(\n" + " k1 date,\n" + " k2 datetime(3),\n"