Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1846830 allow triple slash file prefix (file:///) #2033

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
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 @@ -1881,7 +1881,7 @@ private void uploadFiles(Set<String> fileList, int parallel) throws SnowflakeSQL
threadExecutor.submit(
getUploadFileCallable(
stageInfo,
srcFile,
srcFileObj.getPath(),
fileMetadata,
(stageInfo.getStageType() == StageInfo.StageType.LOCAL_FS)
? null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.apache.commons.io.FileUtils;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

/** Tests for SnowflakeFileTransferAgent that require an active connection */
@Tag(TestTags.OTHERS)
Expand Down Expand Up @@ -885,4 +886,32 @@ public void testUploadWithTildeInPath() throws SQLException, IOException {
FileUtils.deleteDirectory(subDir.toFile());
}
}

@Test
public void testUploadWithTripleSlashFilePrefix(@TempDir File tempDir)
throws SQLException, IOException {
String stageName = "testStage" + SnowflakeUtil.randomAlphaNumeric(10);
try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
try {
statement.execute("CREATE OR REPLACE STAGE " + stageName);
SFSession sfSession = connection.unwrap(SnowflakeConnectionV1.class).getSfSession();

String command =
"PUT file:///" + getFullPathFileInResource(TEST_DATA_FILE) + " @" + stageName;
SnowflakeFileTransferAgent sfAgent =
new SnowflakeFileTransferAgent(command, sfSession, new SFStatement(sfSession));
assertTrue(sfAgent.execute());

String tempDirPath = tempDir.getCanonicalPath().replace("\\", "/");
String getCommand = "GET @" + stageName + " file:///" + tempDirPath;
SnowflakeFileTransferAgent sfAgent1 =
new SnowflakeFileTransferAgent(getCommand, sfSession, new SFStatement(sfSession));
assertTrue(sfAgent1.execute());
assertEquals(1, sfAgent1.statusRows.size());
} finally {
statement.execute("DROP STAGE if exists " + stageName);
}
}
}
}
Loading