Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,11 @@ private int getMysqlTypeLength(Type type) {
case DATEV2:
case DATE:
return 10;
case TIMESTAMPTZ:
// yyyy-MM-dd HH:mm:ss[.ffffff]+HH:mm
return 32;
case DATETIME:
case DATETIMEV2:
case TIMESTAMPTZ: {
case DATETIMEV2: {
if (type.getPrimitiveType().isTimeType()) {
return 10;
} else {
Expand Down Expand Up @@ -338,7 +340,6 @@ public int getMysqlDecimals(Type type) {
case DECIMAL256:
case TIMEV2:
case DATETIMEV2:
case TIMESTAMPTZ:
return ((ScalarType) type).decimalScale();
case FLOAT:
case DOUBLE:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1870,7 +1870,6 @@ protected void sendBinaryResultRow(ResultSet resultSet) throws IOException {
break;
case DATETIME:
case DATETIMEV2:
case TIMESTAMPTZ:
DateTimeV2Literal datetime = new DateTimeV2Literal(item);
long microSecond = datetime.getMicroSecond();
// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query_response_text_resultset.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.apache.doris.mysql;

import org.apache.doris.catalog.MysqlColType;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.catalog.Type;

Expand Down Expand Up @@ -118,6 +119,35 @@ public void testFieldPacketForVarcharUsesUtf8Collation() {
Assertions.assertEquals(0, flags); // not BINARY
}

@Test
public void testFieldPacketForTimestampTzUsesStringMetadata() {
MysqlSerializer ser = MysqlSerializer.newInstance();
Type type = ScalarType.createTimeStampTzType(6);
ser.writeField("ts", type);
byte[] out = ser.toArray();

Assertions.assertEquals(MysqlColType.MYSQL_TYPE_STRING, type.getPrimitiveType().toMysqlType());

int off = skipFieldHeaderStrings(out);
int charset = leUInt2(out, off);
Assertions.assertEquals(33, charset); // utf8_general_ci
off += 2;

long displayLen = leUInt4(out, off);
Assertions.assertEquals(32L, displayLen);
off += 4;

int colType = out[off] & 0xFF;
Assertions.assertEquals(MysqlColType.MYSQL_TYPE_STRING.getCode(), colType);
off += 1;

int flags = leUInt2(out, off);
Assertions.assertEquals(0, flags);
off += 2;

Assertions.assertEquals(0, out[off] & 0xFF);
}

@Test
public void testWriteLenEncodedBytesPreservesNullByte() {
MysqlSerializer ser = MysqlSerializer.newInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,10 @@ public MysqlColType toMysqlType() {
case DATE:
case DATEV2:
return MysqlColType.MYSQL_TYPE_DATE;
case TIMESTAMPTZ:
return MysqlColType.MYSQL_TYPE_STRING;
case DATETIME:
case DATETIMEV2:
case TIMESTAMPTZ: {
case DATETIMEV2: {
if (isTimeType) {
return MysqlColType.MYSQL_TYPE_TIME;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
\N \N \N \N \N \N \N \N

-- !sql --
2020-01-01T00:00:00.000000124
2020-01-01 00:00:00.124+07:00

-- !sql --
2020-01-01T04:00:00.124
Expand All @@ -33,7 +33,7 @@
2020-01-01T04:00 2020-06-01T16:34:56 2021-01-01T03:59:59 2020-01-01T10:00 2020-06-01T22:34:56 2021-01-01T09:59:59 2020-01-01T07:00 2020-06-01T19:34:56 2021-01-01T06:59:59

-- !sql --
2020-01-01T00:00:00.000000124
2020-01-01 00:00:00.124+07:00

-- !sql --
2020-01-01T04:00:00.124
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
2020-01-02 00:00:00.00000+08:00

-- !cast_1 --
1 2020-01-01T05:00:00.000000123 2020-01-01 05:00:00.12300+08:00
2 2020-06-01T15:00:00.000000456 2020-06-01 15:00:00.45600+08:00
3 2020-01-01T07:59:59.000000789 2020-01-01 07:59:59.78900+08:00
1 2020-01-01 05:00:00.123+08:00 2020-01-01 05:00:00.12300+08:00
2 2020-06-01 15:00:00.456+08:00 2020-06-01 15:00:00.45600+08:00
3 2020-01-01 07:59:59.789+08:00 2020-01-01 07:59:59.78900+08:00

-- !cast_2 --
1 2020-01-01 05:00:00.12345+08:00 2020-01-01T05:00:00.000000123
2 2020-06-01 15:00:00.45678+08:00 2020-06-01T15:00:00.000000457
3 2020-01-01 07:59:59.78901+08:00 2020-01-01T07:59:59.000000789
1 2020-01-01 05:00:00.12345+08:00 2020-01-01 05:00:00.123+08:00
2 2020-06-01 15:00:00.45678+08:00 2020-06-01 15:00:00.457+08:00
3 2020-01-01 07:59:59.78901+08:00 2020-01-01 07:59:59.789+08:00

Original file line number Diff line number Diff line change
Expand Up @@ -681,13 +681,13 @@ gdaskpdp
2023-01-02 08:00:00+08:00

-- !hours_add_8 --
2024-03-01T13:30:45.000000123
2024-03-01 13:30:45.123+08:00

-- !hours_add_9 --
0001-01-03 08:00:00+08:00

-- !hours_add_10 --
2023-06-15T08:45:30.000000555
2023-06-15 08:45:30.555+08:00

-- !hours_add_11 --
\N
Expand Down Expand Up @@ -735,13 +735,13 @@ gdaskpdp
2022-12-31 08:00:00+08:00

-- !hours_sub_8 --
2024-02-29T13:30:45.000000123
2024-02-29 13:30:45.123+08:00

-- !hours_sub_9 --
0000-12-30 08:00:00+08:00

-- !hours_sub_10 --
2023-06-15T20:45:30.000000555
2023-06-15 20:45:30.555+08:00

-- !hours_sub_11 --
\N
Expand Down Expand Up @@ -1113,13 +1113,13 @@ gdaskpdp
2023-01-01 09:00:00+08:00

-- !minutes_add_9 --
2024-03-01T02:19:56.000000123
2024-03-01 02:19:56.123+08:00

-- !minutes_add_10 --
0001-01-01 08:01:00+08:00

-- !minutes_add_11 --
2023-06-15T14:15:30.000000555
2023-06-15 14:15:30.555+08:00

-- !minutes_add_12 --
\N
Expand Down Expand Up @@ -1167,13 +1167,13 @@ gdaskpdp
2023-01-01 07:00:00+08:00

-- !minutes_sub_8 --
2024-03-01T00:49:56.000000123
2024-03-01 00:49:56.123+08:00

-- !minutes_sub_9 --
0001-01-01 07:59:00+08:00

-- !minutes_sub_10 --
2023-06-15T15:15:30.000000555
2023-06-15 15:15:30.555+08:00

-- !minutes_sub_11 --
\N
Expand Down Expand Up @@ -1647,13 +1647,13 @@ da fanadur
2023-07-01 08:00:00+08:00

-- !quarters_add_10 --
2024-05-30T01:30:45.000000123
2024-05-30 01:30:45.123+08:00

-- !quarters_add_11 --
0002-01-01 08:00:00+08:00

-- !quarters_add_12 --
2022-12-15T14:45:30.000000555
2022-12-15 14:45:30.555+08:00

-- !quarters_add_13 --
\N
Expand Down Expand Up @@ -1686,13 +1686,13 @@ da fanadur
2022-07-01 08:00:00+08:00

-- !quarters_sub_10 --
2023-11-30T01:30:45.000000123
2023-11-30 01:30:45.123+08:00

-- !quarters_sub_11 --
0000-01-01 08:00:00+08:00

-- !quarters_sub_12 --
2023-12-15T14:45:30.000000555
2023-12-15 14:45:30.555+08:00

-- !quarters_sub_13 --
\N
Expand Down Expand Up @@ -1776,13 +1776,13 @@ da fanadur
2023-01-01 09:00:00+08:00

-- !seconds_add_9 --
2024-03-01T01:35:11.000000123
2024-03-01 01:35:11.123+08:00

-- !seconds_add_10 --
0001-01-01 08:01:00+08:00

-- !seconds_add_11 --
2023-06-15T14:45:00.000000555
2023-06-15 14:45:00.555+08:00

-- !seconds_add_12 --
\N
Expand Down Expand Up @@ -1830,13 +1830,13 @@ da fanadur
2023-01-01 07:00:00+08:00

-- !seconds_sub_9 --
2024-03-01T01:34:41.000000123
2024-03-01 01:34:41.123+08:00

-- !seconds_sub_10 --
0001-01-01 07:59:00+08:00

-- !seconds_sub_11 --
2023-06-15T14:46:00.000000555
2023-06-15 14:46:00.555+08:00

-- !seconds_sub_12 --
\N
Expand Down Expand Up @@ -2232,13 +2232,13 @@ da fanadur
2023-01-15 08:00:00+08:00

-- !weeks_add_8 --
2024-03-08T01:30:45.000000123
2024-03-08 01:30:45.123+08:00

-- !weeks_add_9 --
0001-01-29 08:00:00+08:00

-- !weeks_add_10 --
2023-06-01T14:45:30.000000555
2023-06-01 14:45:30.555+08:00

-- !weeks_add_11 --
\N
Expand Down Expand Up @@ -2292,13 +2292,13 @@ da fanadur
2022-12-18 08:00:00+08:00

-- !weeks_sub_8 --
2024-02-23T01:30:45.000000123
2024-02-23 01:30:45.123+08:00

-- !weeks_sub_9 --
0000-12-04 08:00:00+08:00

-- !weeks_sub_10 --
2023-06-29T14:45:30.000000555
2023-06-29 14:45:30.555+08:00

-- !weeks_sub_11 --
\N
Expand Down Expand Up @@ -2418,13 +2418,13 @@ da fanadur
2025-01-01 08:00:00+08:00

-- !years_add_9 --
2025-03-01T01:30:45.000000123
2025-03-01 01:30:45.123+08:00

-- !years_add_10 --
0011-01-01 08:00:00+08:00

-- !years_add_11 --
2020-06-15T14:45:30.000000555
2020-06-15 14:45:30.555+08:00

-- !years_add_12 --
\N
Expand Down Expand Up @@ -2472,13 +2472,13 @@ da fanadur
2021-01-01 08:00:00+08:00

-- !years_sub_8 --
2023-03-01T01:30:45.000000123
2023-03-01 01:30:45.123+08:00

-- !years_sub_9 --
9989-01-01 08:00:00+08:00

-- !years_sub_10 --
2026-06-15T14:45:30.000000555
2026-06-15 14:45:30.555+08:00

-- !years_sub_11 --
0003-01-01 08:00:00+08:00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ id int Yes true \N
ts_ltz timestamptz(3) Yes true \N WITH_TIMEZONE

-- !jni_1 --
1 2024-01-01T10:00
2 2026-01-06T16:13:12
3 2024-11-11T11:11:11.000000123
1 2024-01-01 10:00:00.000+08:00
2 2026-01-06 16:13:12.000+08:00
3 2024-11-11 11:11:11.123+08:00

-- !jni_1_cast --
1 2024-01-01 10:00:00.000+08:00
Expand All @@ -18,9 +18,9 @@ id int Yes true \N
ts_ltz timestamptz(3) Yes true \N WITH_TIMEZONE

-- !native_1 --
1 2024-01-01T10:00
2 2026-01-06T16:13:12
3 2024-11-11T11:11:11.000000123
1 2024-01-01 10:00:00.000+08:00
2 2026-01-06 16:13:12.000+08:00
3 2024-11-11 11:11:11.123+08:00

-- !native_1_cast --
1 2024-01-01 10:00:00.000+08:00
Expand Down
Loading
Loading