Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ static Location setSchemeToFileIfAbsent(Location location)
if (location.scheme().isPresent()) {
return location;
}
return Location.of("file:///" + location.path());
return Location.of("file://@/" + location.path());
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This works for Location, but we still use Hadoop Path and it chokes on such locations.
In particular, AbstractTestHive.testBucketSortedTables / TestHiveFileMetastore.testBucketSortedTables fails

java.lang.IllegalArgumentException: Wrong FS: file://@/var/folders/dr/jhnfvsrd2zl925dyfsctj0pr0000gn/T/trino-staging-11857319125698218229/temp_path_, expected: file:///

	at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:831)
	at org.apache.hadoop.fs.RawLocalFileSystem.pathToFile(RawLocalFileSystem.java:119)
	at org.apache.hadoop.fs.RawLocalFileSystem.mkdirsWithOptionalPermission(RawLocalFileSystem.java:822)
	at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:808)
	at org.apache.hadoop.fs.ChecksumFileSystem.mkdirs(ChecksumFileSystem.java:997)
	at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:722)
	at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:709)
	at io.trino.hdfs.TrinoFileSystemCache$FileSystemWrapper.create(TrinoFileSystemCache.java:361)
	at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:1240)
	at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:1217)
	at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:1098)
	at io.trino.filesystem.hdfs.HdfsOutputFile.lambda$create$1(HdfsOutputFile.java:75)
	at io.trino.hdfs.authentication.NoHdfsAuthentication.doAs(NoHdfsAuthentication.java:25)
	at io.trino.hdfs.HdfsEnvironment.doAs(HdfsEnvironment.java:125)
	at io.trino.filesystem.hdfs.HdfsOutputFile.create(HdfsOutputFile.java:75)
	at io.trino.filesystem.hdfs.HdfsOutputFile.create(HdfsOutputFile.java:54)
	at io.trino.orc.OutputStreamOrcDataSink.create(OutputStreamOrcDataSink.java:41)
	at io.trino.plugin.hive.orc.OrcFileWriterFactory.createOrcDataSink(OrcFileWriterFactory.java:217)
	at io.trino.plugin.hive.SortingFileWriter.writeTempFile(SortingFileWriter.java:258)
	at io.trino.plugin.hive.SortingFileWriter.flushToTempFile(SortingFileWriter.java:201)
	at io.trino.plugin.hive.SortingFileWriter.appendRows(SortingFileWriter.java:125)
	at io.trino.plugin.hive.HiveWriter.append(HiveWriter.java:85)
	at io.trino.plugin.hive.HivePageSink.writePage(HivePageSink.java:346)
	at io.trino.plugin.hive.HivePageSink.doAppend(HivePageSink.java:297)
	at io.trino.plugin.hive.HivePageSink.lambda$appendPage$3(HivePageSink.java:285)
	at io.trino.hdfs.authentication.HdfsAuthentication.lambda$doAs$0(HdfsAuthentication.java:26)
	at io.trino.hdfs.authentication.NoHdfsAuthentication.doAs(NoHdfsAuthentication.java:25)
	at io.trino.hdfs.authentication.HdfsAuthentication.doAs(HdfsAuthentication.java:25)
	at io.trino.hdfs.HdfsEnvironment.doAs(HdfsEnvironment.java:130)
	at io.trino.plugin.hive.HivePageSink.appendPage(HivePageSink.java:285)
	at io.trino.plugin.hive.AbstractTestHive.doTestBucketSortedTables(AbstractTestHive.java:2868)
	at io.trino.plugin.hive.AbstractTestHive.testBucketSortedTables(AbstractTestHive.java:2813)

}

private static class DataColumn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void testSetsSchemeToFile()
{
String pathWithoutScheme = "/simple/file/path";
String result = setSchemeToFileIfAbsent(Location.of(pathWithoutScheme)).toString();
assertThat(result).isEqualTo("file:///simple/file/path");
assertThat(result).isEqualTo("file://@/simple/file/path");
URI resultUri = new Path(result).toUri();
assertThat(resultUri.getScheme()).isEqualTo("file");
assertThat(resultUri.getPath()).isEqualTo("/simple/file/path");
Expand All @@ -59,7 +59,7 @@ public void testSetsSchemeToFile()

String pathWithEmptySpaces = "/simple/file 1/path";
result = setSchemeToFileIfAbsent(Location.of(pathWithEmptySpaces)).toString();
assertThat(result).isEqualTo("file:///simple/file 1/path");
assertThat(result).isEqualTo("file://@/simple/file 1/path");
resultUri = new Path(result).toUri();
assertThat(resultUri.getScheme()).isEqualTo("file");
assertThat(resultUri.getPath()).isEqualTo("/simple/file 1/path");
Expand All @@ -70,5 +70,12 @@ public void testSetsSchemeToFile()
resultUri = new Path(result).toUri();
assertThat(resultUri.getScheme()).isEqualTo("s3");
assertThat(resultUri.getPath()).isEqualTo("/file 1/path");

String pathWithAtSign = "/tmp/user@example.com";
result = setSchemeToFileIfAbsent(Location.of(pathWithAtSign)).toString();
assertThat(result).isEqualTo("file://@/tmp/user@example.com");
resultUri = new Path(result).toUri();
assertThat(resultUri.getScheme()).isEqualTo("file");
assertThat(resultUri.getPath()).isEqualTo("/tmp/user@example.com");
}
}