@@ -91,19 +91,26 @@ private void loadData(Client client) {
9191 insertSettings .compressClientRequest (true );
9292 try (InsertResponse response = client .insert (table , out -> {
9393 // use DataWriter to avoid tmp storage.
94+ //
95+ // DON'T: swallow exceptions thrown by the Arrow writer here. If the writer fails
96+ // mid-stream (I/O error, allocator failure, etc.), only a partial Arrow stream
97+ // reaches the server. The request may still complete and `getWrittenRows()` would
98+ // then misreport success. Always let the exception propagate so the surrounding
99+ // `client.insert(...).get()` fails and the caller sees the real error.
94100 try (ArrowWriter arrowWriter = new ArrowStreamWriter (vectorSchemaRoot , /* provider = */ null , out )) {
95101 arrowWriter .start ();
96102 arrowWriter .writeBatch ();
97103 arrowWriter .end ();
98-
99104 } catch (Exception e ) {
100105 LOG .error ("Failed writing data to output stream" , e );
106+ throw new RuntimeException ("Failed writing Arrow data to output stream" , e );
101107 }
102108 }, ClickHouseFormat .ArrowStream , // Use Arrow Stream Format
103109 insertSettings ).get ()) {
104110 LOG .info ("Data inserted {}" , response .getWrittenRows ());
105111 } catch (Exception e ) {
106112 LOG .error ("Failed to write data to DB" , e );
113+ throw new RuntimeException ("Failed to insert Arrow data" , e );
107114 }
108115 }
109116 }
@@ -171,8 +178,13 @@ private void readData(Client client) {
171178 }
172179
173180 }
181+ // DON'T: the inner ArrowStreamWriter above intentionally has no catch block.
182+ // Letting exceptions propagate out of the insert callback ensures
183+ // `client.insert(...).get()` fails loudly instead of completing with
184+ // partial/empty Arrow data and a misleading row count.
174185 } catch (Exception e ) {
175186 LOG .error ("Failed to query" , e );
187+ throw new RuntimeException ("Failed to read/copy Arrow data" , e );
176188 }
177189 }
178190
0 commit comments