Skip to content

Commit

Permalink
Merge pull request #7775 from ClSlaid/name-portless
Browse files Browse the repository at this point in the history
fix(parser): name scheme with port number
  • Loading branch information
mergify[bot] authored Sep 21, 2022
2 parents e92e1c4 + cc4b8e7 commit 86d742a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
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

1 comment on commit 86d742a

@vercel
Copy link

@vercel vercel bot commented on 86d742a Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

databend – ./

databend-databend.vercel.app
databend-git-main-databend.vercel.app
databend.rs
databend.vercel.app

Please sign in to comment.