@@ -183,7 +183,7 @@ private ImportTargetResult importIntoSingleTable(
183183 .tableName (table )
184184 .status (ImportTargetResultStatus .VALIDATION_FAILED )
185185 .errors (Collections .singletonList (DataLoaderError .TABLE_METADATA_MISSING .buildMessage ()))
186- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
186+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
187187 .build ();
188188 }
189189
@@ -210,7 +210,7 @@ private ImportTargetResult importIntoSingleTable(
210210 .tableName (table )
211211 .status (ImportTargetResultStatus .VALIDATION_FAILED )
212212 .errors (validationResult .getErrorMessages ())
213- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
213+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
214214 .build ();
215215 }
216216
@@ -225,7 +225,7 @@ private ImportTargetResult importIntoSingleTable(
225225 .errors (
226226 Collections .singletonList (
227227 DataLoaderError .COULD_NOT_FIND_PARTITION_KEY .buildMessage ()))
228- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
228+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
229229 .build ();
230230 }
231231 Optional <Key > optionalClusteringKey = Optional .empty ();
@@ -241,7 +241,7 @@ private ImportTargetResult importIntoSingleTable(
241241 .errors (
242242 Collections .singletonList (
243243 DataLoaderError .COULD_NOT_FIND_CLUSTERING_KEY .buildMessage ()))
244- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
244+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
245245 .build ();
246246 }
247247 }
@@ -258,7 +258,7 @@ private ImportTargetResult importIntoSingleTable(
258258 .tableName (table )
259259 .status (ImportTargetResultStatus .RETRIEVAL_FAILED )
260260 .errors (Collections .singletonList (e .getMessage ()))
261- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
261+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
262262 .build ();
263263 }
264264 ImportTaskAction importAction =
@@ -278,7 +278,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
278278 .errors (
279279 Collections .singletonList (
280280 DataLoaderError .UPSERT_INSERT_MISSING_COLUMNS .buildMessage ()))
281- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
281+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
282282 .build ();
283283 }
284284 }
@@ -287,7 +287,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
287287 return ImportTargetResult .builder ()
288288 .namespace (namespace )
289289 .tableName (table )
290- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
290+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
291291 .importAction (importAction )
292292 .status (ImportTargetResultStatus .DATA_ALREADY_EXISTS )
293293 .errors (Collections .singletonList (DataLoaderError .DATA_ALREADY_EXISTS .buildMessage ()))
@@ -298,7 +298,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
298298 return ImportTargetResult .builder ()
299299 .namespace (namespace )
300300 .tableName (table )
301- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
301+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
302302 .importAction (importAction )
303303 .status (ImportTargetResultStatus .DATA_NOT_FOUND )
304304 .errors (Collections .singletonList (DataLoaderError .DATA_NOT_FOUND .buildMessage ()))
@@ -320,7 +320,7 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
320320 return ImportTargetResult .builder ()
321321 .namespace (namespace )
322322 .tableName (table )
323- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
323+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
324324 .status (ImportTargetResultStatus .VALIDATION_FAILED )
325325 .errors (Collections .singletonList (e .getMessage ()))
326326 .build ();
@@ -339,14 +339,14 @@ && shouldRevalidateMissingColumns(importOptions, checkForMissingColumns)) {
339339 .namespace (namespace )
340340 .tableName (table )
341341 .importAction (importAction )
342- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
342+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
343343 .status (ImportTargetResultStatus .SAVED )
344344 .build ();
345345
346346 } catch (ScalarDbDaoException e ) {
347347 return ImportTargetResult .builder ()
348348 .namespace (namespace )
349- .importedRecord (importOptions . isLogRawRecord () ? mutableSourceRecord : null )
349+ .importedRecord (getRecordForLogging ( mutableSourceRecord ) )
350350 .tableName (table )
351351 .importAction (importAction )
352352 .status (ImportTargetResultStatus .SAVE_FAILED )
@@ -430,6 +430,20 @@ private boolean shouldFailForExistingData(
430430 && importOptions .getImportMode () == ImportMode .INSERT ;
431431 }
432432
433+ /**
434+ * Returns the given source record only if raw record logging is enabled in the import options.
435+ *
436+ * <p>This helper method centralizes the logic for conditionally including the raw source record
437+ * in {@code ImportTargetResult}. If {@code logRawRecord} is disabled, {@code null} is returned to
438+ * avoid storing or displaying the raw record.
439+ *
440+ * @param record the source record to include conditionally
441+ * @return the provided record if raw record logging is enabled; otherwise {@code null}
442+ */
443+ private ObjectNode getRecordForLogging (ObjectNode record ) {
444+ return params .getImportOptions ().isLogRawRecord () ? record : null ;
445+ }
446+
433447 /**
434448 * Determines whether the operation should fail if the expected data is missing.
435449 *
0 commit comments