[GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types

2018-07-02 Thread snuyanzin
Github user snuyanzin commented on a diff in the pull request:

https://github.com/apache/flink/pull/6233#discussion_r199559926
  
--- 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)),
--- End diff --

Thank you for the catch.
Corrected


---


[GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types

2018-07-02 Thread hequn8128
Github user hequn8128 commented on a diff in the pull request:

https://github.com/apache/flink/pull/6233#discussion_r199506183
  
--- 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)),
--- End diff --

The first element of `assertEquals` is expected and second is actual, 
correct the order of these two parameters. (Also for other tests)


---


[GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types

2018-07-02 Thread hequn8128
Github user hequn8128 commented on a diff in the pull request:

https://github.com/apache/flink/pull/6233#discussion_r199504811
  
--- 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 --

I think it is better to keep one. How about change `NULL_COLUMN = "(NULL)"` 
to `NULL_COLUMN = "null"`.  @twalthr @snuyanzin 


---


[GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types

2018-07-02 Thread hequn8128
Github user hequn8128 commented on a diff in the pull request:

https://github.com/apache/flink/pull/6233#discussion_r199504779
  
--- 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));
--- End diff --

I'm not quit sure whether output type can be tuple, but a row type is sure. 
For example, `result.setField(8, new Row(2));` , this will also output null.


---


[GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types

2018-07-01 Thread snuyanzin
Github user snuyanzin commented on a diff in the pull request:

https://github.com/apache/flink/pull/6233#discussion_r199364538
  
--- 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));
--- End diff --

Is it a real case to have tuple here for SqlClient? API allows to do that 
but not sure about real cases.


---


[GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types

2018-07-01 Thread snuyanzin
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.



---


[GitHub] flink pull request #6233: [FLINK-9696] Deep toString for array/map sql types

2018-06-30 Thread snuyanzin
GitHub user snuyanzin opened a pull request:

https://github.com/apache/flink/pull/6233

[FLINK-9696] Deep toString for array/map sql types

*Thank you very much for contributing to Apache Flink - we are happy that 
you want to help us improve Flink. To help the community review your 
contribution in the best possible way, please go through the checklist below, 
which will get the contribution into a shape in which it can be best reviewed.*

*Please understand that we do not do this to make contributions to Flink a 
hassle. In order to uphold a high standard of quality for code contributions, 
while at the same time managing a large number of contributions, we need 
contributors to prepare the contributions well, and give reviewers enough 
contextual information for the review. Please also understand that 
contributions that do not follow this guide will take longer to review and thus 
typically be picked up with lower priority by the community.*

## Contribution Checklist

  - Make sure that the pull request corresponds to a [JIRA 
issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are 
made for typos in JavaDoc or documentation files, which need no JIRA issue.
  
  - Name the pull request in the form "[FLINK-] [component] Title of 
the pull request", where *FLINK-* should be replaced by the actual issue 
number. Skip *component* if you are unsure about which is the best component.
  Typo fixes that have no associated JIRA issue should be named following 
this pattern: `[hotfix] [docs] Fix typo in event time introduction` or 
`[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.

  - Fill out the template below to describe the changes contributed by the 
pull request. That will give reviewers the context they need to do the review.
  
  - Make sure that the change passes the automated tests, i.e., `mvn clean 
verify` passes. You can set up Travis CI to do that following [this 
guide](http://flink.apache.org/contribute-code.html#best-practices).

  - Each pull request should address only one issue, not mix up code from 
multiple issues.
  
  - Each commit in the pull request has a meaningful commit message 
(including the JIRA id)

  - Once all items of the checklist are addressed, remove the above text 
and this checklist, leaving only the filled out template below.


**(The sections below can be removed for hotfixes of typos)**

## What is the purpose of the change

*(For example: This pull request makes task deployment go through the blob 
server, rather than through RPC. That way we avoid re-transferring them on each 
deployment (during recovery).)*


## Brief change log

*(for example:)*
  - *Make it possible to have array/map types human readable*


## Verifying this change

*run queries from from the description*

## Does this pull request potentially affect one of the following parts:

  - Dependencies (does it add or upgrade a dependency): (no)
  - The public API, i.e., is any changed class annotated with 
`@Public(Evolving)`: (no)
  - The serializers: (no)
  - The runtime per-record code paths (performance sensitive): (no)
  - Anything that affects deployment or recovery: JobManager (and its 
components), Checkpointing, Yarn/Mesos, ZooKeeper: (no)
  - The S3 file system connector: (no)

## Documentation

  - Does this pull request introduce a new feature? (no)
  - If yes, how is the feature documented? (not applicable)


You can merge this pull request into a Git repository by running:

$ git pull https://github.com/snuyanzin/flink FLINK_9696

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/6233.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #6233


commit 97b648cc87a494c95f4a5146891285e85db3ae1b
Author: snuyanzin 
Date:   2018-06-30T14:42:57Z

[FLINK-9696] Deep toString for array/map sql types




---