Skip to content

Commit 63ef493

Browse files
authored
Merge branch 'main' into ISSUE-9077
2 parents 67c4636 + 2a974cd commit 63ef493

File tree

44 files changed

+590
-212
lines changed

Some content is hidden

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

44 files changed

+590
-212
lines changed

Cargo.lock

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ where R: BufferRead
4747
{
4848
fn read_date_text(&mut self, tz: &Tz) -> Result<NaiveDate> {
4949
// TODO support YYYYMMDD format
50-
self.read_timestamp_text(tz).map(|dt| dt.naive_utc().date())
50+
self.read_timestamp_text(tz)
51+
.map(|dt| dt.naive_local().date())
5152
}
5253

5354
fn read_timestamp_text(&mut self, tz: &Tz) -> Result<DateTime<Tz>> {

src/common/io/src/cursor_ext/cursor_read_datetime_ext.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ where T: AsRef<[u8]>
7575
{
7676
fn read_date_text(&mut self, tz: &Tz) -> Result<NaiveDate> {
7777
// TODO support YYYYMMDD format
78-
self.read_timestamp_text(tz).map(|dt| dt.naive_utc().date())
78+
self.read_timestamp_text(tz)
79+
.map(|dt| dt.naive_local().date())
7980
}
8081

8182
fn read_timestamp_text(&mut self, tz: &Tz) -> Result<DateTime<Tz>> {

src/meta/service/src/configs/inner.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,19 @@ impl Config {
6868
///
6969
/// In the future, we could have `ConfigV1` and `ConfigV2`.
7070
pub fn load() -> Result<Self, MetaStartupError> {
71-
let cfg = OuterV0Config::load()?.into();
71+
let cfg = OuterV0Config::load(true)?.into();
7272

7373
Ok(cfg)
7474
}
7575

76+
/// # NOTE
77+
///
78+
/// This function is served for tests only.
79+
pub fn load_for_test() -> Result<Self, MetaStartupError> {
80+
let cfg: Self = OuterV0Config::load(false)?.into();
81+
Ok(cfg)
82+
}
83+
7684
/// Transform config into the outer style.
7785
///
7886
/// This function should only be used for end-users.

src/meta/service/src/configs/outer_v0.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,18 @@ impl Config {
185185
/// - Load from file as default.
186186
/// - Load from env, will override config from file.
187187
/// - Load from args as finally override
188-
pub fn load() -> Result<Self, MetaStartupError> {
189-
let arg_conf = Self::parse();
188+
///
189+
/// # Notes
190+
///
191+
/// with_args is to control whether we need to load from args or not.
192+
/// We should set this to false during tests because we don't want
193+
/// our test binary to parse cargo's args.
194+
pub fn load(with_args: bool) -> Result<Self, MetaStartupError> {
195+
let mut arg_conf = Self::default();
196+
197+
if with_args {
198+
arg_conf = Self::parse();
199+
}
190200

191201
let mut builder: serfig::Builder<Self> = serfig::Builder::default();
192202

@@ -213,7 +223,9 @@ impl Config {
213223
builder = builder.collect(from_self(cfg_via_env.into()));
214224

215225
// Finally, load from args.
216-
builder = builder.collect(from_self(arg_conf));
226+
if with_args {
227+
builder = builder.collect(from_self(arg_conf));
228+
}
217229

218230
builder
219231
.build()

src/meta/service/tests/it/configs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ cluster_name = "foo_cluster"
6868
)?;
6969

7070
temp_env::with_var("METASRV_CONFIG_FILE", Some(file_path.clone()), || {
71-
let cfg = Config::load().expect("load must success");
71+
let cfg = Config::load_for_test().expect("load must success");
7272
assert_eq!(cfg.log.file.level, "ERROR");
7373
assert_eq!(cfg.log.file.dir, "foo/logs");
7474
assert_eq!(cfg.admin_api_address, "127.0.0.1:9000");
@@ -101,7 +101,7 @@ cluster_name = "foo_cluster"
101101
("METASRV_LOG_LEVEL", Some("DEBUG")),
102102
],
103103
|| {
104-
let cfg = Config::load().expect("load must success");
104+
let cfg = Config::load_for_test().expect("load must success");
105105
assert_eq!(cfg.log.file.level, "DEBUG");
106106
},
107107
);
@@ -116,7 +116,7 @@ cluster_name = "foo_cluster"
116116
("KVSRV_API_PORT", Some("123")),
117117
],
118118
|| {
119-
let cfg = Config::load().expect("load must success");
119+
let cfg = Config::load_for_test().expect("load must success");
120120
assert_eq!(cfg.raft_config.raft_api_port, 123);
121121
},
122122
);

src/query/config/src/inner.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl Config {
6262
///
6363
/// In the future, we could have `ConfigV1` and `ConfigV2`.
6464
pub fn load() -> Result<Self> {
65-
let cfg: Self = OuterV0Config::load()?.try_into()?;
65+
let cfg: Self = OuterV0Config::load(true)?.try_into()?;
6666

6767
// Only check meta config when cmd is empty.
6868
if cfg.cmd.is_empty() {
@@ -71,6 +71,14 @@ impl Config {
7171
Ok(cfg)
7272
}
7373

74+
/// # NOTE
75+
///
76+
/// This function is served for tests only.
77+
pub fn load_for_test() -> Result<Self> {
78+
let cfg: Self = OuterV0Config::load(false)?.try_into()?;
79+
Ok(cfg)
80+
}
81+
7482
pub fn tls_query_cli_enabled(&self) -> bool {
7583
!self.query.rpc_tls_query_server_root_ca_cert.is_empty()
7684
&& !self.query.rpc_tls_query_service_domain_name.is_empty()

src/query/config/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ mod outer_v0;
2828
mod version;
2929

3030
pub use inner::CatalogConfig;
31+
pub use inner::CatalogHiveConfig;
3132
pub use inner::Config;
3233
pub use inner::QueryConfig;
34+
pub use inner::ThriftProtocol;
3335
pub use version::DATABEND_COMMIT_VERSION;
3436
pub use version::QUERY_SEMVER;

src/query/config/src/outer_v0.rs

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,18 @@ impl Config {
130130
/// - Load from file as default.
131131
/// - Load from env, will override config from file.
132132
/// - Load from args as finally override
133-
pub fn load() -> Result<Self> {
134-
let arg_conf = Self::parse();
133+
///
134+
/// # Notes
135+
///
136+
/// with_args is to control whether we need to load from args or not.
137+
/// We should set this to false during tests because we don't want
138+
/// our test binary to parse cargo's args.
139+
pub fn load(with_args: bool) -> Result<Self> {
140+
let mut arg_conf = Self::default();
141+
142+
if with_args {
143+
arg_conf = Self::parse();
144+
}
135145

136146
let mut builder: serfig::Builder<Self> = serfig::Builder::default();
137147

@@ -154,7 +164,9 @@ impl Config {
154164
builder = builder.collect(from_env());
155165

156166
// Finally, load from args.
157-
builder = builder.collect(from_self(arg_conf));
167+
if with_args {
168+
builder = builder.collect(from_self(arg_conf));
169+
}
158170

159171
Ok(builder.build()?)
160172
}
@@ -169,7 +181,7 @@ impl From<InnerConfig> for Config {
169181
log: inner.log.into(),
170182
meta: inner.meta.into(),
171183
storage: inner.storage.into(),
172-
catalog: HiveCatalogConfig::empty(),
184+
catalog: HiveCatalogConfig::default(),
173185

174186
catalogs: inner
175187
.catalogs
@@ -366,9 +378,9 @@ impl TryInto<InnerStorageConfig> for StorageConfig {
366378
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
367379
pub struct CatalogConfig {
368380
#[serde(rename = "type")]
369-
ty: String,
381+
pub ty: String,
370382
#[serde(flatten)]
371-
hive: CatalogsHiveConfig,
383+
pub hive: CatalogsHiveConfig,
372384
}
373385

374386
impl Default for CatalogConfig {
@@ -389,8 +401,8 @@ pub struct CatalogsHiveConfig {
389401
}
390402

391403
/// this is the legacy version of external catalog configuration
392-
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Args)]
393-
#[serde(default = "HiveCatalogConfig::empty")]
404+
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize, Args)]
405+
#[serde(default)]
394406
pub struct HiveCatalogConfig {
395407
#[clap(long = "hive-meta-store-address", default_value_t)]
396408
#[serde(rename = "address", alias = "meta_store_address")]
@@ -468,21 +480,6 @@ impl From<InnerCatalogHiveConfig> for HiveCatalogConfig {
468480
}
469481
}
470482

471-
impl Default for HiveCatalogConfig {
472-
fn default() -> Self {
473-
InnerCatalogHiveConfig::default().into()
474-
}
475-
}
476-
477-
impl HiveCatalogConfig {
478-
pub fn empty() -> Self {
479-
HiveCatalogConfig {
480-
meta_store_address: "".to_string(),
481-
protocol: "".to_string(),
482-
}
483-
}
484-
}
485-
486483
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
487484
#[serde(default)]
488485
pub struct CacheConfig {

src/query/datablocks/src/kernels/data_block_sort.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ impl DataBlock {
4545
sort_columns_descriptions: &[SortColumnDescription],
4646
limit: Option<usize>,
4747
) -> Result<DataBlock> {
48+
if block.is_empty() {
49+
return Ok(block.clone());
50+
}
4851
let order_columns = sort_columns_descriptions
4952
.iter()
5053
.map(|f| {

0 commit comments

Comments
 (0)