@@ -96,7 +96,7 @@ public class TrinoQueryProperties
9696 private Set <String > schemas = ImmutableSet .of ();
9797 private Set <String > catalogSchemas = ImmutableSet .of ();
9898 private boolean isNewQuerySubmission ;
99- private boolean isQueryParsingSuccessful ;
99+ private Optional < String > errorMessage = Optional . empty () ;
100100
101101 public static final String TRINO_CATALOG_HEADER_NAME = "X-Trino-Catalog" ;
102102 public static final String TRINO_SCHEMA_HEADER_NAME = "X-Trino-Schema" ;
@@ -114,7 +114,7 @@ public TrinoQueryProperties(
114114 @ JsonProperty ("schemas" ) Set <String > schemas ,
115115 @ JsonProperty ("catalogSchemas" ) Set <String > catalogSchemas ,
116116 @ JsonProperty ("isNewQuerySubmission" ) boolean isNewQuerySubmission ,
117- @ JsonProperty ("isQueryParsingSuccessful " ) boolean isQueryParsingSuccessful )
117+ @ JsonProperty ("errorMessage " ) Optional < String > errorMessage )
118118 {
119119 this .body = requireNonNullElse (body , "" );
120120 this .queryType = requireNonNullElse (queryType , "" );
@@ -126,7 +126,7 @@ public TrinoQueryProperties(
126126 this .schemas = requireNonNullElse (schemas , ImmutableSet .of ());
127127 this .catalogSchemas = requireNonNullElse (catalogSchemas , ImmutableSet .of ());
128128 this .isNewQuerySubmission = isNewQuerySubmission ;
129- this .isQueryParsingSuccessful = isQueryParsingSuccessful ;
129+ this .errorMessage = requireNonNullElse ( errorMessage , Optional . empty ()) ;
130130 isClientsUseV2Format = false ;
131131 }
132132
@@ -208,19 +208,18 @@ else if (statement instanceof ExecuteImmediate executeImmediate) {
208208 catalogSchemaBuilder .addAll (
209209 tables .stream ().map (qualifiedName -> format ("%s.%s" , qualifiedName .getParts ().getFirst (), qualifiedName .getParts ().get (1 ))).iterator ());
210210 catalogSchemas = catalogSchemaBuilder .build ();
211- isQueryParsingSuccessful = true ;
212211 }
213212 catch (IOException e ) {
214213 log .warn ("Error extracting request body for rules processing: %s" , e .getMessage ());
215- isQueryParsingSuccessful = false ;
214+ errorMessage = Optional . of ( e . getMessage ()) ;
216215 }
217216 catch (ParsingException e ) {
218217 log .info ("Could not parse request body as SQL: %s; Message: %s" , body , e .getMessage ());
219- isQueryParsingSuccessful = false ;
218+ errorMessage = Optional . of ( e . getMessage ()) ;
220219 }
221220 catch (RequestParsingException e ) {
222221 log .warn (e , "Error parsing request for rules" );
223- isQueryParsingSuccessful = false ;
222+ errorMessage = Optional . of ( e . getMessage ()) ;
224223 }
225224 }
226225
@@ -291,7 +290,7 @@ private void getNames(Node node, ImmutableSet.Builder<QualifiedName> tableBuilde
291290 targetSchema = QualifiedName .of (defaultCatalog .orElseThrow (), s .getTarget ().getValue ());
292291 }
293292 else {
294- isQueryParsingSuccessful = false ;
293+ errorMessage = Optional . of ( "defaultCatalog is not present" ) ;
295294 return ;
296295 }
297296 }
@@ -379,7 +378,6 @@ private void setCatalogAndSchemaNameFromSchemaQualifiedName(
379378
380379 private RequestParsingException unsetDefaultExceptionSupplier ()
381380 {
382- isQueryParsingSuccessful = false ;
383381 return new RequestParsingException ("Name not fully qualified" );
384382 }
385383
@@ -513,7 +511,13 @@ public boolean isNewQuerySubmission()
513511 @ JsonProperty ("isQueryParsingSuccessful" )
514512 public boolean isQueryParsingSuccessful ()
515513 {
516- return isQueryParsingSuccessful ;
514+ return errorMessage .isEmpty ();
515+ }
516+
517+ @ JsonProperty
518+ public Optional <String > getErrorMessage ()
519+ {
520+ return errorMessage ;
517521 }
518522
519523 public static class AlternateStatementRequestBodyFormat
0 commit comments