@@ -1570,54 +1570,66 @@ public void testUploadWithGCSDownscopedCredentialWithoutConnection() throws Thro
1570
1570
@ Test
1571
1571
@ ConditionalIgnoreRule .ConditionalIgnore (condition = RunningOnGithubAction .class )
1572
1572
public void testHTAPOptimizations () throws SQLException {
1573
- // Set the HTAP test parameter to true
1574
- try (Connection con = getSnowflakeAdminConnection ()) {
1575
- Statement statement = con .createStatement ();
1576
- statement .execute (
1577
- "alter account "
1578
- + TestUtil .systemGetEnv ("SNOWFLAKE_TEST_ACCOUNT" )
1579
- + " set ENABLE_SNOW_654741_FOR_TESTING=true" );
1580
- }
1581
- // Create a normal connection and assert that database, schema, and warehouse have expected
1582
- // values
1583
- Connection con = getConnection ();
1584
- SFSession session = con .unwrap (SnowflakeConnectionV1 .class ).getSfSession ();
1585
- assertTrue (TestUtil .systemGetEnv ("SNOWFLAKE_TEST_SCHEMA" ).equalsIgnoreCase (con .getSchema ()));
1586
- assertTrue (TestUtil .systemGetEnv ("SNOWFLAKE_TEST_DATABASE" ).equalsIgnoreCase (con .getCatalog ()));
1587
- assertTrue (
1588
- TestUtil .systemGetEnv ("SNOWFLAKE_TEST_WAREHOUSE" ).equalsIgnoreCase (session .getWarehouse ()));
1589
- Statement statement = con .createStatement ();
1590
- // Set TIMESTAMP_OUTPUT_FORMAT (which is a session parameter) to check its value later
1591
- statement .execute ("alter session set TIMESTAMP_OUTPUT_FORMAT='YYYY-MM-DD HH24:MI:SS.FFTZH'" );
1592
- statement .execute ("create or replace table testtable1 (cola string, colb int)" );
1593
- statement .execute ("insert into testtable1 values ('row1', 1), ('row2', 2), ('row3', 3)" );
1594
- ResultSet rs = statement .executeQuery ("select * from testtable1" );
1595
- assertEquals (3 , getSizeOfResultSet (rs ));
1596
- // Assert database, schema, and warehouse have the same values as before even though the select
1597
- // statement will
1598
- // return no parameters or metadata
1599
- assertTrue (TestUtil .systemGetEnv ("SNOWFLAKE_TEST_SCHEMA" ).equalsIgnoreCase (con .getSchema ()));
1600
- assertTrue (TestUtil .systemGetEnv ("SNOWFLAKE_TEST_DATABASE" ).equalsIgnoreCase (con .getCatalog ()));
1601
- assertTrue (
1602
- TestUtil .systemGetEnv ("SNOWFLAKE_TEST_WAREHOUSE" ).equalsIgnoreCase (session .getWarehouse ()));
1603
- // Assert session parameter TIMESTAMP_OUTPUT_FORMAT has the same value as before the select
1604
- // statement
1605
- assertEquals (
1606
- "YYYY-MM-DD HH24:MI:SS.FFTZH" ,
1607
- session .getCommonParameters ().get ("TIMESTAMP_OUTPUT_FORMAT" ));
1608
- // cleanup
1609
- statement .execute ("alter session unset TIMESTAMP_OUTPUT_FORMAT" );
1610
- statement .execute ("drop table testtable1" );
1611
- rs .close ();
1612
- statement .close ();
1613
- con .close ();
1614
- // cleanup
1615
- try (Connection con2 = getSnowflakeAdminConnection ()) {
1616
- statement = con2 .createStatement ();
1617
- statement .execute (
1618
- "alter account "
1619
- + TestUtil .systemGetEnv ("SNOWFLAKE_TEST_ACCOUNT" )
1620
- + " unset ENABLE_SNOW_654741_FOR_TESTING" );
1573
+ try {
1574
+ // Set the HTAP test parameter to true
1575
+ try (Connection con = getSnowflakeAdminConnection ();
1576
+ Statement statement = con .createStatement ()) {
1577
+ statement .execute (
1578
+ "alter account "
1579
+ + TestUtil .systemGetEnv ("SNOWFLAKE_TEST_ACCOUNT" )
1580
+ + " set ENABLE_SNOW_654741_FOR_TESTING=true" );
1581
+ }
1582
+ // Create a normal connection and assert that database, schema, and warehouse have expected
1583
+ // values
1584
+ try (Connection con = getConnection ()) {
1585
+ SFSession session = con .unwrap (SnowflakeConnectionV1 .class ).getSfSession ();
1586
+ assertTrue (
1587
+ TestUtil .systemGetEnv ("SNOWFLAKE_TEST_SCHEMA" ).equalsIgnoreCase (con .getSchema ()));
1588
+ assertTrue (
1589
+ TestUtil .systemGetEnv ("SNOWFLAKE_TEST_DATABASE" ).equalsIgnoreCase (con .getCatalog ()));
1590
+ assertTrue (
1591
+ TestUtil .systemGetEnv ("SNOWFLAKE_TEST_WAREHOUSE" )
1592
+ .equalsIgnoreCase (session .getWarehouse ()));
1593
+ try (Statement statement = con .createStatement ()) {
1594
+ // Set TIMESTAMP_OUTPUT_FORMAT (which is a session parameter) to check its value later
1595
+ try {
1596
+ statement .execute (
1597
+ "alter session set TIMESTAMP_OUTPUT_FORMAT='YYYY-MM-DD HH24:MI:SS.FFTZH'" );
1598
+ statement .execute ("create or replace table testtable1 (cola string, colb int)" );
1599
+ statement .execute (
1600
+ "insert into testtable1 values ('row1', 1), ('row2', 2), ('row3', 3)" );
1601
+ try (ResultSet rs = statement .executeQuery ("select * from testtable1" )) {
1602
+ assertEquals (3 , getSizeOfResultSet (rs ));
1603
+ // Assert database, schema, and warehouse have the same values as before even though
1604
+ // the select statement will return no parameters or metadata
1605
+ assertTrue (
1606
+ TestUtil .systemGetEnv ("SNOWFLAKE_TEST_SCHEMA" ).equalsIgnoreCase (con .getSchema ()));
1607
+ assertTrue (
1608
+ TestUtil .systemGetEnv ("SNOWFLAKE_TEST_DATABASE" )
1609
+ .equalsIgnoreCase (con .getCatalog ()));
1610
+ assertTrue (
1611
+ TestUtil .systemGetEnv ("SNOWFLAKE_TEST_WAREHOUSE" )
1612
+ .equalsIgnoreCase (session .getWarehouse ()));
1613
+ // Assert session parameter TIMESTAMP_OUTPUT_FORMAT has the same value as before the
1614
+ // select statement
1615
+ assertEquals (
1616
+ "YYYY-MM-DD HH24:MI:SS.FFTZH" ,
1617
+ session .getCommonParameters ().get ("TIMESTAMP_OUTPUT_FORMAT" ));
1618
+ }
1619
+ } finally {
1620
+ statement .execute ("alter session unset TIMESTAMP_OUTPUT_FORMAT" );
1621
+ statement .execute ("drop table if exists testtable1" );
1622
+ }
1623
+ }
1624
+ }
1625
+ } finally {
1626
+ try (Connection con = getSnowflakeAdminConnection ();
1627
+ Statement statement = con .createStatement ()) {
1628
+ statement .execute (
1629
+ "alter account "
1630
+ + TestUtil .systemGetEnv ("SNOWFLAKE_TEST_ACCOUNT" )
1631
+ + " unset ENABLE_SNOW_654741_FOR_TESTING" );
1632
+ }
1621
1633
}
1622
1634
}
1623
1635
0 commit comments