From issues-return-174216-apmail-flink-issues-archive=flink.apache.org@flink.apache.org Sun Jul 1 23:06:59 2018 Return-Path: X-Original-To: apmail-flink-issues-archive@minotaur.apache.org Delivered-To: apmail-flink-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id D7D6118A8B for ; Sun, 1 Jul 2018 23:06:59 +0000 (UTC) Received: (qmail 12628 invoked by uid 500); 1 Jul 2018 23:06:58 -0000 Delivered-To: apmail-flink-issues-archive@flink.apache.org Received: (qmail 12592 invoked by uid 500); 1 Jul 2018 23:06:58 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 12577 invoked by uid 99); 1 Jul 2018 23:06:58 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Jul 2018 23:06:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 12C8FE10B8; Sun, 1 Jul 2018 23:06:58 +0000 (UTC) From: snuyanzin To: issues@flink.apache.org Reply-To: issues@flink.apache.org References: In-Reply-To: Subject: [GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types Content-Type: text/plain Message-Id: <20180701230658.12C8FE10B8@git1-us-west.apache.org> Date: Sun, 1 Jul 2018 23:06:58 +0000 (UTC) Github user snuyanzin commented on a diff in the pull request: https://github.com/apache/flink/pull/6233#discussion_r199364581 --- Diff: flink-libraries/flink-sql-client/src/test/java/org/apache/flink/table/client/cli/CliUtilsTest.java --- @@ -0,0 +1,108 @@ +/* + * 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.api.java.tuple.Tuple3; +import org.apache.flink.types.Row; + +import org.junit.Test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.assertEquals; + +/** + * Tests for {@link CliUtils}. + */ +public class CliUtilsTest { + + @Test + public void testRowToString() throws IOException { + Row result = new Row(10); + result.setField(0, null); + result.setField(1, "String"); + result.setField(2, 'c'); + result.setField(3, false); + result.setField(4, 12345.67f); + result.setField(5, 12345.67d); + result.setField(6, 12345L); + result.setField(7, java.sql.Date.valueOf("2018-11-12")); + result.setField(8, new int[]{1, 2}); + result.setField(9, new Tuple3<>(1, "123", null)); + assertEquals(Arrays.toString(CliUtils.rowToString(result)), + "[(NULL), String, c, false, 12345.67, 12345.67, 12345, 2018-11-12, " + + "[1, 2], (1,123,null)]"); --- End diff -- If having tuple here is ok then the next strange thing is null handling inside tuples (it is printed in lowercase and without brackets). So there are at least 2 different types of null handling: inside tuples and all others. ---