@@ -49,19 +49,27 @@ public final class SessionContext implements AutoCloseable {
4949 }
5050
5151 private long nativeHandle ;
52+ // Snapshot of the builder's exceptionVerbosity, passed through to UDF /
53+ // TableProvider registrations. Locked at construction time; not mutable.
54+ // Default FULL keeps stack traces flowing for callers that don't touch the
55+ // setter. Stored as a byte to keep the JNI signature ABI-stable across any
56+ // future ExceptionVerbosity additions.
57+ private final byte exceptionVerbosity ;
5258
5359 public SessionContext () {
5460 this .nativeHandle = createSessionContext ();
5561 if (this .nativeHandle == 0 ) {
5662 throw new RuntimeException ("Failed to create native SessionContext" );
5763 }
64+ this .exceptionVerbosity = ExceptionVerbosity .FULL .toByte ();
5865 }
5966
60- SessionContext (byte [] optionsBytes ) {
67+ SessionContext (byte [] optionsBytes , ExceptionVerbosity exceptionVerbosity ) {
6168 this .nativeHandle = createSessionContextWithOptions (optionsBytes );
6269 if (this .nativeHandle == 0 ) {
6370 throw new RuntimeException ("Failed to create native SessionContext" );
6471 }
72+ this .exceptionVerbosity = exceptionVerbosity .toByte ();
6573 }
6674
6775 /** Start configuring a {@link SessionContext}. */
@@ -550,7 +558,8 @@ public void registerUdf(ScalarUdf udf) {
550558 fields .addAll (udf .argFields ());
551559 Schema signatureSchema = new Schema (fields );
552560 byte [] signatureBytes = serializeSchemaIpc (signatureSchema );
553- registerScalarUdf (nativeHandle , name , signatureBytes , volatility .code (), impl );
561+ registerScalarUdf (
562+ nativeHandle , name , signatureBytes , volatility .code (), impl , exceptionVerbosity );
554563 }
555564
556565 /**
@@ -585,7 +594,7 @@ public void registerTable(String name, TableProvider provider) {
585594 throw new IllegalStateException ("TableProvider.schema returned null" );
586595 }
587596 byte [] schemaIpc = serializeSchemaIpc (schema );
588- registerTableNative (nativeHandle , name , schemaIpc , provider );
597+ registerTableNative (nativeHandle , name , schemaIpc , provider , exceptionVerbosity );
589598 }
590599
591600 private static byte [] serializeSchemaIpc (Schema schema ) {
@@ -660,8 +669,17 @@ private static native long readJsonWithOptions(
660669 private static native void closeSessionContext (long handle );
661670
662671 private static native void registerScalarUdf (
663- long handle , String name , byte [] signatureSchemaBytes , byte volatility , ScalarFunction impl );
672+ long handle ,
673+ String name ,
674+ byte [] signatureSchemaBytes ,
675+ byte volatility ,
676+ ScalarFunction impl ,
677+ byte exceptionVerbosity );
664678
665679 private static native void registerTableNative (
666- long handle , String name , byte [] schemaIpcBytes , TableProvider provider );
680+ long handle ,
681+ String name ,
682+ byte [] schemaIpcBytes ,
683+ TableProvider provider ,
684+ byte exceptionVerbosity );
667685}
0 commit comments