Skip to content

Conversation

sryza
Copy link
Contributor

@sryza sryza commented Oct 4, 2025

What changes were proposed in this pull request?

When defining a streaming table or materialized view, enable passing a string to its schema, in addition to a StructType. This mimics the flexibility of the DataFrameReader schema arg.

E.g.

from pyspark.sql.functions import lit

@dp.materialized_view(schema="id LONG, name STRING")
def table_with_string_schema():
    return spark.range(5).withColumn("name", lit("test"))

Why are the changes needed?

For flexibility and consistency with similar args.

Does this PR introduce any user-facing change?

Makes changes to unreleased protos.

How was this patch tested?

Was this patch authored or co-authored using generative AI tooling?

@sryza sryza force-pushed the dataset-schema-string branch from 50b839e to cb8ba44 Compare October 6, 2025 14:02
assert(graph.tables.size == 1)

val table = graph.table(graphIdentifier("table_with_string_schema"))
assert(table.specifiedSchema.isDefined)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shall we simply compare table.specifiedSchema with an expected schema (for example, StructType.fromDDL(id LONG, name STRING))

optional spark.connect.DataType schema = 7;
oneof schema {
spark.connect.DataType schema_data_type = 7;
string schema_string = 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since Spark 4.1 is not offically released. I wonder if we can change the sequence numbers here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants