You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
demo: seed via CTE injection instead of CREATE TEMPORARY VIEW
The e2e run revealed that a DDL/command ExecutePlan over the grpc-web reattach
path livelocks (an infinite ReattachExecute loop), hanging the demo at seeding.
None of the existing passing tests issue a command - only data-returning
queries - so the command path was unexercised.
Define the synthetic retail dataset as CTEs injected into every query, so every
statement sent to Spark is a data-returning SELECT (the working path). The
table picker / DESCRIBE / queries are unchanged from the user's perspective.
Co-authored-by: Isaac
Copy file name to clipboardExpand all lines: demo/index.html
+40-37Lines changed: 40 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -307,49 +307,53 @@ <h2>Starting PySpark in your browser</h2>
307
307
" return v",
308
308
" return str(v)",
309
309
"",
310
-
"def pcw_seed():",
311
-
" # Per-session TEMPORARY VIEWs: deterministic (seeded rand/pmod), so every",
312
-
" # visitor gets the identical dataset, with no warehouse writes or catalog",
313
-
" # config needed - works on any Spark Connect server, and is self-contained.",
314
-
" spark.sql('''CREATE OR REPLACE TEMPORARY VIEW products AS",
315
-
" SELECT id AS product_id,",
316
-
" element_at(array('Widget','Gadget','Gizmo','Doohickey','Sprocket','Cog','Lever','Valve'), cast(pmod(id,8) as int)+1) || ' #' || cast(id as string) AS product_name,",
317
-
" element_at(array('Electronics','Home','Toys','Sports','Office'), cast(pmod(id,5) as int)+1) AS category,",
318
-
" round(5 + rand(id)*195, 2) AS price",
319
-
" FROM range(50)''')",
320
-
" spark.sql('''CREATE OR REPLACE TEMPORARY VIEW customers AS",
321
-
" SELECT id AS customer_id,",
322
-
" 'Customer ' || cast(id as string) AS name,",
323
-
" element_at(array('US','UK','DE','FR','JP','IN','BR','CA'), cast(pmod(id,8) as int)+1) AS country,",
324
-
" date_add(date'2023-01-01', cast(pmod(id*7,700) as int)) AS signup_date",
325
-
" FROM range(200)''')",
326
-
" spark.sql('''CREATE OR REPLACE TEMPORARY VIEW orders AS",
327
-
" SELECT id AS order_id,",
328
-
" cast(pmod(id*31+7, 200) as bigint) AS customer_id,",
329
-
" cast(pmod(id*17+3, 50) as bigint) AS product_id,",
330
-
" cast(1 + pmod(id*13, 5) as int) AS quantity,",
331
-
" date_add(date'2024-01-01', cast(pmod(id*3, 365) as int)) AS order_date",
332
-
" FROM range(5000)''')",
333
-
" _emit({'ok': True})",
310
+
"# The synthetic retail dataset, defined as CTEs (deterministic seeded",
311
+
"# rand/pmod). We inject these into every query so the demo's 'tables' need",
312
+
"# no DDL: every statement sent to Spark is a data-returning SELECT. This is",
313
+
"# deliberate - CREATE/temp-view COMMAND responses currently livelock the",
314
+
"# grpc-web reattach path, while SELECT results work. Same dataset for every",
315
+
"# visitor, no warehouse writes, works on any Spark Connect server.",
316
+
"_CTES = '''",
317
+
" products AS (",
318
+
" SELECT id AS product_id,",
319
+
" element_at(array('Widget','Gadget','Gizmo','Doohickey','Sprocket','Cog','Lever','Valve'), cast(pmod(id,8) as int)+1) || ' #' || cast(id as string) AS product_name,",
320
+
" element_at(array('Electronics','Home','Toys','Sports','Office'), cast(pmod(id,5) as int)+1) AS category,",
321
+
" round(5 + rand(id)*195, 2) AS price",
322
+
" FROM range(50)),",
323
+
" customers AS (",
324
+
" SELECT id AS customer_id,",
325
+
" 'Customer ' || cast(id as string) AS name,",
326
+
" element_at(array('US','UK','DE','FR','JP','IN','BR','CA'), cast(pmod(id,8) as int)+1) AS country,",
327
+
" date_add(date'2023-01-01', cast(pmod(id*7,700) as int)) AS signup_date",
328
+
" FROM range(200)),",
329
+
" orders AS (",
330
+
" SELECT id AS order_id,",
331
+
" cast(pmod(id*31+7, 200) as bigint) AS customer_id,",
332
+
" cast(pmod(id*17+3, 50) as bigint) AS product_id,",
333
+
" cast(1 + pmod(id*13, 5) as int) AS quantity,",
334
+
" date_add(date'2024-01-01', cast(pmod(id*3, 365) as int)) AS order_date",
0 commit comments