Skip to content

Commit 86d742a

Browse files
authored
Merge pull request #7775 from ClSlaid/name-portless
fix(parser): name scheme with port number
2 parents e92e1c4 + cc4b8e7 commit 86d742a

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,8 +1425,14 @@ pub fn uri_location(i: Input) -> IResult<UriLocation> {
14251425
protocol: parsed.scheme().to_string(),
14261426
name: parsed
14271427
.host_str()
1428-
.ok_or(ErrorKind::Other("invalid uri location"))?
1429-
.to_string(),
1428+
.map(|hostname| {
1429+
if let Some(port) = parsed.port() {
1430+
format!("{}:{}", hostname, port)
1431+
} else {
1432+
hostname.to_string()
1433+
}
1434+
})
1435+
.ok_or(ErrorKind::Other("invalid uri location"))?,
14301436
path: if parsed.path().is_empty() {
14311437
"/".to_string()
14321438
} else {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,10 @@ fn test_statement() {
190190
skip_header = 1
191191
)
192192
size_limit=10;"#,
193+
r#"COPY INTO mytable
194+
FROM 'https://127.0.0.1:9900';"#,
195+
r#"COPY INTO mytable
196+
FROM 'https://127.0.0.1:';"#,
193197
r#"COPY INTO mytable
194198
FROM @my_stage
195199
FILE_FORMAT = (

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5600,6 +5600,78 @@ Copy(
56005600
)
56015601

56025602

5603+
---------- Input ----------
5604+
COPY INTO mytable
5605+
FROM 'https://127.0.0.1:9900';
5606+
---------- Output ---------
5607+
COPY INTO mytable FROM 'https://127.0.0.1:9900/' PURGE = false FORCE = false
5608+
---------- AST ------------
5609+
Copy(
5610+
CopyStmt {
5611+
src: UriLocation(
5612+
UriLocation {
5613+
protocol: "https",
5614+
name: "127.0.0.1:9900",
5615+
path: "/",
5616+
connection: {},
5617+
},
5618+
),
5619+
dst: Table {
5620+
catalog: None,
5621+
database: None,
5622+
table: Identifier {
5623+
name: "mytable",
5624+
quote: None,
5625+
span: Ident(10..17),
5626+
},
5627+
},
5628+
files: [],
5629+
pattern: "",
5630+
file_format: {},
5631+
validation_mode: "",
5632+
size_limit: 0,
5633+
purge: false,
5634+
force: false,
5635+
},
5636+
)
5637+
5638+
5639+
---------- Input ----------
5640+
COPY INTO mytable
5641+
FROM 'https://127.0.0.1:';
5642+
---------- Output ---------
5643+
COPY INTO mytable FROM 'https://127.0.0.1/' PURGE = false FORCE = false
5644+
---------- AST ------------
5645+
Copy(
5646+
CopyStmt {
5647+
src: UriLocation(
5648+
UriLocation {
5649+
protocol: "https",
5650+
name: "127.0.0.1",
5651+
path: "/",
5652+
connection: {},
5653+
},
5654+
),
5655+
dst: Table {
5656+
catalog: None,
5657+
database: None,
5658+
table: Identifier {
5659+
name: "mytable",
5660+
quote: None,
5661+
span: Ident(10..17),
5662+
},
5663+
},
5664+
files: [],
5665+
pattern: "",
5666+
file_format: {},
5667+
validation_mode: "",
5668+
size_limit: 0,
5669+
purge: false,
5670+
force: false,
5671+
},
5672+
)
5673+
5674+
56035675
---------- Input ----------
56045676
COPY INTO mytable
56055677
FROM @my_stage

0 commit comments

Comments
 (0)