You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by bl...@apache.org on 2019/08/21 20:43:22 UTC
[flink] branch release-1.9 updated: [FLINK-13711][sql-client] Hive
array values not properly displayed in SQL CLI
This is an automated email from the ASF dual-hosted git repository.
bli pushed a commit to branch release-1.9
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.9 by this push:
new b58fa92 [FLINK-13711][sql-client] Hive array values not properly displayed in SQL CLI
b58fa92 is described below
commit b58fa92f0ade9475e39b59c58540676748da5b3a
Author: Rui Li <li...@apache.org>
AuthorDate: Thu Aug 15 15:49:21 2019 +0800
[FLINK-13711][sql-client] Hive array values not properly displayed in SQL CLI
Fix the issue that SQL CLI doesn't display arrays properly.
This closes #9450.
---
.../apache/flink/table/client/cli/CliUtils.java | 3 +-
.../flink/table/client/cli/CliUtilsTest.java | 43 ++++++++++++++++++++++
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliUtils.java b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliUtils.java
index 471d168..cf87f3e 100644
--- a/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliUtils.java
+++ b/flink-table/flink-sql-client/src/main/java/org/apache/flink/table/client/cli/CliUtils.java
@@ -20,6 +20,7 @@ package org.apache.flink.table.client.cli;
import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.table.types.DataType;
+import org.apache.flink.table.utils.EncodingUtils;
import org.apache.flink.types.Row;
import org.jline.utils.AttributedString;
@@ -97,7 +98,7 @@ public final class CliUtils {
if (field == null) {
fields[i] = CliStrings.NULL_COLUMN;
} else {
- fields[i] = field.toString();
+ fields[i] = EncodingUtils.objectToString(field);
}
}
return fields;
diff --git a/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliUtilsTest.java b/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliUtilsTest.java
new file mode 100644
index 0000000..8e2d32e
--- /dev/null
+++ b/flink-table/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliUtilsTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.client.cli;
+
+import org.apache.flink.types.Row;
+
+import org.junit.Test;
+
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Tests {@link CliUtils}.
+ */
+public class CliUtilsTest {
+
+ @Test
+ public void testArrayToString() {
+ Row row = new Row(4);
+ row.setField(0, new int[]{1, 2});
+ row.setField(1, new Integer[]{3, 4});
+ row.setField(2, new Object[]{new int[]{5, 6}, new int[]{7, 8}});
+ row.setField(3, new Integer[][]{new Integer[]{9, 10}, new Integer[]{11, 12}});
+ assertEquals("[[1, 2], [3, 4], [[5, 6], [7, 8]], [[9, 10], [11, 12]]]", Arrays.toString(CliUtils.rowToString(row)));
+ }
+}