Skip to content

Commit 008649b

Browse files
authored
chore:(query): support [SET | USE] CATALOG <catalog_name> (#17844)
1 parent 51d95dd commit 008649b

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
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
);

src/query/ast/tests/it/parser.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ fn test_statement() {
147147
r#"create catalog ctl type=hive connection=(url='<hive-meta-store>' thrift_protocol='binary' warehouse='default');"#,
148148
r#"select current_catalog();"#,
149149
r#"use catalog ctl;"#,
150+
r#"catalog ctl;"#,
151+
r#"set catalog ctl;"#,
150152
r#"create database if not exists a;"#,
151153
r#"create database ctl.t engine = Default;"#,
152154
r#"create database t engine = Default;"#,

src/query/ast/tests/it/testdata/stmt.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,6 +3495,40 @@ UseCatalog {
34953495
}
34963496

34973497

3498+
---------- Input ----------
3499+
catalog ctl;
3500+
---------- Output ---------
3501+
USE CATALOG ctl
3502+
---------- AST ------------
3503+
UseCatalog {
3504+
catalog: Identifier {
3505+
span: Some(
3506+
8..11,
3507+
),
3508+
name: "ctl",
3509+
quote: None,
3510+
ident_type: None,
3511+
},
3512+
}
3513+
3514+
3515+
---------- Input ----------
3516+
set catalog ctl;
3517+
---------- Output ---------
3518+
USE CATALOG ctl
3519+
---------- AST ------------
3520+
UseCatalog {
3521+
catalog: Identifier {
3522+
span: Some(
3523+
12..15,
3524+
),
3525+
name: "ctl",
3526+
quote: None,
3527+
ident_type: None,
3528+
},
3529+
}
3530+
3531+
34983532
---------- Input ----------
34993533
create database if not exists a;
35003534
---------- Output ---------

tests/sqllogictests/suites/tpch_iceberg/table_function.test

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ CONNECTION=(
1313
);
1414

1515
statement ok
16-
use catalog ctl;
16+
SET catalog ctl;
17+
18+
statement ok
19+
catalog ctl;
1720

1821
statement ok
1922
select * from iceberg_snapshot('tpch', 'lineitem');

0 commit comments

Comments
 (0)