Skip to content

Commit

Permalink
Added exception on unsupported uri schema.
Browse files Browse the repository at this point in the history
  • Loading branch information
pustovit committed Apr 13, 2015
1 parent 34e5b70 commit c8c7227
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Changes for Crate
Unreleased
==========

- Using unsupported URI schema in COPY FROM statement now results in an error.

- Fixed an issue with the LIKE predicate if used on a system table where it
wouldn't match if the content contains newline characters

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ public FileReadingCollector(String fileUri,
if (this.fileUri.getScheme().equals("file") && !this.fileUri.getSchemeSpecificPart().startsWith("///")) {
throw new IllegalArgumentException("Invalid fileURI");
}
if (!this.fileUri.getScheme().equals("file") && !this.fileUri.getScheme().equals("s3") ) {
throw new IllegalArgumentException("URI scheme is not supported");
}
}
this.downstream = downstream.registerUpstream(this);
this.compressed = compression != null && compression.equalsIgnoreCase("gzip");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ public void testCollectWithEmptyLine() throws Throwable {
assertCorrectResult(projector.result().get());
}

@Test
public void unsupportedURITest() throws Throwable {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("URI scheme is not supported");
getObjects("https://crate.io/docs/en/latest/sql/reference/copy_from.html");
}

private void assertCorrectResult(Bucket rows) throws Throwable {
Iterator<Row> it = rows.iterator();
assertThat(it.next(), isRow("{\"name\": \"Arthur\", \"id\": 4, \"details\": {\"age\": 38}}"));
Expand Down

0 comments on commit c8c7227

Please sign in to comment.