You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/09 12:04:07 UTC

[GitHub] [flink] libenchao commented on a change in pull request #13519: [FLINK-18850][Table SQL / Runtime]Add late records dropped metric for row time over windows

libenchao commented on a change in pull request #13519:
URL: https://github.com/apache/flink/pull/13519#discussion_r502374384



##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/operators/over/RowTimeRangeBoundedPrecedingFunction.java
##########
@@ -86,12 +90,25 @@
 
 	private transient AggsHandleFunction function;
 
+	// ------------------------------------------------------------------------
+	// Metrics
+	// ------------------------------------------------------------------------
+	protected static final String LATE_ELEMENTS_DROPPED_METRIC_NAME = "numLateRecordsDropped";
+	protected static final String LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME = "lateRecordsDroppedRate";

Review comment:
       Maybe adding `numLateRecordsDropped` is enough, I also added this metric in CEP in FLINK-15431, and we came into compromise that only added `numLateRecordsDropped`. You can see the discussions in FLINK-15431

##########
File path: flink-table/flink-table-runtime-blink/src/test/java/org/apache/flink/table/runtime/operators/over/RowTimeRangeBoundedPrecedingFunctionTest.java
##########
@@ -40,25 +33,7 @@
 /**
  * Test for {@link RowTimeRangeBoundedPrecedingFunction}.
  */
-public class RowTimeRangeBoundedPrecedingFunctionTest {
-
-	private static GeneratedAggsHandleFunction aggsHandleFunction =
-		new GeneratedAggsHandleFunction("Function", "", new Object[0]) {
-			@Override
-			public AggsHandleFunction newInstance(ClassLoader classLoader) {
-				return new SumAggsHandleFunction(1);
-			}
-		};
-
-	private LogicalType[] inputFieldTypes = new LogicalType[]{
-		new VarCharType(VarCharType.MAX_LENGTH),
-		new BigIntType(),
-		new BigIntType()
-	};
-	private LogicalType[] accTypes = new LogicalType[]{ new BigIntType() };
-
-	private BinaryRowDataKeySelector keySelector = new BinaryRowDataKeySelector(new int[]{ 0 }, inputFieldTypes);
-	private TypeInformation<RowData> keyType = keySelector.getProducedType();
+public class RowTimeRangeBoundedPrecedingFunctionTest extends RowTimeOverWindowTestBase{

Review comment:
       ```suggestion
   public class RowTimeRangeBoundedPrecedingFunctionTest extends RowTimeOverWindowTestBase {
   ```

##########
File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/operators/over/RowTimeRangeBoundedPrecedingFunction.java
##########
@@ -86,12 +90,25 @@
 
 	private transient AggsHandleFunction function;
 
+	// ------------------------------------------------------------------------
+	// Metrics
+	// ------------------------------------------------------------------------
+	protected static final String LATE_ELEMENTS_DROPPED_METRIC_NAME = "numLateRecordsDropped";
+	protected static final String LATE_ELEMENTS_DROPPED_RATE_METRIC_NAME = "lateRecordsDroppedRate";
+	private transient Counter numLateRecordsDropped;
+	private transient Meter lateRecordsDroppedRate;
+
+	@VisibleForTesting
+	public Counter getCounter() {
+		return numLateRecordsDropped;
+	}
+
 	public RowTimeRangeBoundedPrecedingFunction(
-			GeneratedAggsHandleFunction genAggsHandler,
-			LogicalType[] accTypes,
-			LogicalType[] inputFieldTypes,
-			long precedingOffset,
-			int rowTimeIdx) {
+		GeneratedAggsHandleFunction genAggsHandler,
+		LogicalType[] accTypes,
+		LogicalType[] inputFieldTypes,
+		long precedingOffset,
+		int rowTimeIdx) {

Review comment:
       usually we add one more tab for method parameters.

##########
File path: flink-table/flink-table-runtime-blink/src/test/java/org/apache/flink/table/runtime/operators/over/RowTimeRangeUnboundedPrecedingFunctionTest.java
##########
@@ -0,0 +1,61 @@
+/*
+ * 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.flink.table.runtime.operators.over;
+
+import org.apache.flink.metrics.Counter;
+import org.apache.flink.streaming.api.operators.KeyedProcessOperator;
+import org.apache.flink.streaming.api.watermark.Watermark;
+import org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness;
+import org.apache.flink.table.data.RowData;
+
+import org.junit.Test;
+
+import static org.apache.flink.table.runtime.util.StreamRecordUtils.insertRecord;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test for {@link RowTimeRangeUnboundedPrecedingFunction}.
+ */
+public class RowTimeRangeUnboundedPrecedingFunctionTest extends RowTimeOverWindowTestBase{

Review comment:
       ```suggestion
   public class RowTimeRangeUnboundedPrecedingFunctionTest extends RowTimeOverWindowTestBase {
   ```




----------------------------------------------------------------
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:
users@infra.apache.org