lindong28 commented on code in PR #187:
URL: https://github.com/apache/flink-ml/pull/187#discussion_r1045233434


##########
flink-ml-lib/src/main/java/org/apache/flink/ml/feature/univariatefeatureselector/UnivariateFeatureSelectorModel.java:
##########
@@ -0,0 +1,201 @@
+/*
+ * 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.ml.feature.univariatefeatureselector;
+
+import org.apache.flink.api.common.functions.RichMapFunction;
+import org.apache.flink.api.java.typeutils.RowTypeInfo;
+import org.apache.flink.ml.api.Model;
+import org.apache.flink.ml.common.broadcast.BroadcastUtils;
+import org.apache.flink.ml.common.datastream.TableUtils;
+import org.apache.flink.ml.linalg.DenseVector;
+import org.apache.flink.ml.linalg.SparseVector;
+import org.apache.flink.ml.linalg.Vector;
+import org.apache.flink.ml.linalg.Vectors;
+import org.apache.flink.ml.linalg.typeinfo.VectorTypeInfo;
+import org.apache.flink.ml.param.Param;
+import org.apache.flink.ml.util.ParamUtils;
+import org.apache.flink.ml.util.ReadWriteUtils;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.table.api.internal.TableImpl;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.Preconditions;
+
+import org.apache.commons.lang3.ArrayUtils;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A Model which transforms data using the model data computed by {@link 
UnivariateFeatureSelector}.
+ */
+public class UnivariateFeatureSelectorModel
+        implements Model<UnivariateFeatureSelectorModel>,
+                
UnivariateFeatureSelectorModelParams<UnivariateFeatureSelectorModel> {
+
+    private final Map<Param<?>, Object> paramMap = new HashMap<>();
+    private Table modelDataTable;
+
+    public UnivariateFeatureSelectorModel() {
+        ParamUtils.initializeMapWithDefaultValues(paramMap, this);
+    }
+
+    @Override
+    public UnivariateFeatureSelectorModel setModelData(Table... inputs) {
+        Preconditions.checkArgument(inputs.length == 1);
+        modelDataTable = inputs[0];
+        return this;
+    }
+
+    @Override
+    public Table[] getModelData() {
+        return new Table[] {modelDataTable};
+    }
+
+    @SuppressWarnings({"unchecked", "rawtypes"})
+    @Override
+    public Table[] transform(Table... inputs) {
+        Preconditions.checkArgument(inputs.length == 1);
+
+        StreamTableEnvironment tEnv =
+                (StreamTableEnvironment) ((TableImpl) 
inputs[0]).getTableEnvironment();
+        DataStream<Row> data = tEnv.toDataStream(inputs[0]);
+        DataStream<UnivariateFeatureSelectorModelData> modelData =
+                
UnivariateFeatureSelectorModelData.getModelDataStream(modelDataTable);
+
+        final String broadcastModelKey = "broadcastModelKey";
+        RowTypeInfo inputTypeInfo = 
TableUtils.getRowTypeInfo(inputs[0].getResolvedSchema());
+        RowTypeInfo outputTypeInfo =
+                new RowTypeInfo(
+                        ArrayUtils.addAll(inputTypeInfo.getFieldTypes(), 
VectorTypeInfo.INSTANCE),
+                        ArrayUtils.addAll(inputTypeInfo.getFieldNames(), 
getOutputCol()));
+
+        DataStream<Row> outputStream =
+                BroadcastUtils.withBroadcastStream(
+                        Collections.singletonList(data),
+                        Collections.singletonMap(broadcastModelKey, modelData),
+                        inputList -> {
+                            DataStream input = inputList.get(0);
+                            return input.map(
+                                    new 
PredictOutputFunction(getFeaturesCol(), broadcastModelKey),
+                                    outputTypeInfo);
+                        });
+
+        return new Table[] {tEnv.fromDataStream(outputStream)};
+    }
+
+    /** This operator loads model data and predicts result. */
+    private static class PredictOutputFunction extends RichMapFunction<Row, 
Row> {
+
+        private final String inputCol;
+        private final String broadcastKey;
+        private int[] indices;
+
+        public PredictOutputFunction(String inputCol, String broadcastKey) {
+            this.inputCol = inputCol;
+            this.broadcastKey = broadcastKey;
+        }
+
+        @Override
+        public Row map(Row row) {
+            if (indices == null) {
+                UnivariateFeatureSelectorModelData modelData =
+                        (UnivariateFeatureSelectorModelData)
+                                
getRuntimeContext().getBroadcastVariable(broadcastKey).get(0);
+                indices = Arrays.stream(modelData.indices).sorted().toArray();
+            }
+
+            if (indices.length == 0) {
+                return Row.join(row, Row.of(Vectors.dense()));
+            } else {
+                Vector inputVec = ((Vector) row.getField(inputCol));
+                Preconditions.checkArgument(
+                        inputVec.size() > indices[indices.length - 1],
+                        "Input %s features, but UnivariateFeatureSelector is "
+                                + "expecting at least %s features as input.",
+                        inputVec.size(),
+                        indices[indices.length - 1] + 1);
+                Vector outputVec = selectByIndices(inputVec, indices);
+                return Row.join(row, Row.of(outputVec));
+            }
+        }
+
+        /**
+         * Selects a subset of the vector base on the indices. Note that the 
input indices must be
+         * sorted in ascending order if the input vector is sparse.
+         */
+        private Vector selectByIndices(Vector vector, int[] selectedIndices) {
+            if (vector instanceof DenseVector) {
+                DenseVector resultVec = new 
DenseVector(selectedIndices.length);
+                for (int i = 0; i < selectedIndices.length; i++) {
+                    resultVec.set(i, vector.get(selectedIndices[i]));
+                }
+                return resultVec;
+            } else {
+                List<Integer> resultIndices = new ArrayList<>();
+                List<Double> resultValues = new ArrayList<>();
+
+                int[] indices = ((SparseVector) vector).indices;
+                for (int i = 0, j = 0; i < indices.length && j < 
selectedIndices.length; ) {
+                    if (indices[i] == selectedIndices[j]) {
+                        resultIndices.add(j++);
+                        resultValues.add(((SparseVector) vector).values[i++]);
+                    } else if (indices[i] > selectedIndices[j]) {
+                        j++;
+                    } else {
+                        i++;
+                    }
+                }
+                return new SparseVector(

Review Comment:
   The SparseVector instance created here is guaranteed to be dense. Would it 
be simpler to just return DenseVector here?



##########
flink-ml-lib/src/test/java/org/apache/flink/ml/feature/UnivariateFeatureSelectorTest.java:
##########
@@ -0,0 +1,783 @@
+/*
+ * 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.ml.feature;
+
+import org.apache.flink.api.common.restartstrategy.RestartStrategies;
+import org.apache.flink.api.common.typeinfo.Types;
+import org.apache.flink.configuration.Configuration;
+import 
org.apache.flink.ml.feature.univariatefeatureselector.UnivariateFeatureSelector;
+import 
org.apache.flink.ml.feature.univariatefeatureselector.UnivariateFeatureSelectorModel;
+import org.apache.flink.ml.linalg.Vector;
+import org.apache.flink.ml.linalg.Vectors;
+import org.apache.flink.ml.linalg.typeinfo.VectorTypeInfo;
+import org.apache.flink.ml.util.TestUtils;
+import org.apache.flink.streaming.api.datastream.DataStream;
+import 
org.apache.flink.streaming.api.environment.ExecutionCheckpointingOptions;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.api.Table;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.table.api.internal.TableImpl;
+import org.apache.flink.test.util.AbstractTestBase;
+import org.apache.flink.types.Row;
+import org.apache.flink.util.CloseableIterator;
+
+import org.apache.commons.collections.IteratorUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+/** Tests {@link UnivariateFeatureSelector} and {@link 
UnivariateFeatureSelectorModel}. */
+public class UnivariateFeatureSelectorTest extends AbstractTestBase {
+    @Rule public final TemporaryFolder tempFolder = new TemporaryFolder();
+    private StreamExecutionEnvironment env;
+    private StreamTableEnvironment tEnv;
+    private Table inputChiSqTable;
+    private Table inputANOVATable;
+    private Table inputFValueTable;
+
+    private static final double EPS = 1.0e-5;
+
+    private UnivariateFeatureSelector selectorWithChiSqTest;
+    private UnivariateFeatureSelector selectorWithANOVATest;
+    private UnivariateFeatureSelector selectorWithFValueTest;
+
+    private static final List<Row> INPUT_CHISQ_DATA =
+            Arrays.asList(
+                    Row.of(0.0, Vectors.dense(6.0, 7.0, 0.0, 7.0, 6.0, 0.0)),
+                    Row.of(1.0, Vectors.dense(0.0, 9.0, 6.0, 0.0, 5.0, 9.0)),
+                    Row.of(1.0, Vectors.dense(0.0, 9.0, 3.0, 0.0, 5.0, 5.0)),
+                    Row.of(1.0, Vectors.dense(0.0, 9.0, 8.0, 5.0, 6.0, 
4.0).toSparse()),
+                    Row.of(2.0, Vectors.dense(8.0, 9.0, 6.0, 5.0, 4.0, 
4.0).toSparse()),
+                    Row.of(2.0, Vectors.dense(8.0, 9.0, 6.0, 4.0, 0.0, 
0.0).toSparse()));
+
+    private static final List<Row> INPUT_ANOVA_DATA =
+            Arrays.asList(
+                    Row.of(
+                            1,
+                            Vectors.dense(
+                                    4.65415496e-03,
+                                    1.03550567e-01,
+                                    -1.17358140e+00,
+                                    1.61408773e-01,
+                                    3.92492111e-01,
+                                    7.31240882e-01)),
+                    Row.of(
+                            1,
+                            Vectors.dense(
+                                    -9.01651741e-01,
+                                    -5.28905302e-01,
+                                    1.27636785e+00,
+                                    7.02154563e-01,
+                                    6.21348351e-01,
+                                    1.88397353e-01)),
+                    Row.of(
+                            1,
+                            Vectors.dense(
+                                    3.85692159e-01,
+                                    -9.04639637e-01,
+                                    5.09782604e-02,
+                                    8.40043971e-01,
+                                    7.45977857e-01,
+                                    8.78402288e-01)),
+                    Row.of(
+                            1,
+                            Vectors.dense(
+                                    1.36264353e+00,
+                                    2.62454094e-01,
+                                    7.96306202e-01,
+                                    6.14948000e-01,
+                                    7.44948187e-01,
+                                    9.74034830e-01)),
+                    Row.of(
+                            1,
+                            Vectors.dense(
+                                    9.65874070e-01,
+                                    2.52773665e+00,
+                                    -2.19380094e+00,
+                                    2.33408080e-01,
+                                    1.86340919e-01,
+                                    8.23390433e-01)),
+                    Row.of(
+                            2,
+                            Vectors.dense(
+                                    1.12324305e+01,
+                                    -2.77121515e-01,
+                                    1.12740513e-01,
+                                    2.35184013e-01,
+                                    3.46668895e-01,
+                                    9.38500782e-02)),
+                    Row.of(
+                            2,
+                            Vectors.dense(
+                                    1.06195839e+01,
+                                    -1.82891238e+00,
+                                    2.25085601e-01,
+                                    9.09979851e-01,
+                                    6.80257535e-02,
+                                    8.24017480e-01)),
+                    Row.of(
+                            2,
+                            Vectors.dense(
+                                    1.12806837e+01,
+                                    1.30686889e+00,
+                                    9.32839108e-02,
+                                    3.49784755e-01,
+                                    1.71322408e-02,
+                                    7.48465194e-02)),
+                    Row.of(
+                            2,
+                            Vectors.dense(
+                                    9.98689462e+00,
+                                    9.50808938e-01,
+                                    -2.90786359e-01,
+                                    2.31253009e-01,
+                                    7.46270968e-01,
+                                    1.60308169e-01)),
+                    Row.of(
+                            2,
+                            Vectors.dense(
+                                    1.08428551e+01,
+                                    -1.02749936e+00,
+                                    1.73951508e-01,
+                                    8.92482744e-02,
+                                    1.42651730e-01,
+                                    7.66751625e-01)),
+                    Row.of(
+                            3,
+                            Vectors.dense(
+                                            -1.98641448e+00,
+                                            1.12811990e+01,
+                                            -2.35246756e-01,
+                                            8.22809049e-01,
+                                            3.26739456e-01,
+                                            7.88268404e-01)
+                                    .toSparse()),
+                    Row.of(
+                            3,
+                            Vectors.dense(
+                                            -6.09864090e-01,
+                                            1.07346276e+01,
+                                            -2.18805509e-01,
+                                            7.33931213e-01,
+                                            1.42554396e-01,
+                                            7.11225605e-01)
+                                    .toSparse()),
+                    Row.of(
+                            3,
+                            Vectors.dense(
+                                            -1.58481268e+00,
+                                            9.19364039e+00,
+                                            -5.87490459e-02,
+                                            2.51532056e-01,
+                                            2.82729807e-01,
+                                            7.16245686e-01)
+                                    .toSparse()),
+                    Row.of(
+                            3,
+                            Vectors.dense(
+                                            -2.50949277e-01,
+                                            1.12815254e+01,
+                                            -6.94806734e-01,
+                                            5.93898886e-01,
+                                            5.68425656e-01,
+                                            8.49762330e-01)
+                                    .toSparse()),
+                    Row.of(
+                            3,
+                            Vectors.dense(
+                                            7.63485129e-01,
+                                            1.02605138e+01,
+                                            1.32617719e+00,
+                                            5.49682879e-01,
+                                            8.59931442e-01,
+                                            4.88677978e-02)
+                                    .toSparse()),
+                    Row.of(
+                            4,
+                            Vectors.dense(
+                                            9.34900015e-01,
+                                            4.11379043e-01,
+                                            8.65010205e+00,
+                                            9.23509168e-01,
+                                            1.16995043e-01,
+                                            5.91894106e-03)
+                                    .toSparse()),
+                    Row.of(
+                            4,
+                            Vectors.dense(
+                                            4.73734933e-01,
+                                            -1.48321181e+00,
+                                            9.73349621e+00,
+                                            4.09421563e-01,
+                                            5.09375719e-01,
+                                            5.93157850e-01)
+                                    .toSparse()),
+                    Row.of(
+                            4,
+                            Vectors.dense(
+                                            3.41470679e-01,
+                                            -6.88972582e-01,
+                                            9.60347938e+00,
+                                            3.62654055e-01,
+                                            2.43437468e-01,
+                                            7.13052838e-01)
+                                    .toSparse()),
+                    Row.of(
+                            4,
+                            Vectors.dense(
+                                            -5.29614251e-01,
+                                            -1.39262856e+00,
+                                            1.01354144e+01,
+                                            8.24123861e-01,
+                                            5.84074506e-01,
+                                            6.54461558e-01)
+                                    .toSparse()),
+                    Row.of(
+                            4,
+                            Vectors.dense(
+                                            -2.99454508e-01,
+                                            2.20457263e+00,
+                                            1.14586015e+01,
+                                            5.16336729e-01,
+                                            9.99776159e-01,
+                                            3.15769738e-01)
+                                    .toSparse()));
+
+    private static final List<Row> INPUT_FVALUE_DATA =
+            Arrays.asList(
+                    Row.of(
+                            0.52516321,
+                            Vectors.dense(
+                                    0.19151945,
+                                    0.62210877,
+                                    0.43772774,
+                                    0.78535858,
+                                    0.77997581,
+                                    0.27259261)),
+                    Row.of(
+                            0.88275782,
+                            Vectors.dense(
+                                    0.27646426,
+                                    0.80187218,
+                                    0.95813935,
+                                    0.87593263,
+                                    0.35781727,
+                                    0.50099513)),
+                    Row.of(
+                            0.67524507,
+                            Vectors.dense(
+                                    0.68346294,
+                                    0.71270203,
+                                    0.37025075,
+                                    0.56119619,
+                                    0.50308317,
+                                    0.01376845)),
+                    Row.of(
+                            0.76734745,
+                            Vectors.dense(
+                                    0.77282662,
+                                    0.88264119,
+                                    0.36488598,
+                                    0.61539618,
+                                    0.07538124,
+                                    0.36882401)),
+                    Row.of(
+                            0.73909458,
+                            Vectors.dense(
+                                    0.9331401,
+                                    0.65137814,
+                                    0.39720258,
+                                    0.78873014,
+                                    0.31683612,
+                                    0.56809865)),
+                    Row.of(
+                            0.83628141,
+                            Vectors.dense(
+                                    0.86912739,
+                                    0.43617342,
+                                    0.80214764,
+                                    0.14376682,
+                                    0.70426097,
+                                    0.70458131)),
+                    Row.of(
+                            0.65665506,
+                            Vectors.dense(
+                                    0.21879211,
+                                    0.92486763,
+                                    0.44214076,
+                                    0.90931596,
+                                    0.05980922,
+                                    0.18428708)),
+                    Row.of(
+                            0.58147135,
+                            Vectors.dense(
+                                    0.04735528,
+                                    0.67488094,
+                                    0.59462478,
+                                    0.53331016,
+                                    0.04332406,
+                                    0.56143308)),
+                    Row.of(
+                            0.35603443,
+                            Vectors.dense(
+                                    0.32966845,
+                                    0.50296683,
+                                    0.11189432,
+                                    0.60719371,
+                                    0.56594464,
+                                    0.00676406)),
+                    Row.of(
+                            0.94534373,
+                            Vectors.dense(
+                                    0.61744171,
+                                    0.91212289,
+                                    0.79052413,
+                                    0.99208147,
+                                    0.95880176,
+                                    0.79196414)),
+                    Row.of(
+                            0.57458887,
+                            Vectors.dense(
+                                            0.28525096,
+                                            0.62491671,
+                                            0.4780938,
+                                            0.19567518,
+                                            0.38231745,
+                                            0.05387369)
+                                    .toSparse()),
+                    Row.of(
+                            0.59026777,
+                            Vectors.dense(
+                                            0.45164841,
+                                            0.98200474,
+                                            0.1239427,
+                                            0.1193809,
+                                            0.73852306,
+                                            0.58730363)
+                                    .toSparse()),
+                    Row.of(
+                            0.29894977,
+                            Vectors.dense(
+                                            0.47163253,
+                                            0.10712682,
+                                            0.22921857,
+                                            0.89996519,
+                                            0.41675354,
+                                            0.53585166)
+                                    .toSparse()),
+                    Row.of(
+                            0.34056582,
+                            Vectors.dense(
+                                            0.00620852,
+                                            0.30064171,
+                                            0.43689317,
+                                            0.612149,
+                                            0.91819808,
+                                            0.62573667)
+                                    .toSparse()),
+                    Row.of(
+                            0.64476446,
+                            Vectors.dense(
+                                            0.70599757,
+                                            0.14983372,
+                                            0.74606341,
+                                            0.83100699,
+                                            0.63372577,
+                                            0.43830988)
+                                    .toSparse()),
+                    Row.of(
+                            0.53724782,
+                            Vectors.dense(
+                                            0.15257277,
+                                            0.56840962,
+                                            0.52822428,
+                                            0.95142876,
+                                            0.48035918,
+                                            0.50255956)
+                                    .toSparse()),
+                    Row.of(
+                            0.5173021,
+                            Vectors.dense(
+                                            0.53687819,
+                                            0.81920207,
+                                            0.05711564,
+                                            0.66942174,
+                                            0.76711663,
+                                            0.70811536)
+                                    .toSparse()),
+                    Row.of(
+                            0.94508275,
+                            Vectors.dense(
+                                            0.79686718,
+                                            0.55776083,
+                                            0.96583653,
+                                            0.1471569,
+                                            0.029647,
+                                            0.59389349)
+                                    .toSparse()),
+                    Row.of(
+                            0.57739736,
+                            Vectors.dense(
+                                            0.1140657,
+                                            0.95080985,
+                                            0.96583653,
+                                            0.19361869,
+                                            0.45781165,
+                                            0.92040257)
+                                    .toSparse()),
+                    Row.of(
+                            0.53877145,
+                            Vectors.dense(
+                                            0.87906916,
+                                            0.25261576,
+                                            0.34800879,
+                                            0.18258873,
+                                            0.90179605,
+                                            0.70652816)
+                                    .toSparse()));
+
+    @Before
+    public void before() {
+        Configuration config = new Configuration();
+        
config.set(ExecutionCheckpointingOptions.ENABLE_CHECKPOINTS_AFTER_TASKS_FINISH, 
true);
+        env = StreamExecutionEnvironment.getExecutionEnvironment(config);
+        env.setParallelism(4);
+        env.enableCheckpointing(100);
+        env.setRestartStrategy(RestartStrategies.noRestart());
+        env.getConfig().enableObjectReuse();
+        tEnv = StreamTableEnvironment.create(env);
+
+        selectorWithChiSqTest =
+                new UnivariateFeatureSelector()
+                        .setFeatureType("categorical")
+                        .setLabelType("categorical");
+        selectorWithANOVATest =
+                new UnivariateFeatureSelector()
+                        .setFeatureType("continuous")
+                        .setLabelType("categorical");
+        selectorWithFValueTest =
+                new UnivariateFeatureSelector()
+                        .setFeatureType("continuous")
+                        .setLabelType("continuous");
+        inputChiSqTable =
+                tEnv.fromDataStream(
+                                env.fromCollection(
+                                        INPUT_CHISQ_DATA,
+                                        Types.ROW(Types.DOUBLE, 
VectorTypeInfo.INSTANCE)))
+                        .as("label", "features");
+        inputANOVATable =
+                tEnv.fromDataStream(
+                                env.fromCollection(
+                                        INPUT_ANOVA_DATA,
+                                        Types.ROW(Types.INT, 
VectorTypeInfo.INSTANCE)))
+                        .as("label", "features");
+        inputFValueTable =
+                tEnv.fromDataStream(
+                                env.fromCollection(
+                                        INPUT_FVALUE_DATA,
+                                        Types.ROW(Types.DOUBLE, 
VectorTypeInfo.INSTANCE)))
+                        .as("label", "features");
+    }
+
+    private void transformAndVerify(
+            UnivariateFeatureSelector selector, Table table, int... 
expectedIndices)
+            throws Exception {
+        UnivariateFeatureSelectorModel model = selector.fit(table);
+        Table output = model.transform(table)[0];
+        verifyOutputResult(output, expectedIndices);
+    }
+
+    private void verifyOutputResult(Table table, int... expectedIndices) 
throws Exception {
+        StreamTableEnvironment tEnv =
+                (StreamTableEnvironment) ((TableImpl) 
table).getTableEnvironment();
+        CloseableIterator<Row> rowIterator = 
tEnv.toDataStream(table).executeAndCollect();
+        while (rowIterator.hasNext()) {
+            Row row = rowIterator.next();
+            for (int i = 0; i < expectedIndices.length; i++) {
+                assertEquals(
+                        ((Vector) 
row.getField("features")).get(expectedIndices[i]),
+                        ((Vector) row.getField("output")).get(i),

Review Comment:
   Should we also verify that the given `table` only contains the selected 
features?



-- 
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: issues-unsubscr...@flink.apache.org

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

Reply via email to