[GitHub] [spark] cloud-fan commented on a change in pull request #31476: [SPARK-34366][SQL] Add interface for DS v2 metrics

2021-03-23 Thread GitBox


cloud-fan commented on a change in pull request #31476:
URL: https://github.com/apache/spark/pull/31476#discussion_r599346059



##
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/connector/CustomTaskMetric.java
##
@@ -0,0 +1,46 @@
+/*
+ * 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.connector;
+
+import org.apache.spark.annotation.Evolving;
+import org.apache.spark.sql.connector.read.PartitionReader;
+
+/**
+ * A custom task metric. This is a logical representation of a metric reported 
by data sources
+ * at the executor side. During query execution, Spark will collect the task 
metrics per partition
+ * by {@link PartitionReader} and update internal metrics based on collected 
metric values.
+ * For streaming query, Spark will collect and combine metrics for a final 
result per micro batch.
+ *
+ * The metrics will be gathered during query execution back to the driver and 
then combined. How
+ * the task metrics are combined is defined by corresponding {@link 
CustomMetric} with same metric
+ * name. The final result will be shown up in the physical operator in Spark 
UI.

Review comment:
   `physical operator` -> `data source scan operator`




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] cloud-fan commented on a change in pull request #31476: [SPARK-34366][SQL] Add interface for DS v2 metrics

2021-02-08 Thread GitBox


cloud-fan commented on a change in pull request #31476:
URL: https://github.com/apache/spark/pull/31476#discussion_r572300669



##
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/connector/SupportsReportMetrics.java
##
@@ -0,0 +1,39 @@
+/*
+ * 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.connector;
+
+import org.apache.spark.annotation.Evolving;
+
+/**
+ * Data sources can implement this interface to
+ * report supported custom metrics to Spark in read/write path.
+ *
+ * @since 3.2.0
+ */
+@Evolving
+public interface SupportsReportMetrics {
+
+/**
+ * Returns an array of supported custom metrics with name and description.
+ * By default it returns empty array.
+ */
+default CustomMetric[] supportedCustomMetrics() {
+CustomMetric[] NO_METRICS = {};

Review comment:
   shall we define it as a private static field?





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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org



[GitHub] [spark] cloud-fan commented on a change in pull request #31476: [SPARK-34366][SQL] Add interface for DS v2 metrics

2021-02-08 Thread GitBox


cloud-fan commented on a change in pull request #31476:
URL: https://github.com/apache/spark/pull/31476#discussion_r572298710



##
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/connector/read/Scan.java
##
@@ -102,4 +102,13 @@ default MicroBatchStream toMicroBatchStream(String 
checkpointLocation) {
   default ContinuousStream toContinuousStream(String checkpointLocation) {
 throw new UnsupportedOperationException(description() + ": Continuous scan 
are not supported");
   }
+
+  /**
+   * Returns an array of supported custom metrics with name and description.
+   * By default it returns empty array.
+   */
+  default CustomMetric[] supportedCustomMetrics() {

Review comment:
   I don't see how a mixin trait helps avoid breaking change. Removing the 
trait later is also a breaking change. Agree with @rdblue that an optional 
method is simple and sufficient. Some other features have mixin trait because 
they don't have a reasonable default if made into optional methods. Metrics is 
OK as we can return empty metrics as the default.





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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



-
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org