Skip to content

Commit 2509e07

Browse files
committed
amend schemas - x use struct
1 parent 57efd97 commit 2509e07

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

datafusion-examples/examples/nested_struct2.rs

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,7 @@ fn create_schema2() -> Arc<Schema> {
210210
.map(|f| f.as_ref().clone())
211211
.collect::<Vec<Field>>();
212212

213-
// Add the query_params field
214-
fields.push(Field::new(
215-
"query_params",
216-
DataType::Struct(vec![Field::new("customer_id", DataType::Utf8, true)].into()),
217-
true,
218-
));
213+
fields.push(Field::new("new_utf_field", DataType::Utf8, true));
219214

220215
// Create a new schema with the extended fields
221216
Arc::new(Schema::new(fields))
@@ -243,32 +238,16 @@ fn create_schema3() -> Arc<Schema> {
243238
/// Creates a schema with HTTP request fields, expanded query_params struct with additional fields, and an error field
244239
fn create_schema4() -> Arc<Schema> {
245240
// Get the base schema from create_schema1 (we can't use schema3 directly since we need to modify query_params)
246-
let schema1 = create_schema1();
241+
let schema3 = create_schema3();
247242

248243
// Convert to a vector of fields
249-
let mut fields = schema1
244+
let mut fields = schema3
250245
.fields()
251246
.iter()
252247
.map(|f| f.as_ref().clone())
253248
.collect::<Vec<Field>>();
254249

255-
// Add the expanded query_params field with additional fields
256-
fields.push(Field::new(
257-
"query_params",
258-
DataType::Struct(
259-
vec![
260-
Field::new("customer_id", DataType::Utf8, true),
261-
Field::new("document_type", DataType::Utf8, true),
262-
Field::new("fetch_from_source", DataType::Utf8, true),
263-
Field::new("source_system", DataType::Utf8, true),
264-
]
265-
.into(),
266-
),
267-
true,
268-
));
269-
270-
// Add the error field
271-
fields.push(Field::new("error", DataType::Utf8, true));
250+
fields.push(Field::new("new_utf_field2", DataType::Utf8, true));
272251

273252
// Create a new schema with the extended fields
274253
Arc::new(Schema::new(fields))

0 commit comments

Comments
 (0)