@@ -122,6 +122,8 @@ pub fn fixture_tables(sources: &str) -> String {
122122struct Catalog {
123123 schema : Schema ,
124124 columns : BTreeMap < String , Vec < SchemaColumn > > ,
125+ /// Why a source is left out, as `sqlquack convert` warns about it.
126+ warnings : Vec < String > ,
125127}
126128
127129impl LineageSchema for Catalog {
@@ -130,16 +132,13 @@ impl LineageSchema for Catalog {
130132 }
131133}
132134
133- /// The source file `text`, read as `sqlquack convert` reads a project's `sources/*.yml`; a source
134- /// left out for an untyped column is an error, so the playground says why .
135+ /// The source file `text`, read as `sqlquack convert` reads a project's `sources/*.yml`: a source
136+ /// left out for a column without a type SQLQuack reads is a warning, and the rest still declare .
135137fn catalog ( text : & str ) -> Result < Catalog , String > {
136138 if text. trim ( ) . is_empty ( ) {
137139 return Ok ( Catalog :: default ( ) ) ;
138140 }
139141 let found = source_tables ( text) ?;
140- if !found. warnings . is_empty ( ) {
141- return Err ( found. warnings . join ( "; " ) ) ;
142- }
143142 let relations: serde_json:: Map < String , Value > = found. tables . into_iter ( ) . collect ( ) ;
144143 let schema =
145144 parse_schema ( & json ! ( { "relations" : relations } ) . to_string ( ) ) . map_err (
@@ -163,7 +162,11 @@ fn catalog(text: &str) -> Result<Catalog, String> {
163162 ( relation. clone ( ) , named)
164163 } )
165164 . collect ( ) ;
166- Ok ( Catalog { schema, columns } )
165+ Ok ( Catalog {
166+ schema,
167+ columns,
168+ warnings : found. warnings ,
169+ } )
167170}
168171
169172/// The playground's policy and session settings.
@@ -249,11 +252,21 @@ fn placed(mut refusal: Refusal, statement: &Expression, lines: &SourceLines) ->
249252 refusal
250253}
251254
255+ /// Every stage's result for `sql` over `sources`, with a warning for each source left out.
252256fn report ( sql : & str , sources : & str , settings : & str ) -> Value {
253257 let catalog = match catalog ( sources) {
254258 Ok ( catalog) => catalog,
255259 Err ( error) => return json ! ( { "sources_error" : error } ) ,
256260 } ;
261+ let mut report = stages ( sql, & catalog, settings) ;
262+ if !catalog. warnings . is_empty ( ) {
263+ report[ "warnings" ] = json ! ( catalog. warnings) ;
264+ }
265+ report
266+ }
267+
268+ /// Each stage's result for `sql` over `catalog`, as JSON.
269+ fn stages ( sql : & str , catalog : & Catalog , settings : & str ) -> Value {
257270 let settings: Settings = match settings. trim ( ) {
258271 "" => Settings :: default ( ) ,
259272 text => match serde_json:: from_str ( text) {
@@ -293,7 +306,7 @@ fn report(sql: &str, sources: &str, settings: &str) -> Value {
293306 ( false , 1 ) => {
294307 let context = LineageContext {
295308 profile : & SNOWFLAKE ,
296- schema : & catalog,
309+ schema : catalog,
297310 sql : Some ( sql) ,
298311 } ;
299312 query_name_findings ( sql, Dialect :: Snowflake , & ParseOptions :: default ( ) , context)
0 commit comments