You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by kirill-morozov-epam <gi...@git.apache.org> on 2016/09/07 12:32:56 UTC

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

GitHub user kirill-morozov-epam opened a pull request:

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

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

    

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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/flink/pull/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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2477: [FLINK-4506] CsvOutputFormat defaults allowNullValues to ...

Posted by fhueske <gi...@git.apache.org>.
Github user fhueske commented on the issue:

    https://github.com/apache/flink/pull/2477
  
    I agree with @zentol. `this.allowNullValues = false;` is the behavior since the initial code import. I would not change this and rather fix the JavaDocs.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2477#discussion_r80887299
  
    --- 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 --
    
    The temporary file is created within `open()` and will not be cleaned up.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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

Posted by fhueske <gi...@git.apache.org>.
Github user fhueske commented on a diff in the pull request:

    https://github.com/apache/flink/pull/2477#discussion_r82594396
  
    --- 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 --
    
    Please use `File.createTempFile()` to create a file in the default temp space.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2477: [FLINK-4506] CsvOutputFormat defaults allowNullValues to ...

Posted by zentol <gi...@git.apache.org>.
Github user zentol commented on the issue:

    https://github.com/apache/flink/pull/2477
  
    I think should rather adjust the documentation to fit the current behavior. This discrepancy wasn't just introduced recently, as far as i can tell it has been there forever, or rather since the allowNullValues flag was introduced.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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

Posted by kirill-morozov-epam <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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

Posted by kirill-morozov-epam <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] flink issue #2477: [FLINK-4506] CsvOutputFormat defaults allowNullValues to ...

Posted by fhueske <gi...@git.apache.org>.
Github user fhueske commented on the issue:

    https://github.com/apache/flink/pull/2477
  
    Thanks for the update @kirill-morozov-epam!
    Merging


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---