From 2206af2207803f5e2ec9fbc0d67fab446af22b17 Mon Sep 17 00:00:00 2001 From: lovasoa Date: Fri, 16 May 2025 22:20:52 +0200 Subject: [PATCH] pretty-print CREATE VIEW statements --- src/ast/mod.rs | 4 +++- tests/pretty_print.rs | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index d711a1062..e18251ea2 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -4858,7 +4858,9 @@ impl fmt::Display for Statement { if matches!(options, CreateTableOptions::Options(_)) { write!(f, " {options}")?; } - write!(f, " AS {query}")?; + f.write_str(" AS")?; + SpaceOrNewline.fmt(f)?; + query.fmt(f)?; if *with_no_schema_binding { write!(f, " WITH NO SCHEMA BINDING")?; } diff --git a/tests/pretty_print.rs b/tests/pretty_print.rs index b4adbe352..1c84d1553 100644 --- a/tests/pretty_print.rs +++ b/tests/pretty_print.rs @@ -265,7 +265,6 @@ CREATE TABLE my_table ( } #[test] -#[ignore = "https://github.com/apache/datafusion-sqlparser-rs/issues/1850"] fn test_pretty_print_create_view() { assert_eq!( prettify("CREATE VIEW my_view AS SELECT a, b FROM my_table WHERE x > 0"),