File tree 1 file changed +40
-0
lines changed
clients/client-s3/test/e2e
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -248,4 +248,44 @@ describe("@aws-sdk/client-s3", () => {
248
248
expect ( ( listUploadsResult . Uploads || [ ] ) . map ( ( upload ) => upload . UploadId ) ) . not . to . contain ( toAbort ) ;
249
249
} ) ;
250
250
} ) ;
251
+
252
+ describe ( "selectObjectContent" , ( ) => {
253
+ const csvFile = `user_name,age
254
+ jsrocks,13
255
+ node4life,22
256
+ esfuture,29` ;
257
+ before ( async ( ) => {
258
+ Key = `${ Date . now ( ) } ` ;
259
+ await client . putObject ( { Bucket, Key, Body : csvFile } ) ;
260
+ } ) ;
261
+ after ( async ( ) => {
262
+ await client . deleteObject ( { Bucket, Key } ) ;
263
+ } ) ;
264
+ it ( "should succeed" , async ( ) => {
265
+ const { Payload } = await client . selectObjectContent ( {
266
+ Bucket,
267
+ Key,
268
+ ExpressionType : "SQL" ,
269
+ Expression : "SELECT user_name FROM S3Object WHERE cast(age as int) > 20" ,
270
+ InputSerialization : {
271
+ CSV : {
272
+ FileHeaderInfo : "USE" ,
273
+ RecordDelimiter : "\n" ,
274
+ FieldDelimiter : "," ,
275
+ } ,
276
+ } ,
277
+ OutputSerialization : {
278
+ CSV : { } ,
279
+ } ,
280
+ } ) ;
281
+ const events = [ ] ;
282
+ for await ( const event of Payload ) {
283
+ events . push ( event ) ;
284
+ }
285
+ expect ( events . length ) . to . equal ( 3 ) ;
286
+ expect ( Buffer . from ( events [ 0 ] . Records . Payload ) . toString ( "utf8" ) ) . to . equal ( "node4life\nesfuture\n" ) ;
287
+ expect ( events [ 1 ] . Stats . Details ) . to . be . exist ;
288
+ expect ( events [ 2 ] . End ) . to . be . exist ;
289
+ } ) ;
290
+ } ) ;
251
291
} ) ;
You can’t perform that action at this time.
0 commit comments