You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/10/19 22:20:48 UTC
[GitHub] [spark] HeartSaVioR opened a new pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
HeartSaVioR opened a new pull request #34333:
URL: https://github.com/apache/spark/pull/34333
### What changes were proposed in this pull request?
This PR proposes to introduce a new data source having short name as "rate-epoch", which produces similar input rows as "rate" (increment long values with timestamps), but ensures that each micro-batch has a "predictable" set of input rows.
Rate-epoch data source receives a config to specify the number of rows per epoch, which defines the set of input rows for further micro-batches. For example, if the number of rows per epoch is set to 1000, the first batch would have 1000 rows having value range as 0~999, the second batch would have 1000 rows having value range as 1000~1999, and so on. This characteristic brings different use cases compared to rate data source, as we can't predict the input rows for rate data source like this.
For generated time (timestamp column), the data source applies the same mechanism to make the value of column be predictable. `startTimestamp` option defines the starting value of generated time, and `advanceMillisPerEpoch` option defines how much time the generated time should advance per epoch. All input rows in the same micro-batch will have same timestamp.
This source supports the following options:
* `rowsPerEpoch` (e.g. 100): How many rows should be generated per epoch.
* `numPartitions` (e.g. 10, default: Spark's default parallelism): The partition number for the generated rows.
* `startTimestamp` (e.g. 1000, default: 0): starting value of generated time
* `advanceMillisPerEpoch` (e.g. 1000, default: 1000): the amount of time being advanced in generated time on each epoch.
### Why are the changes needed?
The "rate" data source has been known to be used as a benchmark for streaming query.
While this helps to put the query to the limit (how many rows the query could process per second), the rate data source doesn't provide consistent rows per batch into stream, which leads two environments be hard to compare with.
For example, in many cases, you may want to compare the metrics in the batches between test environments (like running same streaming query with different options). These metrics are strongly affected if the distribution of input rows in batches are changing, especially a micro-batch has been lagged (in any reason) and rate data source produces more input rows to the next batch.
Also, when you test against streaming aggregation, you may want the data source produces the same set of input rows per batch (deterministic), so that you can plan how these input rows will be aggregated and how state rows will be evicted, and craft the test query based on the plan.
### Does this PR introduce _any_ user-facing change?
Yes, end users can leverage a new data source in micro-batch mode of streaming query to test/benchmark.
### How was this patch tested?
New UTs, and manually tested via below query in spark-shell:
```
spark.readStream.format("rate-epoch").option("rowsPerEpoch", 20).option("numPartitions", 3).load().writeStream.format("console").start()
```
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947286747
**[Test build #144431 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144431/testReport)** for PR 34333 at commit [`affad64`](https://github.com/apache/spark/commit/affad642d9c6e587aead24b9718c9c1a093d2e53).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds the following public classes _(experimental)_:
* `class RatePerEpochMicroBatchStream(`
* `case class RatePerEpochStreamOffset(offset: Long, timestamp: Long) extends Offset `
* `case class RatePerEpochStreamMicroBatchInputPartition(`
* `class RatePerEpochStreamMicroBatchPartitionReader(`
* `class RatePerEpochProvider extends SimpleTableProvider with DataSourceRegister `
* `class RatePerEpochTable(`
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947180626
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48904/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948236461
**[Test build #144487 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144487/testReport)** for PR 34333 at commit [`0aec07a`](https://github.com/apache/spark/commit/0aec07a885d32b3222f7ae410bf3a809f55c35ac).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953758805
**[Test build #144697 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144697/testReport)** for PR 34333 at commit [`f1539cf`](https://github.com/apache/spark/commit/f1539cf3811d8adcb1bd9ba73352517e1e1b3166).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953598090
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49166/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r732391899
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
I mean we could have a separate implementation internally but externally I wonder if users would just prefer to set an option with single testing source.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953785177
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144697/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739938401
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchProvider.scala
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import java.util
+
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.connector.catalog.{SupportsRead, Table, TableCapability}
+import org.apache.spark.sql.connector.read.{Scan, ScanBuilder}
+import org.apache.spark.sql.connector.read.streaming.{ContinuousStream, MicroBatchStream}
+import org.apache.spark.sql.internal.connector.SimpleTableProvider
+import org.apache.spark.sql.sources.DataSourceRegister
+import org.apache.spark.sql.types.{LongType, StructField, StructType, TimestampType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+/**
+ * A source that generates increment long values with timestamps. Each generated row has two
+ * columns: a timestamp column for the generated time and an auto increment long column starting
+ * with 0L.
+ *
+ * This source supports the following options:
+ * - `rowsPerMicroBatch` (e.g. 100): How many rows should be generated per micro-batch.
+ * - `numPartitions` (e.g. 10, default: Spark's default parallelism): The partition number for the
+ * generated rows.
+ * - `startTimestamp` (e.g. 1000, default: 0): starting value of generated time
+ * - `advanceMillisPerMicroBatch` (e.g. 1000, default: 1000): the amount of time being advanced in
+ * generated time on each micro-batch.
+ *
+ * Unlike `rate` data source, this data source provides a consistent set of input rows per
+ * micro-batch regardless of query execution (configuration of trigger, query being lagging, etc.),
+ * say, batch 0 will produce 0~999 and batch 1 will produce 1000~1999, and so on. Same applies to
+ * the generated time.
+ *
+ * As the name represents, this data source only supports micro-batch read.
+ */
+class RatePerMicroBatchProvider extends SimpleTableProvider with DataSourceRegister {
+ import RatePerMicroBatchProvider._
+
+ override def getTable(options: CaseInsensitiveStringMap): Table = {
+ val rowsPerBatch = options.getLong(ROWS_PER_BATCH, 0)
Review comment:
No, the value in the classdoc is just an example. The option is "required" one - I just put default value of 0 here and make it fail because `getLong` requires default value.
There is no good default value for the option; I see rate source taking the default row per second as 1, but I doubt about the actual usage. Same for this option - end users will have a set of inputs for micro-batches in mind when using this data source, and the value heavily depends on the test workload. Instead of have a default value which could be far from the realistic, it seems clearer that we require the option and give error message to guide end users to set it when the option is not specified.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-956112008
**[Test build #144800 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144800/testReport)** for PR 34333 at commit [`cc48368`](https://github.com/apache/spark/commit/cc48368bbbb16873b707f0450e59a20127332ef2).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739956535
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchProvider.scala
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import java.util
+
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.connector.catalog.{SupportsRead, Table, TableCapability}
+import org.apache.spark.sql.connector.read.{Scan, ScanBuilder}
+import org.apache.spark.sql.connector.read.streaming.{ContinuousStream, MicroBatchStream}
+import org.apache.spark.sql.internal.connector.SimpleTableProvider
+import org.apache.spark.sql.sources.DataSourceRegister
+import org.apache.spark.sql.types.{LongType, StructField, StructType, TimestampType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+/**
+ * A source that generates increment long values with timestamps. Each generated row has two
+ * columns: a timestamp column for the generated time and an auto increment long column starting
+ * with 0L.
+ *
+ * This source supports the following options:
+ * - `rowsPerMicroBatch` (e.g. 100): How many rows should be generated per micro-batch.
+ * - `numPartitions` (e.g. 10, default: Spark's default parallelism): The partition number for the
+ * generated rows.
+ * - `startTimestamp` (e.g. 1000, default: 0): starting value of generated time
+ * - `advanceMillisPerMicroBatch` (e.g. 1000, default: 1000): the amount of time being advanced in
+ * generated time on each micro-batch.
+ *
+ * Unlike `rate` data source, this data source provides a consistent set of input rows per
+ * micro-batch regardless of query execution (configuration of trigger, query being lagging, etc.),
+ * say, batch 0 will produce 0~999 and batch 1 will produce 1000~1999, and so on. Same applies to
+ * the generated time.
+ *
+ * As the name represents, this data source only supports micro-batch read.
+ */
+class RatePerMicroBatchProvider extends SimpleTableProvider with DataSourceRegister {
+ import RatePerMicroBatchProvider._
+
+ override def getTable(options: CaseInsensitiveStringMap): Table = {
+ val rowsPerBatch = options.getLong(ROWS_PER_BATCH, 0)
Review comment:
Oh, I misread the 100 as default value.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947297384
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947297384
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r732402515
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
ah okay. I am fine. was just wondering.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953542267
**[Test build #144697 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144697/testReport)** for PR 34333 at commit [`f1539cf`](https://github.com/apache/spark/commit/f1539cf3811d8adcb1bd9ba73352517e1e1b3166).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953604674
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/49166/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953604674
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/49166/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953583243
@HeartSaVioR thanks for reminding. I will take a look in next few days.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739956802
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchStream.scala
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import org.json4s.NoTypeHints
+import org.json4s.jackson.Serialization
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.util.DateTimeUtils
+import org.apache.spark.sql.connector.read.{InputPartition, PartitionReader, PartitionReaderFactory}
+import org.apache.spark.sql.connector.read.streaming.{MicroBatchStream, Offset, ReadLimit, ReadMaxRows, SupportsAdmissionControl}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+class RatePerMicroBatchStream(
+ rowsPerBatch: Long,
+ numPartitions: Int,
+ startTimestamp: Long,
+ advanceMsPerBatch: Int,
+ options: CaseInsensitiveStringMap)
+ extends SupportsAdmissionControl with MicroBatchStream with Logging {
+
+ override def initialOffset(): Offset = RatePerMicroBatchStreamOffset(0L, startTimestamp)
+
+ override def latestOffset(): Offset = {
+ throw new UnsupportedOperationException(
+ "latestOffset(Offset, ReadLimit) should be called instead of this method")
+ }
+
+ override def getDefaultReadLimit: ReadLimit = {
+ ReadLimit.maxRows(rowsPerBatch)
+ }
+
+ private def extractOffsetAndTimestamp(offset: Offset): (Long, Long) = {
+ offset match {
+ case o: RatePerMicroBatchStreamOffset => (o.offset, o.timestamp)
+ case _ => throw new IllegalStateException("The type of Offset should be " +
+ "RatePerMicroBatchStreamOffset")
+ }
+ }
+
+ override def latestOffset(startOffset: Offset, limit: ReadLimit): Offset = {
+ val (startOffsetLong, timestampAtStartOffset) = extractOffsetAndTimestamp(startOffset)
+ val numRows = limit.asInstanceOf[ReadMaxRows].maxRows()
+
+ val endOffsetLong = Math.min(startOffsetLong + numRows, Long.MaxValue)
+ val endOffset = RatePerMicroBatchStreamOffset(endOffsetLong,
+ timestampAtStartOffset + advanceMsPerBatch)
+
+ endOffset
+ }
+
+ override def deserializeOffset(json: String): Offset = {
+ RatePerMicroBatchStreamOffset.apply(json)
+ }
+
+ override def planInputPartitions(start: Offset, end: Offset): Array[InputPartition] = {
+ val (startOffset, startTimestamp) = extractOffsetAndTimestamp(start)
+ val (endOffset, endTimestamp) = extractOffsetAndTimestamp(end)
+
+ assert(startOffset <= endOffset, s"startOffset($startOffset) > endOffset($endOffset)")
+ assert(startTimestamp <= endTimestamp,
+ s"startTimestamp($startTimestamp) > endTimestamp($endTimestamp)")
+ logDebug(s"startOffset: $startOffset, startTimestamp: $startTimestamp, " +
+ s"endOffset: $endOffset, endTimestamp: $endTimestamp")
+
+ if (startOffset == endOffset) {
+ Array.empty
+ } else {
+ (0 until numPartitions).map { p =>
+ RatePerMicroBatchStreamInputPartition(p, numPartitions, startOffset,
+ startTimestamp, endOffset, endTimestamp)
+ }.toArray
+ }
+ }
+
+ override def createReaderFactory(): PartitionReaderFactory = {
+ RatePerMicroBatchStreamReaderFactory
+ }
+
+ override def commit(end: Offset): Unit = {}
+
+ override def stop(): Unit = {}
+
+ override def toString: String = s"RatePerMicroBatchStream[rowsPerBatch=$rowsPerBatch, " +
+ s"numPartitions=$numPartitions, startTimestamp=$startTimestamp, " +
+ s"advanceMsPerBatch=$advanceMsPerBatch]"
+}
+
+case class RatePerMicroBatchStreamOffset(offset: Long, timestamp: Long) extends Offset {
+ override def json(): String = {
+ Serialization.write(this)(RatePerMicroBatchStreamOffset.formats)
+ }
+}
+
+object RatePerMicroBatchStreamOffset {
+ implicit val formats = Serialization.formats(NoTypeHints)
+
+ def apply(json: String): RatePerMicroBatchStreamOffset =
+ Serialization.read[RatePerMicroBatchStreamOffset](json)
+}
+
+case class RatePerMicroBatchStreamInputPartition(
+ partitionId: Int,
+ numPartitions: Int,
+ startOffset: Long,
+ startTimestamp: Long,
+ endOffset: Long,
+ endTimestamp: Long) extends InputPartition
+
+object RatePerMicroBatchStreamReaderFactory extends PartitionReaderFactory {
+ override def createReader(partition: InputPartition): PartitionReader[InternalRow] = {
+ val p = partition.asInstanceOf[RatePerMicroBatchStreamInputPartition]
+ new RatePerMicroBatchStreamPartitionReader(p.partitionId, p.numPartitions,
+ p.startOffset, p.startTimestamp, p.endOffset, p.endTimestamp)
+ }
+}
+
+class RatePerMicroBatchStreamPartitionReader(
+ partitionId: Int,
+ numPartitions: Int,
+ startOffset: Long,
+ startTimestamp: Long,
+ endOffset: Long,
+ endTimestamp: Long) extends PartitionReader[InternalRow] {
Review comment:
Ok.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739945169
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchStream.scala
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import org.json4s.NoTypeHints
+import org.json4s.jackson.Serialization
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.util.DateTimeUtils
+import org.apache.spark.sql.connector.read.{InputPartition, PartitionReader, PartitionReaderFactory}
+import org.apache.spark.sql.connector.read.streaming.{MicroBatchStream, Offset, ReadLimit, ReadMaxRows, SupportsAdmissionControl}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+class RatePerMicroBatchStream(
+ rowsPerBatch: Long,
+ numPartitions: Int,
+ startTimestamp: Long,
+ advanceMsPerBatch: Int,
+ options: CaseInsensitiveStringMap)
+ extends SupportsAdmissionControl with MicroBatchStream with Logging {
+
+ override def initialOffset(): Offset = RatePerMicroBatchStreamOffset(0L, startTimestamp)
+
+ override def latestOffset(): Offset = {
+ throw new UnsupportedOperationException(
+ "latestOffset(Offset, ReadLimit) should be called instead of this method")
+ }
+
+ override def getDefaultReadLimit: ReadLimit = {
+ ReadLimit.maxRows(rowsPerBatch)
+ }
+
+ private def extractOffsetAndTimestamp(offset: Offset): (Long, Long) = {
+ offset match {
+ case o: RatePerMicroBatchStreamOffset => (o.offset, o.timestamp)
+ case _ => throw new IllegalStateException("The type of Offset should be " +
+ "RatePerMicroBatchStreamOffset")
+ }
+ }
+
+ override def latestOffset(startOffset: Offset, limit: ReadLimit): Offset = {
Review comment:
> We cannot change the limit for this data source
The data source doesn't provide such option, but Spark will pass ReadLimit.allAvailable() when the trigger is either Once or AvailableNow.
That said, I think you found the bug. I missed to handle these triggers. Not sure what is the desired behavior for these triggers, though. Probably simply providing a set of inputs for a single batch is acceptable.
I'll fix it. Thanks!
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-956114960
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144800/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-955997111
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/49270/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947160485
**[Test build #144432 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144432/testReport)** for PR 34333 at commit [`2534675`](https://github.com/apache/spark/commit/25346756c4766edb1c4d8677c558936de5e60682).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR edited a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR edited a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947166060
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947180992
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48905/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947211616
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947587953
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48928/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948394208
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144487/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947158829
**[Test build #144431 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144431/testReport)** for PR 34333 at commit [`affad64`](https://github.com/apache/spark/commit/affad642d9c6e587aead24b9718c9c1a093d2e53).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947701925
**[Test build #144455 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144455/testReport)** for PR 34333 at commit [`850548d`](https://github.com/apache/spark/commit/850548d182ba5e0127831704f4ab6b75fbba95f9).
* This patch **fails Spark unit tests**.
* This patch merges cleanly.
* This patch adds the following public classes _(experimental)_:
* `class RatePerMicroBatchProvider extends SimpleTableProvider with DataSourceRegister `
* `class RatePerMicroBatchTable(`
* `class RatePerMicroBatchStream(`
* `case class RatePerMicroBatchStreamOffset(offset: Long, timestamp: Long) extends Offset `
* `case class RatePerMicroBatchStreamInputPartition(`
* `class RatePerMicroBatchStreamPartitionReader(`
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739943400
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchProvider.scala
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import java.util
+
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.connector.catalog.{SupportsRead, Table, TableCapability}
+import org.apache.spark.sql.connector.read.{Scan, ScanBuilder}
+import org.apache.spark.sql.connector.read.streaming.{ContinuousStream, MicroBatchStream}
+import org.apache.spark.sql.internal.connector.SimpleTableProvider
+import org.apache.spark.sql.sources.DataSourceRegister
+import org.apache.spark.sql.types.{LongType, StructField, StructType, TimestampType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+/**
+ * A source that generates increment long values with timestamps. Each generated row has two
+ * columns: a timestamp column for the generated time and an auto increment long column starting
+ * with 0L.
+ *
+ * This source supports the following options:
+ * - `rowsPerMicroBatch` (e.g. 100): How many rows should be generated per micro-batch.
+ * - `numPartitions` (e.g. 10, default: Spark's default parallelism): The partition number for the
+ * generated rows.
+ * - `startTimestamp` (e.g. 1000, default: 0): starting value of generated time
+ * - `advanceMillisPerMicroBatch` (e.g. 1000, default: 1000): the amount of time being advanced in
+ * generated time on each micro-batch.
+ *
+ * Unlike `rate` data source, this data source provides a consistent set of input rows per
+ * micro-batch regardless of query execution (configuration of trigger, query being lagging, etc.),
+ * say, batch 0 will produce 0~999 and batch 1 will produce 1000~1999, and so on. Same applies to
+ * the generated time.
+ *
+ * As the name represents, this data source only supports micro-batch read.
+ */
+class RatePerMicroBatchProvider extends SimpleTableProvider with DataSourceRegister {
+ import RatePerMicroBatchProvider._
+
+ override def getTable(options: CaseInsensitiveStringMap): Table = {
+ val rowsPerBatch = options.getLong(ROWS_PER_BATCH, 0)
+ if (rowsPerBatch <= 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$rowsPerBatch'. The option 'rowsPerBatch' must be positive")
+ }
+
+ val numPartitions = options.getInt(
+ NUM_PARTITIONS, SparkSession.active.sparkContext.defaultParallelism)
+ if (numPartitions <= 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$numPartitions'. The option 'numPartitions' must be positive")
+ }
+
+ val startTimestamp = options.getLong(START_TIMESTAMP, 0)
+ if (startTimestamp < 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$startTimestamp'. The option 'startTimestamp' must be non-negative")
+ }
+
+ val advanceMillisPerBatch = options.getInt(ADVANCE_MILLIS_PER_BATCH, 1000)
+ if (advanceMillisPerBatch < 0) {
Review comment:
Technically it doesn't have any limitation. It can even be negative, though I can't think of the cases leveraging this.
The reason I validate the value here is that I just wanted to block the case where the timestamp goes negative and keeps decreasing (the lower limit is startTimestamp = 0, advanceMillisPerBatch = 0). Having advanceMillisPerBatch = 0 doesn't lead to such issue, it just sticks the event time for all inputs across micro-batches.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-955994926
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49270/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739885766
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchProvider.scala
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import java.util
+
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.connector.catalog.{SupportsRead, Table, TableCapability}
+import org.apache.spark.sql.connector.read.{Scan, ScanBuilder}
+import org.apache.spark.sql.connector.read.streaming.{ContinuousStream, MicroBatchStream}
+import org.apache.spark.sql.internal.connector.SimpleTableProvider
+import org.apache.spark.sql.sources.DataSourceRegister
+import org.apache.spark.sql.types.{LongType, StructField, StructType, TimestampType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+/**
+ * A source that generates increment long values with timestamps. Each generated row has two
+ * columns: a timestamp column for the generated time and an auto increment long column starting
+ * with 0L.
+ *
+ * This source supports the following options:
+ * - `rowsPerMicroBatch` (e.g. 100): How many rows should be generated per micro-batch.
+ * - `numPartitions` (e.g. 10, default: Spark's default parallelism): The partition number for the
+ * generated rows.
+ * - `startTimestamp` (e.g. 1000, default: 0): starting value of generated time
+ * - `advanceMillisPerMicroBatch` (e.g. 1000, default: 1000): the amount of time being advanced in
+ * generated time on each micro-batch.
+ *
+ * Unlike `rate` data source, this data source provides a consistent set of input rows per
+ * micro-batch regardless of query execution (configuration of trigger, query being lagging, etc.),
+ * say, batch 0 will produce 0~999 and batch 1 will produce 1000~1999, and so on. Same applies to
+ * the generated time.
+ *
+ * As the name represents, this data source only supports micro-batch read.
+ */
+class RatePerMicroBatchProvider extends SimpleTableProvider with DataSourceRegister {
+ import RatePerMicroBatchProvider._
+
+ override def getTable(options: CaseInsensitiveStringMap): Table = {
+ val rowsPerBatch = options.getLong(ROWS_PER_BATCH, 0)
Review comment:
I thought the default is 100?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-956065017
I just reran GA build: https://github.com/HeartSaVioR/spark/actions/runs/1406673937
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947197843
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48905/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947502952
**[Test build #144455 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144455/testReport)** for PR 34333 at commit [`850548d`](https://github.com/apache/spark/commit/850548d182ba5e0127831704f4ab6b75fbba95f9).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947166060
cc. @zsxwing @viirya @xuanyuanking
This data source helps to test out the performance aspect on adjusting options (POC yet) for RocksDB state store provider. Say, you can run the streaming query twice, with different options, and it's valid to compare the metrics of micro-batches between the two as they would have same inputs. Previously it has been only possible from Kafka data source with pre-ingesting data.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947587953
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48928/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948236461
**[Test build #144487 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144487/testReport)** for PR 34333 at commit [`0aec07a`](https://github.com/apache/spark/commit/0aec07a885d32b3222f7ae410bf3a809f55c35ac).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739957267
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
The name of data source looks okay to me.
Maybe you can copy some wordings from the java doc here too, e.g., "Unlike `rate` data source, this data source provides a consistent set of input rows ...".
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-956135601
Thanks! Merging to master.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739939842
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchStream.scala
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import org.json4s.NoTypeHints
+import org.json4s.jackson.Serialization
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.util.DateTimeUtils
+import org.apache.spark.sql.connector.read.{InputPartition, PartitionReader, PartitionReaderFactory}
+import org.apache.spark.sql.connector.read.streaming.{MicroBatchStream, Offset, ReadLimit, ReadMaxRows, SupportsAdmissionControl}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+class RatePerMicroBatchStream(
+ rowsPerBatch: Long,
+ numPartitions: Int,
+ startTimestamp: Long,
+ advanceMsPerBatch: Int,
+ options: CaseInsensitiveStringMap)
+ extends SupportsAdmissionControl with MicroBatchStream with Logging {
+
+ override def initialOffset(): Offset = RatePerMicroBatchStreamOffset(0L, startTimestamp)
+
+ override def latestOffset(): Offset = {
+ throw new UnsupportedOperationException(
+ "latestOffset(Offset, ReadLimit) should be called instead of this method")
+ }
+
+ override def getDefaultReadLimit: ReadLimit = {
+ ReadLimit.maxRows(rowsPerBatch)
+ }
+
+ private def extractOffsetAndTimestamp(offset: Offset): (Long, Long) = {
+ offset match {
+ case o: RatePerMicroBatchStreamOffset => (o.offset, o.timestamp)
+ case _ => throw new IllegalStateException("The type of Offset should be " +
+ "RatePerMicroBatchStreamOffset")
+ }
+ }
+
+ override def latestOffset(startOffset: Offset, limit: ReadLimit): Offset = {
+ val (startOffsetLong, timestampAtStartOffset) = extractOffsetAndTimestamp(startOffset)
+ val numRows = limit.asInstanceOf[ReadMaxRows].maxRows()
+
+ val endOffsetLong = Math.min(startOffsetLong + numRows, Long.MaxValue)
+ val endOffset = RatePerMicroBatchStreamOffset(endOffsetLong,
+ timestampAtStartOffset + advanceMsPerBatch)
+
+ endOffset
+ }
+
+ override def deserializeOffset(json: String): Offset = {
+ RatePerMicroBatchStreamOffset.apply(json)
+ }
+
+ override def planInputPartitions(start: Offset, end: Offset): Array[InputPartition] = {
+ val (startOffset, startTimestamp) = extractOffsetAndTimestamp(start)
+ val (endOffset, endTimestamp) = extractOffsetAndTimestamp(end)
+
+ assert(startOffset <= endOffset, s"startOffset($startOffset) > endOffset($endOffset)")
+ assert(startTimestamp <= endTimestamp,
+ s"startTimestamp($startTimestamp) > endTimestamp($endTimestamp)")
+ logDebug(s"startOffset: $startOffset, startTimestamp: $startTimestamp, " +
+ s"endOffset: $endOffset, endTimestamp: $endTimestamp")
+
+ if (startOffset == endOffset) {
+ Array.empty
+ } else {
+ (0 until numPartitions).map { p =>
+ RatePerMicroBatchStreamInputPartition(p, numPartitions, startOffset,
+ startTimestamp, endOffset, endTimestamp)
+ }.toArray
+ }
+ }
+
+ override def createReaderFactory(): PartitionReaderFactory = {
+ RatePerMicroBatchStreamReaderFactory
+ }
+
+ override def commit(end: Offset): Unit = {}
+
+ override def stop(): Unit = {}
+
+ override def toString: String = s"RatePerMicroBatchStream[rowsPerBatch=$rowsPerBatch, " +
+ s"numPartitions=$numPartitions, startTimestamp=$startTimestamp, " +
+ s"advanceMsPerBatch=$advanceMsPerBatch]"
+}
+
+case class RatePerMicroBatchStreamOffset(offset: Long, timestamp: Long) extends Offset {
+ override def json(): String = {
+ Serialization.write(this)(RatePerMicroBatchStreamOffset.formats)
+ }
+}
+
+object RatePerMicroBatchStreamOffset {
+ implicit val formats = Serialization.formats(NoTypeHints)
+
+ def apply(json: String): RatePerMicroBatchStreamOffset =
+ Serialization.read[RatePerMicroBatchStreamOffset](json)
+}
+
+case class RatePerMicroBatchStreamInputPartition(
+ partitionId: Int,
+ numPartitions: Int,
+ startOffset: Long,
+ startTimestamp: Long,
+ endOffset: Long,
+ endTimestamp: Long) extends InputPartition
+
+object RatePerMicroBatchStreamReaderFactory extends PartitionReaderFactory {
+ override def createReader(partition: InputPartition): PartitionReader[InternalRow] = {
+ val p = partition.asInstanceOf[RatePerMicroBatchStreamInputPartition]
+ new RatePerMicroBatchStreamPartitionReader(p.partitionId, p.numPartitions,
+ p.startOffset, p.startTimestamp, p.endOffset, p.endTimestamp)
+ }
+}
+
+class RatePerMicroBatchStreamPartitionReader(
+ partitionId: Int,
+ numPartitions: Int,
+ startOffset: Long,
+ startTimestamp: Long,
+ endOffset: Long,
+ endTimestamp: Long) extends PartitionReader[InternalRow] {
Review comment:
Yes, actually I thought about gradual increasing of timestamp even in same micro-batch, but decided to make it simple and add if someone claims with good use cases. I'll remove the unused parameter for now.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948276126
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48959/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948271810
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48959/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948255095
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48959/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-955951266
**[Test build #144800 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144800/testReport)** for PR 34333 at commit [`cc48368`](https://github.com/apache/spark/commit/cc48368bbbb16873b707f0450e59a20127332ef2).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR closed pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR closed pull request #34333:
URL: https://github.com/apache/spark/pull/34333
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947211616
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947198480
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48904/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r732395419
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
The set of available options between rate source and rate-epoch source are different, like, `rampUpTime` is only valid for rate source, whereas `startTimestamp` and `advanceMillisPerEpoch` are only valid for rate-epoch source.
So if we have a unified data source (mix up `rate-epoch` into current `rate`), then there will be two sets of options, which defines the behavior, which IMHO is confusing.
Could we please enumerate the upside of adding this as different mode of rate source?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r732465606
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -588,6 +590,17 @@ Here are the details of all the sources in Spark.
<td>Yes</td>
<td></td>
</tr>
+ <tr>
+ <td><b>Rate Per Epoch Source</b></td>
Review comment:
Yeah actually I thought of introducing this to continuous mode as well (the word `epoch` has been used to mention about the specific boundary across modes), but realized the DSv2 writer API doesn't give an enough information to determine the current epoch, hence micro-batch only now. No rationalization to use epoch now.
I'll rename everywhere from epoch to micro-batch; simply using `batch` might give confusion between on batch query vs micro-batch. Thanks!
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-956114960
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144800/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739885874
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchProvider.scala
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import java.util
+
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.connector.catalog.{SupportsRead, Table, TableCapability}
+import org.apache.spark.sql.connector.read.{Scan, ScanBuilder}
+import org.apache.spark.sql.connector.read.streaming.{ContinuousStream, MicroBatchStream}
+import org.apache.spark.sql.internal.connector.SimpleTableProvider
+import org.apache.spark.sql.sources.DataSourceRegister
+import org.apache.spark.sql.types.{LongType, StructField, StructType, TimestampType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+/**
+ * A source that generates increment long values with timestamps. Each generated row has two
+ * columns: a timestamp column for the generated time and an auto increment long column starting
+ * with 0L.
+ *
+ * This source supports the following options:
+ * - `rowsPerMicroBatch` (e.g. 100): How many rows should be generated per micro-batch.
+ * - `numPartitions` (e.g. 10, default: Spark's default parallelism): The partition number for the
+ * generated rows.
+ * - `startTimestamp` (e.g. 1000, default: 0): starting value of generated time
+ * - `advanceMillisPerMicroBatch` (e.g. 1000, default: 1000): the amount of time being advanced in
+ * generated time on each micro-batch.
+ *
+ * Unlike `rate` data source, this data source provides a consistent set of input rows per
+ * micro-batch regardless of query execution (configuration of trigger, query being lagging, etc.),
+ * say, batch 0 will produce 0~999 and batch 1 will produce 1000~1999, and so on. Same applies to
+ * the generated time.
+ *
+ * As the name represents, this data source only supports micro-batch read.
+ */
+class RatePerMicroBatchProvider extends SimpleTableProvider with DataSourceRegister {
+ import RatePerMicroBatchProvider._
+
+ override def getTable(options: CaseInsensitiveStringMap): Table = {
+ val rowsPerBatch = options.getLong(ROWS_PER_BATCH, 0)
+ if (rowsPerBatch <= 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$rowsPerBatch'. The option 'rowsPerBatch' must be positive")
+ }
+
+ val numPartitions = options.getInt(
+ NUM_PARTITIONS, SparkSession.active.sparkContext.defaultParallelism)
+ if (numPartitions <= 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$numPartitions'. The option 'numPartitions' must be positive")
+ }
+
+ val startTimestamp = options.getLong(START_TIMESTAMP, 0)
+ if (startTimestamp < 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$startTimestamp'. The option 'startTimestamp' must be non-negative")
+ }
+
+ val advanceMillisPerBatch = options.getInt(ADVANCE_MILLIS_PER_BATCH, 1000)
+ if (advanceMillisPerBatch < 0) {
Review comment:
Can `advanceMillisPerBatch` be zero?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739884857
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
This is also what comes to my mind of the first glance at the PR description. But the reasoning here seems okay too.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739885325
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
A little concern about the confusion between "rate" and "rate per micro-batch". For original "rate" data source, "Generates data at the specified number of rows per second," it sounds like the rate of data generation is fixed, so mostly it makes the assumption that the number of rows per micro-batch is the same or close. Could we put some wordings into "rate" or "rate per micro-batch" that clarifies the difference for end-users?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] xuanyuanking commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
xuanyuanking commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r736719970
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchProvider.scala
##########
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import java.util
+
+import org.apache.spark.sql.SparkSession
+import org.apache.spark.sql.connector.catalog.{SupportsRead, Table, TableCapability}
+import org.apache.spark.sql.connector.read.{Scan, ScanBuilder}
+import org.apache.spark.sql.connector.read.streaming.{ContinuousStream, MicroBatchStream}
+import org.apache.spark.sql.internal.connector.SimpleTableProvider
+import org.apache.spark.sql.sources.DataSourceRegister
+import org.apache.spark.sql.types.{LongType, StructField, StructType, TimestampType}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+/**
+ * A source that generates increment long values with timestamps. Each generated row has two
+ * columns: a timestamp column for the generated time and an auto increment long column starting
+ * with 0L.
+ *
+ * This source supports the following options:
+ * - `rowsPerMicroBatch` (e.g. 100): How many rows should be generated per micro-batch.
+ * - `numPartitions` (e.g. 10, default: Spark's default parallelism): The partition number for the
+ * generated rows.
+ * - `startTimestamp` (e.g. 1000, default: 0): starting value of generated time
+ * - `advanceMillisPerMicroBatch` (e.g. 1000, default: 1000): the amount of time being advanced in
+ * generated time on each micro-batch.
+ *
+ * Unlike `rate` data source, this data source provides a consistent set of input rows per
+ * micro-batch regardless of query execution (configuration of trigger, query being lagging, etc.),
+ * say, batch 0 will produce 0~999 and batch 1 will produce 1000~1999, and so on. Same applies to
+ * the generated time.
+ *
+ * As the name represents, this data source only supports micro-batch read.
+ */
+class RatePerMicroBatchProvider extends SimpleTableProvider with DataSourceRegister {
+ import RatePerMicroBatchProvider._
+
+ override def getTable(options: CaseInsensitiveStringMap): Table = {
+ val rowsPerBatch = options.getLong(ROWS_PER_BATCH, 0)
+ if (rowsPerBatch <= 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$rowsPerBatch'. The option 'rowsPerBatch' must be positive")
+ }
+
+ val numPartitions = options.getInt(
+ NUM_PARTITIONS, SparkSession.active.sparkContext.defaultParallelism)
+ if (numPartitions <= 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$numPartitions'. The option 'numPartitions' must be positive")
+ }
+
+ val startTimestamp = options.getLong(START_TIMESTAMP, 0)
+ if (startTimestamp < 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$startTimestamp'. The option 'startTimestamp' must be non-negative")
+ }
+
+ val advanceMillisPerBatch = options.getInt(ADVANCE_MILLIS_PER_BATCH, 1000)
+ if (advanceMillisPerBatch < 0) {
+ throw new IllegalArgumentException(
+ s"Invalid value '$advanceMillisPerBatch'. The option 'advanceMillisPerBatch' " +
+ "must be non-negative")
+ }
+
+ new RatePerMicroBatchTable(rowsPerBatch, numPartitions, startTimestamp,
+ advanceMillisPerBatch)
+ }
+
+ override def shortName(): String = "rate-micro-batch"
+}
+
+class RatePerMicroBatchTable(
+ rowsPerBatch: Long,
+ numPartitions: Int,
+ startTimestamp: Long,
+ advanceMillisPerBatch: Int) extends Table with SupportsRead {
+ override def name(): String = {
+ s"RatePerEpoch(rowsPerBatch=$rowsPerBatch, numPartitions=$numPartitions," +
Review comment:
nit: RatePerMicroBatch?
##########
File path: sql/core/src/test/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchProviderSuite.scala
##########
@@ -0,0 +1,141 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import org.apache.spark.sql.execution.datasources.DataSource
+import org.apache.spark.sql.functions.spark_partition_id
+import org.apache.spark.sql.streaming.{StreamTest, Trigger}
+import org.apache.spark.sql.streaming.util.StreamManualClock
+
+class RatePerMicroBatchProviderSuite extends StreamTest {
+
+ import testImplicits._
+
+ test("RatePerMicroBatchProvider in registry") {
+ val ds = DataSource.lookupDataSource("rate-micro-batch", spark.sqlContext.conf).newInstance()
+ assert(ds.isInstanceOf[RatePerMicroBatchProvider], "Could not find rate-micro-batch source")
+ }
+
+ test("basic") {
+ val input = spark.readStream
+ .format("rate-micro-batch")
+ .option("rowsPerBatch", "10")
+ .option("startTimestamp", "1000")
+ .option("advanceMillisPerBatch", "50")
+ .load()
+ val clock = new StreamManualClock
+ testStream(input)(
+ StartStream(trigger = Trigger.ProcessingTime(10), triggerClock = clock),
+ AdvanceManualClock(10),
+ CheckLastBatch((0 until 10).map(v => new java.sql.Timestamp(1000L) -> v): _*),
+ AdvanceManualClock(10),
+ CheckLastBatch((10 until 20).map(v => new java.sql.Timestamp(1050L) -> v): _*),
+ AdvanceManualClock(10),
+ CheckLastBatch((20 until 30).map(v => new java.sql.Timestamp(1100L) -> v): _*)
+ )
+ }
+
+ test("restart") {
+ withTempDir { dir =>
+ val input = spark.readStream
+ .format("rate-micro-batch")
+ .option("rowsPerBatch", "10")
+ .load()
+ .select('value)
+
+ testStream(input)(
+ StartStream(checkpointLocation = dir.getAbsolutePath),
+ Execute(_.awaitOffset(0, RatePerMicroBatchStreamOffset(20, 2000),
+ streamingTimeout.toMillis)),
+ CheckAnswer(0 until 20: _*),
+ StopStream
+ )
+
+ testStream(input)(
+ StartStream(checkpointLocation = dir.getAbsolutePath),
+ Execute(_.awaitOffset(0, RatePerMicroBatchStreamOffset(40, 4000),
+ streamingTimeout.toMillis)),
+ CheckAnswer(20 until 40: _*)
+ )
+ }
+ }
+
+ test("numPartitions") {
+ val input = spark.readStream
+ .format("rate-micro-batch")
+ .option("rowsPerBatch", "10")
+ .option("numPartitions", "6")
+ .load()
+ .select(spark_partition_id())
+ .distinct()
+ val clock = new StreamManualClock
+ testStream(input)(
+ StartStream(trigger = Trigger.ProcessingTime(10), triggerClock = clock),
+ AdvanceManualClock(10),
+ CheckLastBatch(0 until 6: _*)
+ )
+ }
+
+ testQuietly("illegal option values") {
+ def testIllegalOptionValue(
+ option: String,
+ value: String,
+ expectedMessages: Seq[String]): Unit = {
+ val e = intercept[IllegalArgumentException] {
+ var stream = spark.readStream
+ .format("rate-micro-batch")
+ .option(option, value)
+
+ if (option != "rowsPerBatch") {
+ stream = stream.option("rowsPerBatch", "1")
+ }
+
+ stream.load()
+ .writeStream
+ .format("console")
+ .start()
+ .awaitTermination()
+ }
+ for (msg <- expectedMessages) {
+ assert(e.getMessage.contains(msg))
+ }
+ }
+
+ testIllegalOptionValue("rowsPerBatch", "-1", Seq("-1", "rowsPerBatch", "positive"))
+ testIllegalOptionValue("rowsPerBatch", "0", Seq("0", "rowsPerBatch", "positive"))
+ testIllegalOptionValue("numPartitions", "-1", Seq("-1", "numPartitions", "positive"))
+ testIllegalOptionValue("numPartitions", "0", Seq("0", "numPartitions", "positive"))
+
+ // RatePerEpochProvider allows setting below options to 0
Review comment:
ditto
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953541345
@xuanyuanking Thanks! I addressed your review comments.
@zsxwing @viirya Friendly reminder.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953785177
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144697/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947285705
**[Test build #144432 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144432/testReport)** for PR 34333 at commit [`2534675`](https://github.com/apache/spark/commit/25346756c4766edb1c4d8677c558936de5e60682).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947160485
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r732391703
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
qq: should we just have an option instead of adding a new source?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953542267
**[Test build #144697 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144697/testReport)** for PR 34333 at commit [`f1539cf`](https://github.com/apache/spark/commit/f1539cf3811d8adcb1bd9ba73352517e1e1b3166).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-955969220
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49270/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739946197
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
I'd love to address it, but honestly I have no idea other than below representation:
* rate: Generates data at the specified number of rows per second
* rate per micro-batch: Generates data at the specified number of rows per micro-batch
Specified number of rows "per XXX" says the specified number of rows will be presented per XXX, so the main point they should check is the unit (per XXX). "per second" vs "per micro-batch" doesn't seem to make confusion IMHO.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739946496
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
I'm open to alternative names for the data source as well. Picking up "rate" seems to be culprit, but I can't think of alternative names.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947502952
**[Test build #144455 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144455/testReport)** for PR 34333 at commit [`850548d`](https://github.com/apache/spark/commit/850548d182ba5e0127831704f4ab6b75fbba95f9).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947548344
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48928/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947587916
Kubernetes integration test status failure
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/48928/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947735165
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144455/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948392566
**[Test build #144487 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144487/testReport)** for PR 34333 at commit [`0aec07a`](https://github.com/apache/spark/commit/0aec07a885d32b3222f7ae410bf3a809f55c35ac).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948394208
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144487/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-948276126
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/48959/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-955997111
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/49270/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r732417522
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -517,6 +517,8 @@ There are a few built-in sources.
- **Rate source (for testing)** - Generates data at the specified number of rows per second, each output row contains a `timestamp` and `value`. Where `timestamp` is a `Timestamp` type containing the time of message dispatch, and `value` is of `Long` type containing the message count, starting from 0 as the first row. This source is intended for testing and benchmarking.
Review comment:
Yeah let's keep the voice and see whether others also feel like the same. We can change it if the consensus is going like that.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] xuanyuanking commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
xuanyuanking commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r732426274
##########
File path: docs/structured-streaming-programming-guide.md
##########
@@ -588,6 +590,17 @@ Here are the details of all the sources in Spark.
<td>Yes</td>
<td></td>
</tr>
+ <tr>
+ <td><b>Rate Per Epoch Source</b></td>
Review comment:
Introduce a new concept `epoch` here seems ambiguous. How about directly using `micro-batch` or other batch-related words? Let's also keep the voice here and see other opinions.
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HeartSaVioR commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
HeartSaVioR commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-955950158
Just pushed a commit addressing...
1) doc review comment
2) fix a bug for Trigger.Once / Trigger.AvailableNow triggers (with adding UTs)
@viirya @xuanyuanking Please take a look again. Thanks in advance!
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-955951266
**[Test build #144800 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/144800/testReport)** for PR 34333 at commit [`cc48368`](https://github.com/apache/spark/commit/cc48368bbbb16873b707f0450e59a20127332ef2).
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-947735165
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/144455/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #34333:
URL: https://github.com/apache/spark/pull/34333#issuecomment-953566514
Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/49166/
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739886981
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchStream.scala
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import org.json4s.NoTypeHints
+import org.json4s.jackson.Serialization
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.util.DateTimeUtils
+import org.apache.spark.sql.connector.read.{InputPartition, PartitionReader, PartitionReaderFactory}
+import org.apache.spark.sql.connector.read.streaming.{MicroBatchStream, Offset, ReadLimit, ReadMaxRows, SupportsAdmissionControl}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+class RatePerMicroBatchStream(
+ rowsPerBatch: Long,
+ numPartitions: Int,
+ startTimestamp: Long,
+ advanceMsPerBatch: Int,
+ options: CaseInsensitiveStringMap)
+ extends SupportsAdmissionControl with MicroBatchStream with Logging {
+
+ override def initialOffset(): Offset = RatePerMicroBatchStreamOffset(0L, startTimestamp)
+
+ override def latestOffset(): Offset = {
+ throw new UnsupportedOperationException(
+ "latestOffset(Offset, ReadLimit) should be called instead of this method")
+ }
+
+ override def getDefaultReadLimit: ReadLimit = {
+ ReadLimit.maxRows(rowsPerBatch)
+ }
+
+ private def extractOffsetAndTimestamp(offset: Offset): (Long, Long) = {
+ offset match {
+ case o: RatePerMicroBatchStreamOffset => (o.offset, o.timestamp)
+ case _ => throw new IllegalStateException("The type of Offset should be " +
+ "RatePerMicroBatchStreamOffset")
+ }
+ }
+
+ override def latestOffset(startOffset: Offset, limit: ReadLimit): Offset = {
+ val (startOffsetLong, timestampAtStartOffset) = extractOffsetAndTimestamp(startOffset)
+ val numRows = limit.asInstanceOf[ReadMaxRows].maxRows()
+
+ val endOffsetLong = Math.min(startOffsetLong + numRows, Long.MaxValue)
+ val endOffset = RatePerMicroBatchStreamOffset(endOffsetLong,
+ timestampAtStartOffset + advanceMsPerBatch)
+
+ endOffset
+ }
+
+ override def deserializeOffset(json: String): Offset = {
+ RatePerMicroBatchStreamOffset.apply(json)
+ }
+
+ override def planInputPartitions(start: Offset, end: Offset): Array[InputPartition] = {
+ val (startOffset, startTimestamp) = extractOffsetAndTimestamp(start)
+ val (endOffset, endTimestamp) = extractOffsetAndTimestamp(end)
+
+ assert(startOffset <= endOffset, s"startOffset($startOffset) > endOffset($endOffset)")
+ assert(startTimestamp <= endTimestamp,
+ s"startTimestamp($startTimestamp) > endTimestamp($endTimestamp)")
+ logDebug(s"startOffset: $startOffset, startTimestamp: $startTimestamp, " +
+ s"endOffset: $endOffset, endTimestamp: $endTimestamp")
+
+ if (startOffset == endOffset) {
+ Array.empty
+ } else {
+ (0 until numPartitions).map { p =>
+ RatePerMicroBatchStreamInputPartition(p, numPartitions, startOffset,
+ startTimestamp, endOffset, endTimestamp)
+ }.toArray
+ }
+ }
+
+ override def createReaderFactory(): PartitionReaderFactory = {
+ RatePerMicroBatchStreamReaderFactory
+ }
+
+ override def commit(end: Offset): Unit = {}
+
+ override def stop(): Unit = {}
+
+ override def toString: String = s"RatePerMicroBatchStream[rowsPerBatch=$rowsPerBatch, " +
+ s"numPartitions=$numPartitions, startTimestamp=$startTimestamp, " +
+ s"advanceMsPerBatch=$advanceMsPerBatch]"
+}
+
+case class RatePerMicroBatchStreamOffset(offset: Long, timestamp: Long) extends Offset {
+ override def json(): String = {
+ Serialization.write(this)(RatePerMicroBatchStreamOffset.formats)
+ }
+}
+
+object RatePerMicroBatchStreamOffset {
+ implicit val formats = Serialization.formats(NoTypeHints)
+
+ def apply(json: String): RatePerMicroBatchStreamOffset =
+ Serialization.read[RatePerMicroBatchStreamOffset](json)
+}
+
+case class RatePerMicroBatchStreamInputPartition(
+ partitionId: Int,
+ numPartitions: Int,
+ startOffset: Long,
+ startTimestamp: Long,
+ endOffset: Long,
+ endTimestamp: Long) extends InputPartition
+
+object RatePerMicroBatchStreamReaderFactory extends PartitionReaderFactory {
+ override def createReader(partition: InputPartition): PartitionReader[InternalRow] = {
+ val p = partition.asInstanceOf[RatePerMicroBatchStreamInputPartition]
+ new RatePerMicroBatchStreamPartitionReader(p.partitionId, p.numPartitions,
+ p.startOffset, p.startTimestamp, p.endOffset, p.endTimestamp)
+ }
+}
+
+class RatePerMicroBatchStreamPartitionReader(
+ partitionId: Int,
+ numPartitions: Int,
+ startOffset: Long,
+ startTimestamp: Long,
+ endOffset: Long,
+ endTimestamp: Long) extends PartitionReader[InternalRow] {
Review comment:
`endTimestamp` is useless in `RatePerMicroBatchStreamPartitionReader`. All output rows have the same timestamp value (`startTimestamp`)?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] viirya commented on a change in pull request #34333: [SPARK-37062][SS] Introduce a new data source for providing consistent set of rows per microbatch
Posted by GitBox <gi...@apache.org>.
viirya commented on a change in pull request #34333:
URL: https://github.com/apache/spark/pull/34333#discussion_r739887100
##########
File path: sql/core/src/main/scala/org/apache/spark/sql/execution/streaming/sources/RatePerMicroBatchStream.scala
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.execution.streaming.sources
+
+import org.json4s.NoTypeHints
+import org.json4s.jackson.Serialization
+
+import org.apache.spark.internal.Logging
+import org.apache.spark.sql.catalyst.InternalRow
+import org.apache.spark.sql.catalyst.util.DateTimeUtils
+import org.apache.spark.sql.connector.read.{InputPartition, PartitionReader, PartitionReaderFactory}
+import org.apache.spark.sql.connector.read.streaming.{MicroBatchStream, Offset, ReadLimit, ReadMaxRows, SupportsAdmissionControl}
+import org.apache.spark.sql.util.CaseInsensitiveStringMap
+
+class RatePerMicroBatchStream(
+ rowsPerBatch: Long,
+ numPartitions: Int,
+ startTimestamp: Long,
+ advanceMsPerBatch: Int,
+ options: CaseInsensitiveStringMap)
+ extends SupportsAdmissionControl with MicroBatchStream with Logging {
+
+ override def initialOffset(): Offset = RatePerMicroBatchStreamOffset(0L, startTimestamp)
+
+ override def latestOffset(): Offset = {
+ throw new UnsupportedOperationException(
+ "latestOffset(Offset, ReadLimit) should be called instead of this method")
+ }
+
+ override def getDefaultReadLimit: ReadLimit = {
+ ReadLimit.maxRows(rowsPerBatch)
+ }
+
+ private def extractOffsetAndTimestamp(offset: Offset): (Long, Long) = {
+ offset match {
+ case o: RatePerMicroBatchStreamOffset => (o.offset, o.timestamp)
+ case _ => throw new IllegalStateException("The type of Offset should be " +
+ "RatePerMicroBatchStreamOffset")
+ }
+ }
+
+ override def latestOffset(startOffset: Offset, limit: ReadLimit): Offset = {
Review comment:
We cannot change the `limit` for this data source, right? Do we need to check it?
--
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.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org