-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Lahari Guduru <lahariguduru@google.com>
- Loading branch information
1 parent
ba27c36
commit 7c07f7f
Showing
2 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
sdks/java/io/csv/src/main/java/org/apache/beam/sdk/io/csv/CsvIOParse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* 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.beam.sdk.io.csv; | ||
|
||
import org.apache.beam.sdk.schemas.Schema; | ||
import org.apache.beam.sdk.transforms.DoFn; | ||
import org.apache.beam.sdk.transforms.PTransform; | ||
import org.apache.beam.sdk.transforms.ParDo; | ||
import org.apache.beam.sdk.values.PCollection; | ||
|
||
/** | ||
* CsvIO master class that takes an input of {@link PCollection<String>} and outputs custom type | ||
* {@link PCollection<T>}. | ||
*/ | ||
// TODO(https://github.com/apache/beam/issues/31877): Plan for implementation after all dependencies | ||
// are completed. | ||
class CsvIOParse<T> extends PTransform<PCollection<String>, PCollection<T>> { | ||
|
||
/** Stores required parameters for parsing. */ | ||
private final CsvIOParseConfiguration.Builder configBuilder; | ||
|
||
CsvIOParse(CsvIOParseConfiguration.Builder configBuilder) { | ||
this.configBuilder = configBuilder; | ||
} | ||
|
||
@Override | ||
public PCollection<T> expand(PCollection<String> input) { | ||
// TODO: Remove dependency to build CsvIOConfiguration with future PR, needed to pass checks. | ||
configBuilder.build(); | ||
return input.apply(ParDo.of(new DoFn<String, T>() {})); | ||
} | ||
|
||
/** Parses to custom type not specified under {@link Schema.FieldType}. */ | ||
// TODO(https://github.com/apache/beam/issues/31875): Implement method. | ||
void withCustomRecordParsing() {} | ||
|
||
/** Parses cell to emit the value, as well as potential errors with filename. */ | ||
// TODO(https://github.com/apache/beam/issues/31876):Implement method. | ||
Object parseCell(String cell, Schema.Field field) { | ||
return ""; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
sdks/java/io/csv/src/test/java/org/apache/beam/sdk/io/csv/CsvIOParseTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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.beam.sdk.io.csv; | ||
|
||
import org.apache.beam.sdk.util.SerializableUtils; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
/** Tests for {@link CsvIOParse}. */ | ||
@RunWith(JUnit4.class) | ||
public class CsvIOParseTest { | ||
@Test | ||
public void isSerializable() { | ||
SerializableUtils.ensureSerializable(CsvIOParse.class); | ||
} | ||
} |