@@ -101,6 +101,7 @@ public class TestSnowflakeOutputPlugin {
101101 props .setProperty ("warehouse" , TEST_SNOWFLAKE_WAREHOUSE );
102102 props .setProperty ("db" , TEST_SNOWFLAKE_DB );
103103 props .setProperty ("schema" , TEST_SNOWFLAKE_SCHEMA );
104+ props .setProperty ("MULTI_STATEMENT_COUNT" , "0" );
104105 TEST_PROPERTIES = props ;
105106 }
106107
@@ -287,6 +288,51 @@ public void testRuntimeReplaceStringTable() throws IOException {
287288 }
288289 }
289290
291+ @ Test
292+ public void testExecuteMultiQuery () throws IOException {
293+ File in = testFolder .newFile (SnowflakeUtils .randomString (8 ) + ".csv" );
294+ List <String > lines =
295+ Stream .of ("c0:double, c1:string" , "0.0,aaa" , "0.1,bbb" , "1.2,ccc" )
296+ .collect (Collectors .toList ());
297+ Files .write (in .toPath (), lines );
298+
299+ String targetTableName = generateTemporaryTableName ();
300+ String targetTableFullName =
301+ String .format (
302+ "\" %s\" .\" %s\" .\" %s\" " , TEST_SNOWFLAKE_DB , TEST_SNOWFLAKE_SCHEMA , targetTableName );
303+ runQuery (
304+ String .format ("create table %s (c0 FLOAT, c1 STRING)" , targetTableFullName ),
305+ foreachResult (rs_ -> {}));
306+
307+ String temporaryTableName = generateTemporaryTableName ();
308+
309+ final ConfigSource config =
310+ CONFIG_MAPPER_FACTORY
311+ .newConfigSource ()
312+ .set ("type" , "snowflake" )
313+ .set ("user" , TEST_SNOWFLAKE_USER )
314+ .set ("password" , TEST_SNOWFLAKE_PASSWORD )
315+ .set ("host" , TEST_SNOWFLAKE_HOST )
316+ .set ("database" , TEST_SNOWFLAKE_DB )
317+ .set ("warehouse" , TEST_SNOWFLAKE_WAREHOUSE )
318+ .set ("schema" , TEST_SNOWFLAKE_SCHEMA )
319+ .set ("mode" , "replace" )
320+ .set ("table" , temporaryTableName )
321+ .set (
322+ "after_load" ,
323+ String .format (
324+ "insert into \" %s\" select * from \" %s\" ; drop table \" %s\" ;" ,
325+ targetTableName , temporaryTableName , temporaryTableName ));
326+ embulk .runOutput (config , in .toPath ());
327+
328+ runQuery (
329+ String .format ("select count(*) from %s;" , targetTableFullName ),
330+ foreachResult (
331+ rs -> {
332+ assertEquals (3 , rs .getInt (1 ));
333+ }));
334+ }
335+
290336 @ Test
291337 public void testRuntimeInsertStringTable () throws IOException {
292338 File in = testFolder .newFile (SnowflakeUtils .randomString (8 ) + ".csv" );
0 commit comments