@Test(groups = JDBC) public void shouldSetLocale() throws SQLException { connection.setLocale(CHINESE); try (Statement statement = connection.createStatement()) { QueryResult result = queryResult(statement, "SELECT date_format(TIMESTAMP '2001-01-09 09:04', '%M')"); assertThat(result).contains(row("一月")); } }
@Test(groups = JDBC) public void shouldSetTimezone() throws SQLException { String timeZoneId = "Indian/Kerguelen"; connection.setTimeZoneId(timeZoneId); try (Statement statement = connection.createStatement()) { QueryResult result = queryResult(statement, "select current_timezone()"); assertThat(result).contains(row(timeZoneId)); } }
@Test(groups = JDBC) @Requires(ImmutableNationTable.class) public void shouldExecuteQueryWithSelectedCatalogAndSchema() throws SQLException { connection.setCatalog("hive"); connection.setSchema("default"); try (Statement statement = connection.createStatement()) { QueryResult result = queryResult(statement, "select * from nation"); assertThat(result).matches(PRESTO_NATION_RESULT); } }
@Test(groups = JDBC) @Requires(ImmutableNationTable.class) public void shouldExecuteQuery() throws SQLException { try (Statement statement = connection.createStatement()) { QueryResult result = queryResult(statement, "select * from hive.default.nation"); assertThat(result).matches(PRESTO_NATION_RESULT); } }
@Test(groups = {JDBC, QUARANTINE}) @Requires(ImmutableAndMutableNationTable.class) public void shouldInsertSelectQuery() throws SQLException { String tableNameInDatabase = mutableTablesState().get(TABLE_NAME).getNameInDatabase(); assertThat(query("SELECT * FROM " + tableNameInDatabase)).hasNoRows(); try (Statement statement = connection.createStatement()) { // TODO: fix, should return proper number of inserted rows assertThat( statement.executeUpdate( "insert into " + tableNameInDatabase + " select * from nation")) .isEqualTo(25); } assertThat(query("SELECT * FROM " + tableNameInDatabase)).matches(PRESTO_NATION_RESULT); }
private PrestoDatabaseMetaData metaData() throws SQLException { return (PrestoDatabaseMetaData) connection.getMetaData(); }