Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/query/ast/src/parser/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,8 +1425,14 @@ pub fn uri_location(i: Input) -> IResult<UriLocation> {
protocol: parsed.scheme().to_string(),
name: parsed
.host_str()
.ok_or(ErrorKind::Other("invalid uri location"))?
.to_string(),
.map(|hostname| {
if let Some(port) = parsed.port() {
format!("{}:{}", hostname, port)
} else {
hostname.to_string()
}
})
.ok_or(ErrorKind::Other("invalid uri location"))?,
path: if parsed.path().is_empty() {
"/".to_string()
} else {
Expand Down
4 changes: 4 additions & 0 deletions src/query/ast/tests/it/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ fn test_statement() {
skip_header = 1
)
size_limit=10;"#,
r#"COPY INTO mytable
FROM 'https://127.0.0.1:9900';"#,
r#"COPY INTO mytable
FROM 'https://127.0.0.1:';"#,
r#"COPY INTO mytable
FROM @my_stage
FILE_FORMAT = (
Expand Down
72 changes: 72 additions & 0 deletions src/query/ast/tests/it/testdata/statement.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5600,6 +5600,78 @@ Copy(
)


---------- Input ----------
COPY INTO mytable
FROM 'https://127.0.0.1:9900';
---------- Output ---------
COPY INTO mytable FROM 'https://127.0.0.1:9900/' PURGE = false FORCE = false
---------- AST ------------
Copy(
CopyStmt {
src: UriLocation(
UriLocation {
protocol: "https",
name: "127.0.0.1:9900",
path: "/",
connection: {},
},
),
dst: Table {
catalog: None,
database: None,
table: Identifier {
name: "mytable",
quote: None,
span: Ident(10..17),
},
},
files: [],
pattern: "",
file_format: {},
validation_mode: "",
size_limit: 0,
purge: false,
force: false,
},
)


---------- Input ----------
COPY INTO mytable
FROM 'https://127.0.0.1:';
---------- Output ---------
COPY INTO mytable FROM 'https://127.0.0.1/' PURGE = false FORCE = false
---------- AST ------------
Copy(
CopyStmt {
src: UriLocation(
UriLocation {
protocol: "https",
name: "127.0.0.1",
path: "/",
connection: {},
},
),
dst: Table {
catalog: None,
database: None,
table: Identifier {
name: "mytable",
quote: None,
span: Ident(10..17),
},
},
files: [],
pattern: "",
file_format: {},
validation_mode: "",
size_limit: 0,
purge: false,
force: false,
},
)


---------- Input ----------
COPY INTO mytable
FROM @my_stage
Expand Down