You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by yh...@apache.org on 2024/07/11 14:23:51 UTC
(beam) branch master updated: Use fileNameTemplate attribute for file prefix (#31844)
This is an automated email from the ASF dual-hosted git repository.
yhu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push:
new 9ee961fc0c2 Use fileNameTemplate attribute for file prefix (#31844)
9ee961fc0c2 is described below
commit 9ee961fc0c2ca1e2f88a5e3847de98944c3553b3
Author: Vitaly Terentyev <vi...@akvelon.com>
AuthorDate: Thu Jul 11 18:23:43 2024 +0400
Use fileNameTemplate attribute for file prefix (#31844)
---
.../src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java b/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java
index 6fad4a89b63..b36b678c0a3 100644
--- a/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java
+++ b/sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java
@@ -1079,13 +1079,17 @@ public class SnowflakeIO {
ParDo.of(new MapObjectsArrayToCsvFn(getQuotationMark())))
.setCoder(StringUtf8Coder.of());
+ String filePrefix = getFileNameTemplate();
+ if (filePrefix == null) {
+ filePrefix = UUID.randomUUID().toString().subSequence(0, 8).toString();
+ }
WriteFilesResult<Void> filesResult =
mappedUserData.apply(
"Write files to specified location",
FileIO.<String>write()
.via(TextIO.sink())
.to(stagingBucketDir)
- .withPrefix(UUID.randomUUID().toString().subSequence(0, 8).toString())
+ .withPrefix(filePrefix)
.withSuffix(".csv")
.withNumShards(numShards)
.withCompression(Compression.GZIP));