@@ -65,6 +65,26 @@ void twoPartitions() {
65
65
verifyTwoHundredDocsWereWritten ();
66
66
}
67
67
68
+ @ Test
69
+ void insufficientPrivilegeForOtherDatabase () {
70
+ DataFrameWriter writer = newWriter (2 )
71
+ .option (Options .WRITE_TOTAL_THREAD_COUNT , 16 )
72
+ .option (Options .WRITE_BATCH_SIZE , 10 )
73
+ .option (Options .CLIENT_URI , "spark-test-user:spark@localhost:8016/Documents" );
74
+
75
+ SparkException ex = assertThrows (SparkException .class , () -> writer .save ());
76
+ assertNull (ex .getCause (), "Surprisingly, in this scenario where the exception is thrown during the " +
77
+ "construction of WriteBatcherDataWriter, Spark does not populate the 'cause' of the exception but rather " +
78
+ "shoves the entire stacktrace of the exception into the exception message. This is not a good UX for " +
79
+ "connector or Flux users, as it puts an ugly stacktrace right into their face. I have not figured out " +
80
+ "how to avoid this yet, so this test is capturing this behavior in the hopes that an upgraded version of " +
81
+ "Spark will properly set the cause instead." );
82
+ assertTrue (ex .getMessage ().contains ("at com.marklogic.client.impl.OkHttpServices" ), "This is confirming that " +
83
+ "the exception message contains the stacktrace of the MarkLogic exception - which we don't want. Hoping " +
84
+ "this assertion breaks during a future upgrade of Spark and we have a proper exception message " +
85
+ "instead. Actual message: " + ex .getMessage ());
86
+ }
87
+
68
88
@ Test
69
89
void temporalTest () {
70
90
newWriterWithDefaultConfig ("temporal-data.csv" , 1 )
0 commit comments