snowflake-jdbc icon indicating copy to clipboard operation
snowflake-jdbc copied to clipboard

PUT command should work with OutputStreams rather than InputStreams

Open markslater opened this issue 4 years ago • 2 comments

SnowflakeConnection.uploadStream facilitates "transfer[ring] data directly from a stream to an internal (i.e. Snowflake) stage as a file".

The signature is:

public void uploadStream(String stageName,
                         String destPrefix,
                         InputStream inputStream,
                         String destFileName,
                         boolean compressData)
    throws SQLException

An InputStream seems to be the wrong paradigm for writing to a stage - surely it should work with an OutputStream?

In fact, the use of InputStream causes practical problems. In the normal case where I have a data generator that expects to write to an OuputStream, in order to make it write to a Snowflake stage, I have to use PipedInputStream and PipedOutputStream, which in turn means I need to deal with threads.

Note that making the API work with OutputStreams doesn't cause friction for clients that have data coming from an InputStream, because InputStream offers the transferTo​(OutputStream out) method.

markslater avatar Aug 18 '21 19:08 markslater

Hi @markslater , changing the function signature from inputstream to outputstream could break existing customers. But do you want to submit a feature request to have another uploadStream() function that uses outputstream instead?

sfc-gh-mknister avatar Sep 17 '21 22:09 sfc-gh-mknister

Hi @sfc-gh-mknister, my take on it is that using an InputStream for writing data is a bug in the API. It's possible to work around the issue, but a workaround that involves threading is fairly onerous.

I appreciate that the fix would be a breaking change. My preference would be to grasp the nettle and fix the API, but it's your call. Let me know if you'd rather leave it as is, and I will submit a feature request for a new operation that uses an OutputStream.

markslater avatar Sep 20 '21 08:09 markslater

To clean up and re-prioritize more pressing bugs and feature requests we are closing all issues older than 6 months as of March 1, 2023. If there are any issues or feature requests that you would like us to address, please create them according to the new templates we have created. For urgent issues, opening a support case with this link Snowflake Community is the fastest way to get a response.

sfc-gh-igarish avatar Mar 15 '23 03:03 sfc-gh-igarish