Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go SDK]: Retrieve element type from input PCollection in parquetio.Write #28491

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@

* Removed fastjson library dependency for Beam SQL. Table property is changed to be based on jackson ObjectNode (Java) ([#24154](https://github.com/apache/beam/issues/24154)).
* Removed TensorFlow from Beam Python container images [PR](https://github.com/apache/beam/pull/28424). If you have been negatively affected by this change, please comment on [#20605](https://github.com/apache/beam/issues/20605).
* Removed the parameter `t reflect.Type` from `parquetio.Write`. The element type is derived from the input PCollection (Go) ([#28490](https://github.com/apache/beam/issues/28490))

## Deprecations

Expand Down
5 changes: 3 additions & 2 deletions sdks/go/pkg/beam/io/parquetio/parquetio.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (a *parquetReadFn) ProcessElement(ctx context.Context, file fileio.Readable
}

// Write writes a PCollection<parquetStruct> to .parquet file.
// Write expects a type t of struct with parquet tags
// Write expects elements of a struct type with parquet tags
// For example:
//
// type Student struct {
Expand All @@ -108,7 +108,8 @@ func (a *parquetReadFn) ProcessElement(ctx context.Context, file fileio.Readable
// Day int32 `parquet:"name=day, type=INT32, convertedtype=DATE"`
// Ignored int32 //without parquet tag and won't write
// }
func Write(s beam.Scope, filename string, t reflect.Type, col beam.PCollection) {
func Write(s beam.Scope, filename string, col beam.PCollection) {
t := col.Type().Type()
s = s.Scope("parquetio.Write")
filesystem.ValidateScheme(filename)
pre := beam.AddFixedKey(s, col)
Expand Down
2 changes: 1 addition & 1 deletion sdks/go/pkg/beam/io/parquetio/parquetio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestWrite(t *testing.T) {
}
p, s, sequence := ptest.CreateList(studentList)
parquetFile := "./write_student.parquet"
Write(s, parquetFile, reflect.TypeOf(Student{}), sequence)
Write(s, parquetFile, sequence)
t.Cleanup(func() {
os.Remove(parquetFile)
})
Expand Down
Loading