[ 
https://issues.apache.org/jira/browse/BEAM-9896?focusedWorklogId=464733&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-464733
 ]

ASF GitHub Bot logged work on BEAM-9896:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 30/Jul/20 21:08
            Start Date: 30/Jul/20 21:08
    Worklog Time Spent: 10m 
      Work Description: pabloem commented on a change in pull request #12151:
URL: https://github.com/apache/beam/pull/12151#discussion_r463219932



##########
File path: 
sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java
##########
@@ -719,7 +906,9 @@ private void checkArguments() {
                           return getUserDataMapper().mapRow(element);
                         }
                       }))
-              .apply("Map Objects array to CSV lines", ParDo.of(new 
MapObjectsArrayToCsvFn()))
+              .apply(
+                  "Map Objects array to CSV lines",
+                  ParDo.of(new MapObjectsArrayToCsvFn(getQuotationMark())))

Review comment:
       that makes sense to me. Thanks Kasia!

##########
File path: 
sdks/java/io/snowflake/src/main/java/org/apache/beam/sdk/io/snowflake/SnowflakeIO.java
##########
@@ -684,14 +819,61 @@ private void checkArguments() {
           (getDataSourceProviderFn() != null),
           "withDataSourceConfiguration() or withDataSourceProviderFn() is 
required");
 
-      checkArgument(getTable() != null, "withTable() is required");
+      if (input.isBounded() == PCollection.IsBounded.UNBOUNDED) {
+        checkArgument(getSnowPipe() != null, "withSnowPipe() is required");
+      } else {
+        checkArgument(getTable() != null, "to() is required");
+      }
     }
 
-    private PCollection<String> write(PCollection<T> input, String 
stagingBucketDir) {
+    private PCollection<T> writeStream(PCollection<T> input, String 
stagingBucketDir) {
       SnowflakeService snowflakeService =
-          getSnowflakeService() != null ? getSnowflakeService() : new 
SnowflakeServiceImpl();
+          getSnowflakeService() != null
+              ? getSnowflakeService()
+              : new SnowflakeStreamingServiceImpl();
+
+      /* Ensure that files will be created after specific record count or 
duration specified */
+      PCollection<T> inputInGlobalWindow =
+          input.apply(
+              "rewindowIntoGlobal",
+              Window.<T>into(new GlobalWindows())
+                  .triggering(
+                      Repeatedly.forever(
+                          AfterFirst.of(
+                              AfterProcessingTime.pastFirstElementInPane()
+                                  .plusDelayOf(getFlushTimeLimit()),
+                              
AfterPane.elementCountAtLeast(getFlushRowLimit()))))
+                  .discardingFiredPanes());
+
+      int shards = (getShardsNumber() > 0) ? getShardsNumber() : 
DEFAULT_STREAMING_SHARDS_NUMBER;
+      PCollection files = writeFiles(inputInGlobalWindow, stagingBucketDir, 
shards);
+
+      /* Ensuring that files will be ingested after flush time */
+      files =
+          (PCollection)
+              files.apply(
+                  "applyUserTrigger",
+                  Window.<T>into(new GlobalWindows())
+                      .triggering(
+                          Repeatedly.forever(
+                              AfterProcessingTime.pastFirstElementInPane()
+                                  .plusDelayOf(getFlushTimeLimit())))
+                      .discardingFiredPanes());

Review comment:
       I think we can leave this as it is. I see that the trigger is not the 
exact same.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 464733)
    Time Spent: 4h  (was: 3h 50m)

> Add streaming for SnowflakeIO.Write to Java SDK
> -----------------------------------------------
>
>                 Key: BEAM-9896
>                 URL: https://issues.apache.org/jira/browse/BEAM-9896
>             Project: Beam
>          Issue Type: New Feature
>          Components: io-ideas
>            Reporter: Dariusz Aniszewski
>            Assignee: Kasia Kucharczyk
>            Priority: P2
>          Time Spent: 4h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to