<commit_before>package org.apache.derby.impl.sql.execute.operations;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.splicemachine.derby.test.DerbyTestRule;
import org.apache.log4j.Logger;
import org.junit.*;

public class UpdateOperationTest {
	private static Logger LOG = Logger.getLogger(UpdateOperationTest.class);

	private static final Map<String,String> tableSchemas = new HashMap<String, String>();
	static{
		tableSchemas.put("locations","num int, addr varchar(50), zip char(5)");
		//tableSchemas.put("t1","int_col int, smallint_col smallint, char_30_col char(30), varchar_50_col varchar(50)");
	}
	@Rule public static DerbyTestRule rule = new DerbyTestRule(tableSchemas,LOG);

	@BeforeClass
	public static void startup() throws Exception{
		DerbyTestRule.start();
	}
	@AfterClass
	public static void shutdown() throws Exception{
		rule.dropTables();
		DerbyTestRule.shutdown();
	}

	@Before
	public void setupTest() throws Exception{
		PreparedStatement insertPs = rule.prepareStatement("insert into locations values(?,?,?)");
		insertPs.setInt(1,100);
		insertPs.setString(2,"100");
		insertPs.setString(3, "94114");
		insertPs.executeUpdate();

		insertPs.setInt(1,200);
		insertPs.setString(2,"200");
		insertPs.setString(3, "94509");
		insertPs.executeUpdate();

		insertPs.setInt(1,300);
		insertPs.setString(2,"300");
		insertPs.setString(3, "34166");
		insertPs.executeUpdate();		
				

		
	}

	@Test
	public void testUpdate() throws SQLException {
		int updated= rule.getStatement().executeUpdate("update locations set addr='240' where num=100");
		Assert.assertEquals("Incorrect num rows updated!",1,updated);
		ResultSet rs = rule.executeQuery("select * from locations where num = 100");
		List<String> results = Lists.newArrayListWithCapacity(1);
		while(rs.next()){
			Integer num = rs.getInt(1);
			String addr = rs.getString(2);
			String zip = rs.getString(3);
			Assert.assertNotNull("no zip returned!",zip);
			Assert.assertEquals("Incorrect num returned!",100,num.intValue());
			Assert.assertEquals("Address incorrect","240",addr);
			results.add(String.format("num:%d,addr:%s,zip:%s",num,addr,zip));
		}
		for(String result:results){
			LOG.info(result);
		}
		Assert.assertEquals("Incorrect rows returned!",1,results.size());
	}

	@Test
	public void testUpdateMultipleColumns() throws Exception{
		int updated = rule.getStatement().executeUpdate("update locations set addr='900',zip='63367' where num=300");
		Assert.assertEquals("incorrect number of records updated!",1,updated);
		ResultSet rs = rule.executeQuery("select * from locations where num=300");
		List<String>results = Lists.newArrayList();
		while(rs.next()){
			Integer num = rs.getInt(1);
			String addr = rs.getString(2);
			String zip = rs.getString(3);
			Assert.assertEquals("incorrect num!",new Integer(300),num);
			Assert.assertEquals("Incorrect addr!","900",addr);
			Assert.assertEquals("incorrect zip!","63367",zip);
			results.add(String.format("num:%d,addr:5s,zip:%s",num,addr,zip));
		}
		Assert.assertEquals("Incorrect rows returned!",1,results.size());
	}
}<commit_msg>fixed UpdateOperationTest to manual create/insert/drop table. This is due to multiple run failures as the table was not dropped.<commit_after>package org.apache.derby.impl.sql.execute.operations;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
import com.splicemachine.derby.test.DerbyTestRule;
import org.apache.log4j.Logger;
import org.junit.*;

public class UpdateOperationTest {
	private static Logger LOG = Logger.getLogger(UpdateOperationTest.class);

	private static final Map<String,String> tableSchemas = new HashMap<String, String>();
	static{
		tableSchemas.put("locationup","num int, addr varchar(50), zip char(5)");
		//tableSchemas.put("t1","int_col int, smallint_col smallint, char_30_col char(30), varchar_50_col varchar(50)");
	}
	@Rule public static DerbyTestRule rule = new DerbyTestRule(tableSchemas,false,LOG);

	@BeforeClass
	public static void startup() throws Exception{
		DerbyTestRule.start();
		rule.createTables();
		insertData(rule);
	}
	@AfterClass
	public static void shutdown() throws Exception{
		rule.dropTables();
		DerbyTestRule.shutdown();
	}
	
	public static void insertData(DerbyTestRule rule) throws Exception{
		PreparedStatement insertPs = rule.prepareStatement("insert into locationup values(?,?,?)");
		insertPs.setInt(1,100);
		insertPs.setString(2,"100");
		insertPs.setString(3, "94114");
		insertPs.executeUpdate();

		insertPs.setInt(1,200);
		insertPs.setString(2,"200");
		insertPs.setString(3, "94509");
		insertPs.executeUpdate();

		insertPs.setInt(1,300);
		insertPs.setString(2,"300");
		insertPs.setString(3, "34166");
		insertPs.executeUpdate();		
	}

	@Test
	public void testUpdate() throws SQLException {
		int updated= rule.getStatement().executeUpdate("update locationup set addr='240' where num=100");
		Assert.assertEquals("Incorrect num rows updated!",1,updated);
		ResultSet rs = rule.executeQuery("select * from locationup where num = 100");
		List<String> results = Lists.newArrayListWithCapacity(1);
		while(rs.next()){
			Integer num = rs.getInt(1);
			String addr = rs.getString(2);
			String zip = rs.getString(3);
			Assert.assertNotNull("no zip returned!",zip);
			Assert.assertEquals("Incorrect num returned!",100,num.intValue());
			Assert.assertEquals("Address incorrect","240",addr);
			results.add(String.format("num:%d,addr:%s,zip:%s",num,addr,zip));
		}
		for(String result:results){
			LOG.info(result);
		}
		Assert.assertEquals("Incorrect rows returned!",1,results.size());
	}

	@Test
	public void testUpdateMultipleColumns() throws Exception{
		int updated = rule.getStatement().executeUpdate("update locationup set addr='900',zip='63367' where num=300");
		Assert.assertEquals("incorrect number of records updated!",1,updated);
		ResultSet rs = rule.executeQuery("select * from locationup where num=300");
		List<String>results = Lists.newArrayList();
		while(rs.next()){
			Integer num = rs.getInt(1);
			String addr = rs.getString(2);
			String zip = rs.getString(3);
			Assert.assertEquals("incorrect num!",new Integer(300),num);
			Assert.assertEquals("Incorrect addr!","900",addr);
			Assert.assertEquals("incorrect zip!","63367",zip);
			results.add(String.format("num:%d,addr:5s,zip:%s",num,addr,zip));
		}
		Assert.assertEquals("Incorrect rows returned!",1,results.size());
	}
}
{'fraction_non_alphanumeric': 0.1472218062003894, 'fraction_numerical': 0.03205032200089861, 'mean_word_length': 5.856262833675565, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5112304', 'n_tokens_mistral': 2348, 'n_tokens_neox': 2081, 'n_words': 435}