Skip to content

Commit b08f402

Browse files
committed
Merge branch 'fv2-string' of github.com:sundy-li/fuse-query into fv2-string
2 parents ce55f93 + a3d64a1 commit b08f402

File tree

62 files changed

+475
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+475
-232
lines changed

Cargo.lock

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/doc/30-reference/20-functions/30-datetime-functions/todatetime.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ The function extracts a date and time from the provided string. If the argument
2222

2323
Returns a value of Timestamp type in the format “YYYY-MM-DD hh:mm:ss.ffffff”.
2424

25+
If the expr matches this format but does not have a time part, it is automatically extended to this pattern. The padding value is 0.
26+
2527
## Examples
2628

2729
### Using a String as Argument
@@ -46,6 +48,11 @@ SELECT TO_DATETIME('2022-01-02T01:12:00-07:00');
4648

4749
---
4850
2022-01-02 08:12:00.000000
51+
52+
SELECT TO_DATETIME('2022-01-02T01');
53+
54+
---
55+
2022-01-02 01:00:00.000000
4956
```
5057

5158
### Using an Integer as Argument

src/binaries/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ common-grpc = { path = "../common/grpc" }
3333
common-macros = { path = "../common/macros" }
3434
common-meta-api = { path = "../meta/api" }
3535
common-meta-app = { path = "../meta/app" }
36+
common-meta-client = { path = "../meta/client" }
3637
common-meta-embedded = { path = "../meta/embedded" }
37-
common-meta-grpc = { path = "../meta/grpc" }
3838
common-meta-raft-store = { path = "../meta/raft-store" }
3939
common-meta-sled-store = { path = "../meta/sled-store" }
4040
common-meta-store = { path = "../meta/store" }

src/binaries/metabench/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ use common_meta_app::schema::DatabaseNameIdent;
2727
use common_meta_app::schema::GetTableReq;
2828
use common_meta_app::schema::TableNameIdent;
2929
use common_meta_app::schema::UpsertTableOptionReq;
30-
use common_meta_grpc::ClientHandle;
31-
use common_meta_grpc::MetaGrpcClient;
30+
use common_meta_client::ClientHandle;
31+
use common_meta_client::MetaGrpcClient;
3232
use common_meta_types::MatchSeq;
3333
use common_meta_types::Operation;
3434
use common_meta_types::UpsertKVReq;

src/binaries/metactl/grpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use std::fs::File;
1616
use std::io::Write;
1717

18-
use common_meta_grpc::MetaGrpcClient;
18+
use common_meta_client::MetaGrpcClient;
1919
use common_meta_types::protobuf::Empty;
2020
use tokio_stream::StreamExt;
2121

src/binaries/metactl/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ mod snapshot;
2020
use clap::Parser;
2121
use common_base::base::tokio;
2222
use common_meta_api::KVApi;
23-
use common_meta_grpc::MetaGrpcClient;
23+
use common_meta_client::MetaGrpcClient;
2424
use common_meta_raft_store::config::get_default_raft_advertise_host;
2525
use common_tracing::init_logging;
2626
use common_tracing::Config as LogConfig;

src/binaries/query/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ use std::sync::Arc;
1818

1919
use common_base::base::RuntimeTracker;
2020
use common_macros::databend_main;
21+
use common_meta_client::MIN_METASRV_SEMVER;
2122
use common_meta_embedded::MetaEmbedded;
22-
use common_meta_grpc::MIN_METASRV_SEMVER;
2323
use common_metrics::init_default_metrics_recorder;
2424
use common_tracing::set_panic_hook;
2525
use databend_query::api::HttpService;

src/common/io/src/buffer/buffer_read_datetime_ext.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,27 @@ where R: BufferRead
9797
loop {
9898
buf.clear();
9999
let size = self.keep_read(&mut buf, |f| (b'0'..=b'9').contains(&f))?;
100-
match get_time(&mut buf, size) {
101-
Ok(time) => times.push(time),
102-
Err(e) => return Err(e),
103-
}
104-
if times.len() == 3 {
100+
if size == 0 {
105101
break;
102+
} else {
103+
let time = get_time(&mut buf, size)?;
104+
times.push(time);
105+
if times.len() == 3 {
106+
break;
107+
}
108+
self.ignore_byte(b':')?;
106109
}
107-
self.must_ignore_byte(b':')?;
108110
}
111+
// Time part is HH:MM or HH or empty
112+
// Examples: '2022-02-02T', '2022-02-02 ', '2022-02-02T02', '2022-02-02T3:', '2022-02-03T03:13', '2022-02-03T03:13:'
113+
if times.len() < 3 {
114+
times.resize(3, 0);
115+
dt = tz
116+
.from_local_datetime(&d.and_hms(times[0], times[1], times[2]))
117+
.unwrap();
118+
return less_1000(dt);
119+
}
120+
109121
dt = tz
110122
.from_local_datetime(&d.and_hms(times[0], times[1], times[2]))
111123
.unwrap();

src/common/io/tests/it/buffer/buffer_read_datetime_ext.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ use common_io::prelude::*;
1919
#[test]
2020
fn test_read_datetime_ext() -> Result<()> {
2121
let mut reader = BufferReader::new(
22-
"2023-03-03,2022-02-02,2009-01-01 3:2:1.123,2009-01-01 0:00:00,2009-01-01 00:00:00.123,2009-01-01 00:00:00.123456,0002-03-03T00:01:02,2022-03-04T00:01:02+08:00,2022-03-04T00:01:02-08:00,0000-00-00,0000-00-00 00:00:00,0001-01-01 00:00:00,2020-01-01T11:11:11Z,2009-01-03 00:00:00,2020-01-01T11:11:11.123Z,2055-02-03 10:00:20.234+08:00,2055-02-03 10:00:20.234-08:00,1022-05-16T03:25:02.000000+08:00".as_bytes(),
22+
"2022-02-02T,2022-02-02 12,2022-02-02T13:4:,2022-02-02 12:03,2023-03-03,2022-02-02,2009-01-01 3:2:1.123,2009-01-01 0:00:00,2009-01-01 00:00:00.123,2009-01-01 00:00:00.123456,0002-03-03T00:01:02,2022-03-04T00:01:02+08:00,2022-03-04T00:01:02-08:00,0000-00-00,0000-00-00 00:00:00,0001-01-01 00:00:00,2020-01-01T11:11:11Z,2009-01-03 00:00:00,2020-01-01T11:11:11.123Z,2055-02-03 10:00:20.234+08:00,2055-02-03 10:00:20.234-08:00,1022-05-16T03:25:02.000000+08:00".as_bytes(),
2323
);
2424
let tz = Tz::UTC;
2525
let expected = vec![
26+
"2022-02-02T00:00:00UTC",
27+
"2022-02-02T12:00:00UTC",
28+
"2022-02-02T13:04:00UTC",
29+
"2022-02-02T12:03:00UTC",
2630
"2023-03-03T00:00:00UTC",
2731
"2022-02-02T00:00:00UTC",
2832
"2009-01-01T03:02:01.123UTC",

src/meta/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Databend Meta is a transactional metadata service.
55
- [`api`](./api/), the user level api interface exposed based on the KVApi implementation.
66
- [`app`](./app/), defines meta data types used by meta-client application.
77
- [`embedded`](./embedded/), a meta store backed with a local sled::Tree.
8-
- [`grpc`](./grpc/), the client library based on grpc and is used to communicate with meta service.
8+
- [`grpc`](client/), the client library based on grpc and is used to communicate with meta service.
99
- [`protos`](./protos/) defines the protobuf messages a meta client talks to a meta server.
1010
- [`proto-conv`](./proto-conv/) defines how to convert metadata types in rust from and to protobuf messages.
1111
- [`raft-store`](./raft-store/), the storage layer implementation of openraft, including the state machine.

0 commit comments

Comments
 (0)