Skip to content

Commit a20533f

Browse files
committed
Merge remote-tracking branch 'up/main' into range-shuffle
2 parents 61383d0 + b73a9eb commit a20533f

File tree

37 files changed

+668
-91
lines changed

37 files changed

+668
-91
lines changed

.github/actions/pack_deb/action.yml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -42,47 +42,34 @@ runs:
4242
export version="${{ inputs.version }}"
4343
case "${{ inputs.arch }}" in
4444
x86_64)
45-
echo "deb_arch=amd64" >> $GITHUB_OUTPUT
45+
echo "arch=amd64" >> $GITHUB_OUTPUT
4646
;;
4747
aarch64)
48-
echo "deb_arch=arm64" >> $GITHUB_OUTPUT
48+
echo "arch=arm64" >> $GITHUB_OUTPUT
4949
;;
5050
*)
5151
echo "Unsupported arch: ${{ inputs.arch }}"
5252
exit 1
5353
;;
5454
esac
55-
deb_version=${version/-/.}
56-
echo "deb_version=${deb_version/v/}" >> $GITHUB_OUTPUT
57-
mkdir -p distro/{bin,configs,systemd,scripts}
55+
deb_version=${version/-/'~'}
56+
echo "version=${deb_version/v/}" >> $GITHUB_OUTPUT
57+
mkdir -p distro/{bin,configs,systemd,scripts,pkg}
5858
cp ./scripts/distribution/systemd/databend-* distro/systemd/
5959
cp ./scripts/distribution/configs/databend-* distro/configs/
6060
cp ./scripts/distribution/release-readme.txt distro/readme.txt
6161
cp -r ./scripts/distribution/package-scripts/* distro/scripts/
6262
63-
- name: Build Databend Query Package
63+
- name: Build Databend Packages
6464
shell: bash
6565
run: |
66-
yq -i '.arch = "${{ steps.info.outputs.deb_arch }}"' scripts/distribution/nfpm-query.yaml
67-
yq -i '.version = "${{ steps.info.outputs.deb_version }}"' scripts/distribution/nfpm-query.yaml
68-
pkg_name="databend-query_${{ steps.info.outputs.deb_version }}_${{ steps.info.outputs.deb_arch }}.deb"
69-
nfpm pkg --packager deb -t "distro/${pkg_name}" -f scripts/distribution/nfpm-query.yaml
70-
71-
- name: Build Databend Meta Package
72-
shell: bash
73-
run: |
74-
yq -i '.arch = "${{ steps.info.outputs.deb_arch }}"' scripts/distribution/nfpm-meta.yaml
75-
yq -i '.version = "${{ steps.info.outputs.deb_version }}"' scripts/distribution/nfpm-meta.yaml
76-
pkg_name="databend-meta_${{ steps.info.outputs.deb_version }}_${{ steps.info.outputs.deb_arch }}.deb"
77-
nfpm pkg --packager deb -t "distro/${pkg_name}" -f scripts/distribution/nfpm-meta.yaml
78-
79-
- name: Build Databend Debug Package
80-
shell: bash
81-
run: |
82-
yq -i '.arch = "${{ steps.info.outputs.deb_arch }}"' scripts/distribution/nfpm-query-dbg.yaml
83-
yq -i '.version = "${{ steps.info.outputs.deb_version }}"' scripts/distribution/nfpm-query-dbg.yaml
84-
pkg_name="databend-query-dbg_${{ steps.info.outputs.deb_version }}_${{ steps.info.outputs.deb_arch }}.deb"
85-
nfpm pkg --packager deb -t "distro/${pkg_name}" -f scripts/distribution/nfpm-query-dbg.yaml
66+
pkgs="query meta query-dbg"
67+
for pkg in $pkgs; do
68+
yq -i '.arch = "${{ steps.info.outputs.arch }}"' scripts/distribution/nfpm-${pkg}.yaml
69+
yq -i '.version = "${{ steps.info.outputs.version }}"' scripts/distribution/nfpm-${pkg}.yaml
70+
nfpm pkg --packager deb --target distro/pkg -f scripts/distribution/nfpm-${pkg}.yaml
71+
done
72+
ls -lh distro/pkg
8673
8774
- name: Update release to github
8875
shell: bash
@@ -92,6 +79,6 @@ runs:
9279
run: |
9380
version="${{ inputs.version }}"
9481
# name looks like: `databend_0.8.144~nightly_amd64.deb`
95-
for pkg in $(ls distro/*.deb); do
82+
for pkg in $(ls distro/pkg/*.deb); do
9683
gh release upload ${version} $pkg --clobber
9784
done

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,8 @@ Databend thrives on community contributions! Whether it's through ideas, code, o
272272

273273
Here are some resources to help you get started:
274274

275-
- [Building Databend From Source](https://docs.databend.com/guides/community/contributor/building-from-source)
276-
- [The First Good Pull Request](https://docs.databend.com/guides/community/contributor/good-pr)
275+
- [Building Databend From Source](https://docs.databend.com/developer/community/contributor/building-from-source)
276+
- [The First Good Pull Request](https://docs.databend.com/developer/community/contributor/good-pr)
277277

278278
## 👥 Community
279279

scripts/distribution/nfpm-meta.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "databend-meta"
2-
arch: "${arch}"
2+
arch: ""
33
platform: "linux"
4-
version: "${version}"
4+
version: ""
55
section: "database"
66
priority: "extra"
77
maintainer: "Databend Labs <opensource@databend.com>"

scripts/distribution/nfpm-query-dbg.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "databend-query-dbg"
2-
arch: "${arch}"
2+
arch: ""
33
platform: "linux"
4-
version: "${version}"
4+
version: ""
55
section: "database"
66
priority: "extra"
77
maintainer: "Databend Labs <opensource@databend.com>"

scripts/distribution/nfpm-query.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "databend-query"
2-
arch: "${arch}"
2+
arch: ""
33
platform: "linux"
4-
version: "${version}"
4+
version: ""
55
section: "database"
66
priority: "extra"
77
maintainer: "Databend Labs <opensource@databend.com>"

src/common/storage/src/runtime_layer.rs

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ use opendal::raw::RpRead;
3535
use opendal::raw::RpStat;
3636
use opendal::raw::RpWrite;
3737
use opendal::Buffer;
38+
use opendal::Metadata;
3839
use opendal::Result;
3940

4041
/// # TODO
@@ -89,11 +90,11 @@ impl<A: Access> LayeredAccess for RuntimeAccessor<A> {
8990
type Inner = A;
9091
type Reader = RuntimeIO<A::Reader>;
9192
type BlockingReader = A::BlockingReader;
92-
type Writer = A::Writer;
93+
type Writer = RuntimeIO<A::Writer>;
9394
type BlockingWriter = A::BlockingWriter;
94-
type Lister = A::Lister;
95+
type Lister = RuntimeIO<A::Lister>;
9596
type BlockingLister = A::BlockingLister;
96-
type Deleter = RuntimeIO<A::Deleter>;
97+
type Deleter = RuntimeIO<RuntimeIO<A::Deleter>>;
9798
type BlockingDeleter = A::BlockingDeleter;
9899

99100
fn inner(&self) -> &Self::Inner {
@@ -130,6 +131,10 @@ impl<A: Access> LayeredAccess for RuntimeAccessor<A> {
130131
.spawn(async move { op.write(&path, args).await })
131132
.await
132133
.expect("join must success")
134+
.map(|(rp, r)| {
135+
let r = RuntimeIO::new(r, self.runtime.clone());
136+
(rp, r)
137+
})
133138
}
134139

135140
async fn stat(&self, path: &str, args: OpStat) -> Result<RpStat> {
@@ -152,6 +157,10 @@ impl<A: Access> LayeredAccess for RuntimeAccessor<A> {
152157
let r = RuntimeIO::new(r, self.runtime.clone());
153158
(rp, r)
154159
})
160+
.map(|(rp, r)| {
161+
let r = RuntimeIO::new(r, self.runtime.clone());
162+
(rp, r)
163+
})
155164
}
156165

157166
async fn list(&self, path: &str, args: OpList) -> Result<(RpList, Self::Lister)> {
@@ -161,6 +170,10 @@ impl<A: Access> LayeredAccess for RuntimeAccessor<A> {
161170
.spawn(async move { op.list(&path, args).await })
162171
.await
163172
.expect("join must success")
173+
.map(|(rp, r)| {
174+
let r = RuntimeIO::new(r, self.runtime.clone());
175+
(rp, r)
176+
})
164177
}
165178

166179
fn blocking_read(&self, path: &str, args: OpRead) -> Result<(RpRead, Self::BlockingReader)> {
@@ -211,13 +224,77 @@ impl<R: oio::Read> oio::Read for RuntimeIO<R> {
211224
}
212225
}
213226

227+
impl<R: oio::Write> oio::Write for RuntimeIO<R> {
228+
async fn write(&mut self, bs: Buffer) -> Result<()> {
229+
let mut r = self.inner.take().expect("writer must be valid");
230+
let runtime = self.runtime.clone();
231+
232+
let (r, res) = runtime
233+
.spawn(async move {
234+
let res = r.write(bs).await;
235+
(r, res)
236+
})
237+
.await
238+
.expect("join must success");
239+
self.inner = Some(r);
240+
res
241+
}
242+
243+
async fn close(&mut self) -> Result<Metadata> {
244+
let mut r = self.inner.take().expect("writer must be valid");
245+
let runtime = self.runtime.clone();
246+
247+
let (r, res) = runtime
248+
.spawn(async move {
249+
let res = r.close().await;
250+
(r, res)
251+
})
252+
.await
253+
.expect("join must success");
254+
self.inner = Some(r);
255+
res
256+
}
257+
258+
async fn abort(&mut self) -> Result<()> {
259+
let mut r = self.inner.take().expect("writer must be valid");
260+
let runtime = self.runtime.clone();
261+
262+
let (r, res) = runtime
263+
.spawn(async move {
264+
let res = r.abort().await;
265+
(r, res)
266+
})
267+
.await
268+
.expect("join must success");
269+
self.inner = Some(r);
270+
res
271+
}
272+
}
273+
274+
impl<R: oio::List> oio::List for RuntimeIO<R> {
275+
async fn next(&mut self) -> Result<Option<oio::Entry>> {
276+
let mut r = self.inner.take().expect("lister must be valid");
277+
let runtime = self.runtime.clone();
278+
279+
let (r, res) = runtime
280+
.spawn(async move {
281+
let res = r.next().await;
282+
(r, res)
283+
})
284+
.await
285+
.expect("join must success");
286+
self.inner = Some(r);
287+
res
288+
}
289+
}
290+
214291
impl<R: oio::Delete> oio::Delete for RuntimeIO<R> {
215292
fn delete(&mut self, path: &str, args: OpDelete) -> Result<()> {
216293
self.inner.as_mut().unwrap().delete(path, args)
217294
}
218295

219296
async fn flush(&mut self) -> Result<usize> {
220-
let mut r = self.inner.take().expect("reader must be valid");
297+
let mut r = self.inner.take().expect("deleter must be valid");
221298
let runtime = self.runtime.clone();
222299

223300
let (r, res) = runtime

src/query/ast/src/ast/statements/database.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ impl Display for AlterDatabaseStmt {
166166
AlterDatabaseAction::RenameDatabase { new_db } => {
167167
write!(f, " RENAME TO {new_db}")?;
168168
}
169+
AlterDatabaseAction::RefreshDatabaseCache => {
170+
write!(f, " REFRESH CACHE")?;
171+
}
169172
}
170173

171174
Ok(())
@@ -175,6 +178,7 @@ impl Display for AlterDatabaseStmt {
175178
#[derive(Debug, Clone, PartialEq, Eq, Drive, DriveMut)]
176179
pub enum AlterDatabaseAction {
177180
RenameDatabase { new_db: Identifier },
181+
RefreshDatabaseCache,
178182
}
179183

180184
#[derive(Debug, Clone, PartialEq, Eq, Drive, DriveMut)]

src/query/ast/src/ast/statements/table.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ pub enum AlterTableAction {
465465
UnsetOptions {
466466
targets: Vec<Identifier>,
467467
},
468+
RefreshTableCache,
468469
}
469470

470471
impl Display for AlterTableAction {
@@ -534,6 +535,9 @@ impl Display for AlterTableAction {
534535
write!(f, ")")?;
535536
}
536537
}
538+
AlterTableAction::RefreshTableCache => {
539+
write!(f, "REFRESH CACHE")?;
540+
}
537541
};
538542
Ok(())
539543
}

src/query/ast/src/parser/statement.rs

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ pub fn statement_body(i: Input) -> IResult<Statement> {
519519
);
520520
let use_catalog = map(
521521
rule! {
522-
USE ~ CATALOG ~ #ident
522+
(SET | USE)? ~ CATALOG ~ #ident
523523
},
524524
|(_, _, catalog)| Statement::UseCatalog { catalog },
525525
);
@@ -786,20 +786,37 @@ pub fn statement_body(i: Input) -> IResult<Statement> {
786786
})
787787
},
788788
);
789+
790+
pub fn from_tables(i: Input) -> IResult<(Option<Identifier>, Option<Identifier>, Identifier)> {
791+
let from_dot_table = map(
792+
rule! {
793+
( FROM | IN ) ~ ^#dot_separated_idents_1_to_3
794+
},
795+
|(_, (catalog, database, table))| (catalog, database, table),
796+
);
797+
798+
let from_table = map(
799+
rule! {
800+
( FROM | IN ) ~ #ident
801+
~ ( FROM | IN ) ~ ^#dot_separated_idents_1_to_2
802+
},
803+
|(_, table, _, (catalog, database))| (catalog, Some(database), table),
804+
);
805+
806+
rule!(
807+
#from_table
808+
| #from_dot_table
809+
)(i)
810+
}
811+
789812
let show_columns = map(
790813
rule! {
791814
SHOW
792815
~ FULL? ~ COLUMNS
793-
~ ( FROM | IN ) ~ #ident
794-
~ (( FROM | IN ) ~ ^#dot_separated_idents_1_to_2)?
816+
~ #from_tables
795817
~ #show_limit?
796818
},
797-
|(_, opt_full, _, _, table, ctl_db, limit)| {
798-
let (catalog, database) = match ctl_db {
799-
Some((_, (Some(c), d))) => (Some(c), Some(d)),
800-
Some((_, (None, d))) => (None, Some(d)),
801-
_ => (None, None),
802-
};
819+
|(_, opt_full, _, (catalog, database, table), limit)| {
803820
Statement::ShowColumns(ShowColumnsStmt {
804821
catalog,
805822
database,
@@ -3702,15 +3719,23 @@ pub fn create_table_source(i: Input) -> IResult<CreateTableSource> {
37023719
}
37033720

37043721
pub fn alter_database_action(i: Input) -> IResult<AlterDatabaseAction> {
3705-
let mut rename_database = map(
3722+
let rename_database = map(
37063723
rule! {
37073724
RENAME ~ TO ~ #ident
37083725
},
37093726
|(_, _, new_db)| AlterDatabaseAction::RenameDatabase { new_db },
37103727
);
37113728

3729+
let refresh_cache = map(
3730+
rule! {
3731+
REFRESH ~ CACHE
3732+
},
3733+
|(_, _)| AlterDatabaseAction::RefreshDatabaseCache,
3734+
);
3735+
37123736
rule!(
37133737
#rename_database
3738+
| #refresh_cache
37143739
)(i)
37153740
}
37163741

@@ -3922,6 +3947,13 @@ pub fn alter_table_action(i: Input) -> IResult<AlterTableAction> {
39223947
|(_, _, targets)| AlterTableAction::UnsetOptions { targets },
39233948
);
39243949

3950+
let refresh_cache = map(
3951+
rule! {
3952+
REFRESH ~ CACHE
3953+
},
3954+
|(_, _)| AlterTableAction::RefreshTableCache,
3955+
);
3956+
39253957
rule!(
39263958
#alter_table_cluster_key
39273959
| #drop_table_cluster_key
@@ -3935,6 +3967,7 @@ pub fn alter_table_action(i: Input) -> IResult<AlterTableAction> {
39353967
| #revert_table
39363968
| #set_table_options
39373969
| #unset_table_options
3970+
| #refresh_cache
39383971
)(i)
39393972
}
39403973

src/query/ast/src/parser/token.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,8 @@ pub enum TokenKind {
459459
CHAR,
460460
#[token("COLUMN", ignore(ascii_case))]
461461
COLUMN,
462+
#[token("CACHE", ignore(ascii_case))]
463+
CACHE,
462464
#[token("COLUMN_MATCH_MODE", ignore(ascii_case))]
463465
COLUMN_MATCH_MODE,
464466
#[token("COLUMNS", ignore(ascii_case))]

0 commit comments

Comments
 (0)