Skip to content

Commit b13e777

Browse files
committed
add new ident parse func: option_ident
1 parent 81b8d88 commit b13e777

File tree

9 files changed

+20
-8
lines changed

9 files changed

+20
-8
lines changed

src/query/ast/src/parser/common.rs

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ pub fn ident(i: Input) -> IResult<Identifier> {
8888
non_reserved_identifier(|token| token.is_reserved_ident(false))(i)
8989
}
9090

91+
pub fn option_ident(i: Input) -> IResult<Identifier> {
92+
non_reserved_identifier(|token| token.is_option_reserved_ident(false, true))(i)
93+
}
94+
9195
pub fn plain_ident(i: Input) -> IResult<Identifier> {
9296
plain_identifier(|token| token.is_reserved_ident(false))(i)
9397
}

src/query/ast/src/parser/stage.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub fn connection_opt(sep: &'static str) -> impl FnMut(Input) -> IResult<(String
4747
move |i| {
4848
let string_options = map(
4949
rule! {
50-
#ident ~ #match_text(sep) ~ #literal_string
50+
#option_ident ~ #match_text(sep) ~ #literal_string
5151
},
5252
|(k, _, v)| (k.to_string().to_lowercase(), v),
5353
);

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

+7
Original file line numberDiff line numberDiff line change
@@ -1772,6 +1772,13 @@ impl TokenKind {
17721772
_ => false
17731773
}
17741774
}
1775+
1776+
pub(crate) fn is_option_reserved_ident(&self, after_as: bool, in_option: bool) -> bool {
1777+
match self {
1778+
TokenKind::WAREHOUSE if in_option => false,
1779+
_ => self.is_reserved_ident(after_as),
1780+
}
1781+
}
17751782
}
17761783

17771784
pub fn all_reserved_keywords() -> Vec<String> {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn test_statement() {
137137
r#"drop table a;"#,
138138
r#"drop table if exists a."b";"#,
139139
r#"use "a";"#,
140-
r#"create catalog ctl type=hive connection=(url='<hive-meta-store>' thrift_protocol='binary');"#,
140+
r#"create catalog ctl type=hive connection=(url='<hive-meta-store>' thrift_protocol='binary' warehouse='default');"#,
141141
r#"select current_catalog();"#,
142142
r#"use catalog ctl;"#,
143143
r#"create database if not exists a;"#,

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -2937,9 +2937,9 @@ UseDatabase {
29372937

29382938

29392939
---------- Input ----------
2940-
create catalog ctl type=hive connection=(url='<hive-meta-store>' thrift_protocol='binary');
2940+
create catalog ctl type=hive connection=(url='<hive-meta-store>' thrift_protocol='binary' warehouse='default');
29412941
---------- Output ---------
2942-
CREATE CATALOG ctl TYPE=HIVE CONNECTION = ( thrift_protocol = 'binary', url = '<hive-meta-store>' )
2942+
CREATE CATALOG ctl TYPE=HIVE CONNECTION = ( thrift_protocol = 'binary', url = '<hive-meta-store>', warehouse = 'default' )
29432943
---------- AST ------------
29442944
CreateCatalog(
29452945
CreateCatalogStmt {
@@ -2949,6 +2949,7 @@ CreateCatalog(
29492949
catalog_options: {
29502950
"thrift_protocol": "binary",
29512951
"url": "<hive-meta-store>",
2952+
"warehouse": "default",
29522953
},
29532954
},
29542955
)

tests/sqllogictests/suites/base/05_ddl/05_0029_ddl_create_catalog.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ SHOW CATALOGS;
1010
default
1111

1212
statement error 1001
13-
CREATE CATALOG ctl TYPE=ICEBERG CONNECTION=(TYPE='REST' ADDRESS='http://127.0.0.1:1000' `WAREHOUSE`='default' );
13+
CREATE CATALOG ctl TYPE=ICEBERG CONNECTION=(TYPE='REST' ADDRESS='http://127.0.0.1:1000' WAREHOUSE='default' );
1414

1515
statement ok
1616
DROP CATALOG IF EXISTS ctl;

tests/sqllogictests/suites/tpch_iceberg/prune.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TYPE=ICEBERG
77
CONNECTION=(
88
TYPE='rest'
99
ADDRESS='http://127.0.0.1:8181'
10-
`WAREHOUSE`='s3://iceberg-tpch'
10+
WAREHOUSE='s3://iceberg-tpch'
1111
"s3.region"='us-east-1'
1212
"s3.endpoint"='http://127.0.0.1:9000'
1313
);

tests/sqllogictests/suites/tpch_iceberg/queries.test

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ TYPE=ICEBERG
77
CONNECTION=(
88
TYPE='rest'
99
ADDRESS='http://127.0.0.1:8181'
10-
`WAREHOUSE`='s3://iceberg-tpch'
10+
WAREHOUSE='s3://iceberg-tpch'
1111
"s3.region"='us-east-1'
1212
"s3.endpoint"='http://127.0.0.1:9000'
1313
);

tests/suites/3_stateful_iceberg/00_rest/00_0000_create_and_show.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ TYPE=ICEBERG
1212
CONNECTION=(
1313
TYPE='rest'
1414
ADDRESS='http://127.0.0.1:8181'
15-
`WAREHOUSE`='s3://icebergdata/demo'
15+
WAREHOUSE='s3://icebergdata/demo'
1616
);
1717
EOF
1818

0 commit comments

Comments
 (0)