sirenbyte commented on code in PR #26861: URL: https://github.com/apache/beam/pull/26861#discussion_r1241587101
########## learning/tour-of-beam/learning-content/final-challenge/final-challenge-1/description.md: ########## @@ -0,0 +1,25 @@ +<!-- +Licensed 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. +--> +### Final challenge 1 + +You’re given a csv file with purchase transactions. Write a Beam pipeline to prepare a send report every 30 seconds. The report needs to be created only for transactions where quantity is more than 20. Review Comment: Done ########## learning/tour-of-beam/learning-content/final-challenge/final-challenge-1/description.md: ########## @@ -0,0 +1,25 @@ +<!-- +Licensed 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. +--> +### Final challenge 1 + +You’re given a csv file with purchase transactions. Write a Beam pipeline to prepare a send report every 30 seconds. The report needs to be created only for transactions where quantity is more than 20. + +Report should consist of two files named "**price more than 10**" and "**price less than 10**": Review Comment: Done ########## learning/tour-of-beam/learning-content/final-challenge/final-challenge-1/description.md: ########## @@ -0,0 +1,25 @@ +<!-- +Licensed 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. +--> +### Final challenge 1 + +You’re given a csv file with purchase transactions. Write a Beam pipeline to prepare a send report every 30 seconds. The report needs to be created only for transactions where quantity is more than 20. + +Report should consist of two files named "**price more than 10**" and "**price less than 10**": + +* Total transactions amount grouped by **ProductNo** for products with **price** greater than 10 +* Total transactions amount grouped by **ProductNo** for products with **price** less than 10 + +| TransactionNo | Date | ProductNo | ProductName | Price | Quantity | CustomerNo | Country | Review Comment: Done ########## learning/tour-of-beam/learning-content/final-challenge/final-challenge-1/go-challenge/main.go: ########## @@ -0,0 +1,65 @@ +/* + * 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. + */ + +// beam-playground: +// name: FinalChallenge1 +// description: Final challenge 1. +// multifile: true +// files: +// - name: input.csv +// context_line: 54 +// categories: +// - Quickstart +// complexity: ADVANCED +// tags: +// - hellobeam + +package main + +import ( + "context" + "github.com/apache/beam/sdks/v2/go/pkg/beam" + "github.com/apache/beam/sdks/v2/go/pkg/beam/io/textio" + "github.com/apache/beam/sdks/v2/go/pkg/beam/x/beamx" + "log" +) + +type Transaction struct { + ID int64 + Date string + ProductID string + ProductName string + Price float64 + Quantity int64 + CustomerID int64 + Country string +} + +func main() { + beam.Init() + p := beam.NewPipeline() + s := p.Root() + + file := textio.Read(s, "input.csv") + + textio.Write(s, "smallerThan10.txt", file) Review Comment: Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
