[GitHub] flink pull request #2477: [FLINK-4506] CsvOutputFormat defaults allowNullVal...

2016-10-10 Thread kirill-morozov-epam
Github user kirill-morozov-epam commented on a diff in the pull request:

https://github.com/apache/flink/pull/2477#discussion_r82622593
  
--- Diff: 
flink-java/src/test/java/org/apache/flink/api/java/io/CsvOutputFormatTest.java 
---
@@ -0,0 +1,72 @@
+/*
+ * 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.api.java.io;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.flink.api.common.io.FileOutputFormat;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+
+public class CsvOutputFormatTest {
+
+   private static final Path PATH = new Path("csv_output_test_file.csv");
--- End diff --

Fixed in 
https://github.com/apache/flink/pull/2477/commits/e789411651ab7a932acf15662977a13ae2833b57


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2477: [FLINK-4506] CsvOutputFormat defaults allowNullVal...

2016-09-28 Thread kirill-morozov-epam
Github user kirill-morozov-epam commented on a diff in the pull request:

https://github.com/apache/flink/pull/2477#discussion_r80901404
  
--- Diff: 
flink-java/src/test/java/org/apache/flink/api/java/io/CsvOutputFormatTest.java 
---
@@ -0,0 +1,63 @@
+/*
+ * 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.api.java.io;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.flink.api.common.io.FileOutputFormat;
+import org.apache.flink.api.java.tuple.Tuple3;
+import org.apache.flink.core.fs.FSDataInputStream;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.core.fs.Path;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.nio.charset.StandardCharsets;
+
+public class CsvOutputFormatTest {
+
+   private static final Path PATH = new Path("csv_output_test_file.csv");
+
+   @Test
+   public void testNullAllow() throws Exception {
+   CsvOutputFormat<Tuple3<String, String, Integer>> 
csvOutputFormat = new CsvOutputFormat<Tuple3<String, String, Integer>>(PATH);
+   csvOutputFormat.setWriteMode(FileSystem.WriteMode.OVERWRITE);
+   
csvOutputFormat.setOutputDirectoryMode(FileOutputFormat.OutputDirectoryMode.PARONLY);
+   csvOutputFormat.setAllowNullValues(true);
+   csvOutputFormat.open(0, 1);
+   csvOutputFormat.writeRecord(new Tuple3<String, String, 
Integer>("One", null, 8));
+   csvOutputFormat.close();
+   final FileSystem fs = PATH.getFileSystem();
+   Assert.assertTrue(fs.exists(PATH));
+   FSDataInputStream inputStream = fs.open(PATH);
+   String csvContent = IOUtils.toString(inputStream, 
StandardCharsets.UTF_8);
+   Assert.assertEquals("One,,8\n", csvContent);
+   fs.delete(PATH, true);
+   }
+
+   @Test(expected = RuntimeException.class)
+   public void testNullDisallowOnDefault() throws Exception {
+   CsvOutputFormat<Tuple3<String, String, Integer>> 
csvOutputFormat = new CsvOutputFormat<Tuple3<String, String, Integer>>(PATH);
+   csvOutputFormat.setWriteMode(FileSystem.WriteMode.OVERWRITE);
+   
csvOutputFormat.setOutputDirectoryMode(FileOutputFormat.OutputDirectoryMode.PARONLY);
+   csvOutputFormat.open(0, 1);
+   csvOutputFormat.writeRecord(new Tuple3<String, String, 
Integer>("One", null, 8));
+   csvOutputFormat.close();
--- End diff --

Fixed in 
https://github.com/apache/flink/pull/2477/commits/6d06d0e03e12ced8fe11e164488f1102682704d1


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] flink pull request #2477: [FLINK-4506] CsvOutputFormat defaults allowNullVal...

2016-09-07 Thread kirill-morozov-epam
GitHub user kirill-morozov-epam opened a pull request:

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

[FLINK-4506] CsvOutputFormat defaults allowNullValues to false, even …



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

$ git pull https://github.com/kirill-morozov-epam/flink FLINK-4506

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

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






---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---