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 9 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -1865,7 +1865,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 @@ -48,6 +48,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 @@ -871,4 +872,30 @@ public void testUploadWithTildeInPath() throws SQLException, IOException {
FileUtils.deleteDirectory(subDir.toFile());
}
}

@Test
public void testUploadWithTripleSlashFilePrefix(@TempDir Path tempDir) throws SQLException {
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 getCommand = "GET @" + stageName + " file://" + tempDir;
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