[WIP] [feature](timestamp) support timestamp data type#41760
[WIP] [feature](timestamp) support timestamp data type#41760justfortaste wants to merge 22 commits intoapache:masterfrom
Conversation
todo:
create table t1(id int, t timestamp)ENGINE=OLAP
UNIQUE KEY(k)
DISTRIBUTED BY HASH(id) BUCKETS 2
properties(
"replication_num" = "1",
"enable_unique_key_merge_on_write" = "true",
"disable_auto_compaction" = "true");
ERROR 1105 (HY000): errCode = 2, detailMessage = Nereids do not support type: timestamp
ERROR 1109 (42S02): errCode = 2, detailMessage = errCode = 2, detailMessage = Unknown table 't2' in test
MySQL [test]> create table t2(t timestamp, id int)ENGINE=OLAP
-> UNIQUE KEY(t)
-> DISTRIBUTED BY HASH(t) BUCKETS 2
-> properties(
-> "replication_num" = "1",
-> "enable_unique_key_merge_on_write" = "true",
-> "disable_auto_compaction" = "true");
Query OK, 0 rows affected (0.01 sec)
MySQL [test]> insert into t2 values('2020-01-01 10:00:00',1);
Query OK, 1 row affected (0.06 sec)
{'label':'label_1946a1a147b84131_b1e0100d5679ef25', 'status':'VISIBLE', 'txnId':'3'}
MySQL [test]> insert into t2 values('2025-01-01 11:11:11',2);
Query OK, 1 row affected (0.05 sec)
{'label':'label_d231330c9b1a4b06_9cf94bcc8c440c81', 'status':'VISIBLE', 'txnId':'4'}
MySQL [test]> select * from t2;
+---------------------+------+
| t | id |
+---------------------+------+
| 2020-01-01 10:00:00 | 1 |
| 2025-01-01 11:11:11 | 2 |
+---------------------+------+
2 rows in set (0.03 sec)
todo:
MySQL [test]> create table t2(t timestamp, id int)ENGINE=OLAP
-> UNIQUE KEY(t)
-> DISTRIBUTED BY HASH(t) BUCKETS 2
-> properties(
-> "replication_num" = "1",
-> "enable_unique_key_merge_on_write" = "true",
-> "disable_auto_compaction" = "true");
Query OK, 0 rows affected (0.01 sec)
MySQL [test]> insert into t2 values('2020-01-01 10:00:00',1);
ERROR 1105 (HY000): errCode = 2, detailMessage = unknown date like type
todo: ERROR 1105 (HY000): send fragments failed. io.grpc.StatusRuntimeException: UNAVAILABLE: Network closed for unknown reason, host: 127.0.0.1 7# google::LogMessageFatal::~LogMessageFatal() in /data/ayuanzhang/mydoris/output/be/lib/doris_be 8# doris::thrift_to_type(doris::TPrimitiveType::type) in /data/ayuanzhang/mydoris/output/be/lib/doris_be 9# doris::TypeDescriptor::TypeDescriptor(std::vector<doris::TTypeNode, std::allocator<doris::TTypeNode> > const&, int*) in /data/ayuanzhang/mydoris/output/be/lib/doris_be 10# doris::TypeDescriptor::from_thrift(doris::TTypeDesc const&) at /data/ayuanzhang/mydoris/be/src/runtime/types.h:149 11# doris::SlotDescriptor::SlotDescriptor(doris::TSlotDescriptor const&) at /data/ayuanzhang/mydoris/be/src/runtime/descriptors.cpp:46 12# doris::DescriptorTbl::create(doris::ObjectPool*, doris::TDescriptorTable const&, doris::DescriptorTbl**) in /data/ayuanzhang/mydoris/output/be/lib/doris_be
mysql> set time_zone="+8:00";
Query OK, 0 rows affected (0.01 sec)
mysql> insert into t1 values(1, '2020-01-01 10:00:00');
Query OK, 1 row affected (0.22 sec)
{'label':'label_5961c3a91f6f406e_ad316bfcc1d66eaa', 'status':'VISIBLE', 'txnId':'30028'}
mysql> set time_zone="+10:00";
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t1 values(2, '2020-01-01 10:00:00');
Query OK, 1 row affected (0.06 sec)
{'label':'label_684e9fee3de24054_a6fd582a5fce6440', 'status':'VISIBLE', 'txnId':'30029'}
mysql> select * from t1;
+------+---------------------+
| id | t |
+------+---------------------+
| 1 | 2020-01-01 10:00:00 |
| 2 | 2020-01-01 12:00:00 |
+------+---------------------+
2 rows in set (0.04 sec)
compile ok
-> UNIQUE KEY(id)
-> DISTRIBUTED BY HASH(id) BUCKETS 2
-> properties(
-> "replication_num" = "1",
-> "enable_unique_key_merge_on_write" = "true",
-> "disable_auto_compaction" = "true");
Query OK, 0 rows affected (0.01 sec)
mysql> set time_zone="+8:00";
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t1 values(1, '2020-01-01 10:00:00');
Query OK, 1 row affected (0.07 sec)
{'label':'label_57f023e840c49ef_87835e9756a210fc', 'status':'VISIBLE', 'txnId':'42043'}
mysql> select * from t1;
+------+---------------------+
| id | t |
+------+---------------------+
| 1 | 2020-01-01 11:00:00 |
+------+---------------------+
1 row in set (0.04 sec)
todo:
PGenericType::DATETIMEV2
PColumnType::COLUMN_TYPE_TIMESTAMP
|
Thank you for your contribution to Apache Doris. Since 2024-03-18, the Document has been moved to doris-website. |
| std::vector<RowwiseIteratorUPtr>* out_iters, | ||
| bool use_cache = false) override; | ||
|
|
||
| long tz_offset() { return _tz_offset; } |
There was a problem hiding this comment.
warning: method 'tz_offset' can be made const [readability-make-member-function-const]
| long tz_offset() { return _tz_offset; } | |
| long tz_offset() const { return _tz_offset; } |
|
|
||
| void insert_many_binary_data(char* data_array, uint32_t* len_array, | ||
| uint32_t* start_offset_array, size_t num) override { | ||
| uint32_t* start_offset_array, size_t num, |
There was a problem hiding this comment.
warning: pointer parameter 'start_offset_array' can be pointer to const [readability-non-const-parameter]
| uint32_t* start_offset_array, size_t num, | |
| const uint32_t* start_offset_array, size_t num, |
|
|
||
| void insert_many_binary_data(char* data_array, uint32_t* len_array, | ||
| uint32_t* start_offset_array, size_t num) override { | ||
| uint32_t* start_offset_array, size_t num, |
There was a problem hiding this comment.
warning: pointer parameter 'start_offset_array' can be pointer to const [readability-non-const-parameter]
| uint32_t* start_offset_array, size_t num, | |
| const uint32_t* start_offset_array, size_t num, |
| static constexpr bool is_parametric = true; | ||
|
|
||
| DataTypeDateTimeV2(UInt32 scale = 0) : _scale(scale) { | ||
| DataTypeDateTimeV2(UInt32 scale = 0, bool is_timestamp = 0) |
There was a problem hiding this comment.
warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
| DataTypeDateTimeV2(UInt32 scale = 0, bool is_timestamp = 0) | |
| DataTypeDateTimeV2(UInt32 scale = 0, bool is_timestamp = false) |
| }; | ||
|
|
||
| DataTypePtr create_datetimev2(UInt64 scale); | ||
| DataTypePtr create_datetimev2(UInt64 scale, bool is_timestamp = 0); |
There was a problem hiding this comment.
warning: converting integer literal to bool, use bool literal instead [modernize-use-bool-literals]
| DataTypePtr create_datetimev2(UInt64 scale, bool is_timestamp = 0); | |
| DataTypePtr create_datetimev2(UInt64 scale, bool is_timestamp = false); |
|
|
||
| OlapBlockDataConvertor::OlapColumnDataConvertorBaseUPtr | ||
| OlapBlockDataConvertor::create_olap_column_data_convertor(const TabletColumn& column) { | ||
| OlapBlockDataConvertor::create_olap_column_data_convertor(const TabletColumn& column, |
There was a problem hiding this comment.
warning: function 'create_olap_column_data_convertor' exceeds recommended size/complexity thresholds [readability-function-size]
OlapBlockDataConvertor::create_olap_column_data_convertor(const TabletColumn& column,
^Additional context
be/src/vec/olap/olap_data_convertor.cpp:115: 108 lines including whitespace and comments (threshold 80)
OlapBlockDataConvertor::create_olap_column_data_convertor(const TabletColumn& column,
^| union DateTimeV2UInt64Union { | ||
| DateV2Value<DateTimeV2ValueType> dt; | ||
| uint64_t ui64; | ||
| ~DateTimeV2UInt64Union() {} |
There was a problem hiding this comment.
warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
| ~DateTimeV2UInt64Union() {} | |
| ~DateTimeV2UInt64Union() = default; |
| union DateTimeV2UInt64Union { | ||
| DateV2Value<DateTimeV2ValueType> dt; | ||
| uint64_t ui64; | ||
| ~DateTimeV2UInt64Union() {} |
There was a problem hiding this comment.
warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
| ~DateTimeV2UInt64Union() {} | |
| ~DateTimeV2UInt64Union() = default; |
|
We're closing this PR because it hasn't been updated in a while. |
Proposed changes
Issue Number: close #xxx