JingsongLi commented on code in PR #394:
URL: https://github.com/apache/flink-table-store/pull/394#discussion_r1035560520


##########
flink-table-store-spark/src/main/java/org/apache/flink/table/store/spark/SparkRowData.java:
##########
@@ -0,0 +1,370 @@
+/*
+ * 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.store.spark;
+
+import org.apache.flink.table.data.ArrayData;
+import org.apache.flink.table.data.DecimalData;
+import org.apache.flink.table.data.MapData;
+import org.apache.flink.table.data.RawValueData;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.data.StringData;
+import org.apache.flink.table.data.TimestampData;
+import org.apache.flink.table.store.utils.DateTimeUtils;
+import org.apache.flink.table.types.logical.ArrayType;
+import org.apache.flink.table.types.logical.DateType;
+import org.apache.flink.table.types.logical.LogicalType;
+import org.apache.flink.table.types.logical.MapType;
+import org.apache.flink.table.types.logical.RowType;
+import org.apache.flink.types.RowKind;
+
+import org.apache.spark.sql.Row;
+
+import java.sql.Date;
+import java.sql.Timestamp;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/** A {@link RowData} wraps spark {@link Row}. */
+public class SparkRowData implements RowData {
+
+    private final RowType type;
+    private final Row row;
+
+    public SparkRowData(RowType type, Row row) {
+        this.type = type;
+        this.row = row;
+    }
+
+    @Override
+    public int getArity() {
+        return row.size();
+    }
+
+    @Override
+    public RowKind getRowKind() {
+        return RowKind.INSERT;
+    }
+
+    @Override
+    public void setRowKind(RowKind rowKind) {
+        if (rowKind == RowKind.INSERT) {
+            return;
+        }
+
+        throw new UnsupportedOperationException("Can not set row kind for this 
row.");
+    }
+
+    @Override
+    public boolean isNullAt(int i) {
+        return row.isNullAt(i);
+    }
+
+    @Override
+    public boolean getBoolean(int i) {
+        return row.getBoolean(i);
+    }
+
+    @Override
+    public byte getByte(int i) {
+        return row.getByte(i);
+    }
+
+    @Override
+    public short getShort(int i) {
+        return row.getShort(i);
+    }
+
+    @Override
+    public int getInt(int i) {
+        if (type.getTypeAt(i) instanceof DateType) {
+            return toFlinkDate(row.get(i));
+        }
+        return row.getInt(i);
+    }
+
+    @Override
+    public long getLong(int i) {
+        return row.getLong(i);
+    }
+
+    @Override
+    public float getFloat(int i) {
+        return row.getFloat(i);
+    }
+
+    @Override
+    public double getDouble(int i) {
+        return row.getDouble(i);
+    }
+
+    @Override
+    public StringData getString(int i) {
+        return StringData.fromString(row.getString(i));
+    }
+
+    @Override
+    public DecimalData getDecimal(int i, int precision, int scale) {
+        return DecimalData.fromBigDecimal(row.getDecimal(i), precision, scale);
+    }
+
+    @Override
+    public TimestampData getTimestamp(int i, int precision) {
+        return toFlinkTimestamp(row.get(i));
+    }
+
+    @Override
+    public <T> RawValueData<T> getRawValue(int i) {
+        throw new UnsupportedOperationException();

Review Comment:
   add message: `Raw value is not supported in Spark, please use SQL types.`



-- 
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