suhuruli commented on code in PR #60546:
URL: https://github.com/apache/spark/pull/60546#discussion_r4593209689


##########
examples/src/main/python/pipelines/hello_world/transformations/orders.py:
##########
@@ -0,0 +1,61 @@
+#
+# 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.
+#
+
+"""
+Python datasets for the hello_world pipeline.
+
+- `customers` is a materialized view computed from a small in-line batch 
dataset.
+- `orders` is a streaming table that incrementally ingests the JSON files in 
`data/orders/`.
+  Each run processes only the files that arrived since the previous run.
+"""
+
+from pathlib import Path
+
+from pyspark import pipelines as dp
+from pyspark.sql import DataFrame, SparkSession
+from pyspark.sql.types import IntegerType, StringType, StructField, StructType
+
+# SDP also injects the session as `spark`; assigning it explicitly keeps 
linters happy.
+spark = SparkSession.active()
+
+# Build the URI from the plain path rather than with `Path.as_uri()`, which 
percent-encodes
+# spaces and non-ASCII characters that the file source does not decode.
+ORDERS_DIR = f"file://{(Path(__file__).parent.parent / 'data' / 
'orders').resolve()}"
+
+# A StructType rather than a DDL string: with Spark Connect, a string schema 
is parsed with a
+# separate analysis request, which is not allowed inside a query function.

Review Comment:
   Agreed, the comment overstated it. It now says that `createDataFrame` parses 
a string schema with a separate analysis request, names the error the server 
raises for it (`ATTEMPT_ANALYSIS_IN_PIPELINE_QUERY_FUNCTION`), and points out 
that the `readStream.schema()` call below is fine because it sends the string 
inside the plan. Code lines are unchanged.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to