gemini-code-assist[bot] commented on code in PR #35952:
URL: https://github.com/apache/beam/pull/35952#discussion_r2298756975


##########
website/www/site/content/en/documentation/sdks/yaml-schema.md:
##########
@@ -0,0 +1,107 @@
+---
+type: languages
+title: "Apache Beam YAML Schema"
+---
+<!--
+    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 YAML Schema
+
+As pipelines grow in size and complexity, it becomes more common to encounter
+data that is malformed, doesn't meet preconditions, or otherwise causes issues
+during processing.
+
+Beam YAML helps the user detect and capture these issues by using the optional
+`output_schema` configuration, which is available for any transform in the YAML
+SDK. For example, the following code creates a few "good" records and specifies
+that the output schema from the `Create` transform should have records that
+follow the expected schema: `sdk` as a string and `year` as an integer.
+
+```yaml
+pipeline:
+  type: chain
+  transforms:
+    - type: Create
+      config:
+        elements:
+          - {sdk: MapReduce, year: 2004}
+          - {sdk: MillWheel, year: 2008}
+        output_schema:
+          type: object
+          properties:
+            sdk:
+              type: string
+            year:
+              type: integer
+    - type: AssertEqual
+      config:
+        elements:
+          - {sdk: MapReduce, year: 2004}
+          - {sdk: MillWheel, year: 2008}
+```
+
+More than likely though a user will want to detect errors with schemas like
+that and thats where tagging an additional `error_handling` config inside the
+`output_schema` config comes into play. For example, the following code will

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   This sentence is a bit long and contains a typo ('thats' should be 
'that's'). Consider rephrasing for clarity and correctness.
   
   ```suggestion
   However, a user will more likely want to detect and handle schema errors. 
This is where adding an `error_handling` configuration inside the 
`output_schema` comes into play. For example, the following code will
   ```



##########
sdks/python/apache_beam/yaml/tests/create.yaml:
##########
@@ -115,3 +115,63 @@ pipelines:
               - {sdk: MapReduce, year: 2004}
               - {}
               - {sdk: MillWheel, year: 2008}
+
+  # Simple Create with output schema check
+  - pipeline:
+      type: chain
+      transforms:
+        - type: Create
+          config:
+            elements:
+              - {sdk: MapReduce, year: 2004}
+              - {sdk: MillWheel, year: 2008}
+            output_schema:
+              type: object
+              properties:
+                sdk:
+                  type: string
+                year:
+                  type: integer
+        - type: AssertEqual
+          config:
+            elements:
+              - {sdk: MapReduce, year: 2004}
+              - {sdk: MillWheel, year: 2008}
+
+  # Simple Create with output schema and error handling
+  - pipeline:
+      type: composite
+      transforms:
+        - type: Create
+          config:
+            elements:
+              - {sdk: MapReduce, year: 2004}
+              - {sdk: CheeseWheel, year: "apple"}
+              - {sdk: MillWheel, year: 2008}
+            output_schema:
+              type: object
+              properties:
+                sdk:
+                  type: string
+                year:
+                  type: integer
+              error_handling:
+                output: invalid_rows
+        - type: MapToFields
+          input: Create.invalid_rows
+          config:
+            language: python
+            fields: 
+              sdk: "element.sdk"
+              year: "element.year"   

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There are some extra trailing spaces on these lines. While this doesn't 
affect the test execution, removing them would improve code cleanliness.
   
   ```yaml
               fields:
                 sdk: "element.sdk"
                 year: "element.year"
   ```



##########
website/www/site/content/en/documentation/sdks/yaml-schema.md:
##########
@@ -0,0 +1,107 @@
+---
+type: languages
+title: "Apache Beam YAML Schema"
+---
+<!--
+    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 YAML Schema
+
+As pipelines grow in size and complexity, it becomes more common to encounter
+data that is malformed, doesn't meet preconditions, or otherwise causes issues
+during processing.
+
+Beam YAML helps the user detect and capture these issues by using the optional
+`output_schema` configuration, which is available for any transform in the YAML
+SDK. For example, the following code creates a few "good" records and specifies
+that the output schema from the `Create` transform should have records that
+follow the expected schema: `sdk` as a string and `year` as an integer.
+
+```yaml
+pipeline:
+  type: chain
+  transforms:
+    - type: Create
+      config:
+        elements:
+          - {sdk: MapReduce, year: 2004}
+          - {sdk: MillWheel, year: 2008}
+        output_schema:
+          type: object
+          properties:
+            sdk:
+              type: string
+            year:
+              type: integer
+    - type: AssertEqual
+      config:
+        elements:
+          - {sdk: MapReduce, year: 2004}
+          - {sdk: MillWheel, year: 2008}
+```
+
+More than likely though a user will want to detect errors with schemas like
+that and thats where tagging an additional `error_handling` config inside the
+`output_schema` config comes into play. For example, the following code will
+create a few "good" and "bad" records with a specified schema of `sdk` as a
+string and `year` as an integer with error_handling output going to invalid
+rows. An additonal `MapToFields` transform will take the error_handling output

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   There's a typo here: 'additonal' should be 'additional'.
   
   ```suggestion
   rows. An additional `MapToFields` transform will take the error_handling 
output
   ```



-- 
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: github-unsubscr...@beam.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to