<commit_before>CREATE TABLE model_draft.ego_supply_res_powerplant AS
	TABLE supply.ego_renewable_powerplant; 

ALTER TABLE model_draft.ego_supply_res_powerplant
  	ADD COLUMN subst_id bigint,
  	ADD COLUMN otg_id bigint,
  	ADD COLUMN un_id bigint;

CREATE INDEX model_draft.ego_supply_res_powerplant_idx
  ON model_draft.ego_supply_res_powerplant
  USING gist
(geom);


-- Delete entries without information on installed capacity or where electrical_capacity <= 0
DELETE  FROM model_draft.ego_supply_res_powerplant
	WHERE electrical_capacity IS NULL OR electrical_capacity <= 0; 


-- Delete entries where generation_type and subtype are inconsistent
DELETE  FROM model_draft.ego_supply_res_powerplant
	WHERE generation_type = 'biomass' AND generation_subtype ='wind_onshore'
	OR generation_type = 'biomass' AND generation_subtype ='solar_roof_mounted'
	OR generation_type = 'solar' AND generation_subtype ='wind_onshore'
	OR generation_type = 'wind' AND generation_subtype ='solar_roof_mounted';

-- Update missing subtype of some offshore windturbines

UPDATE model_draft.ego_supply_res_powerplant
SET generation_subtype = 'wind_offshore'
WHERE city = 'Ausschließliche Wirtschaftszone';


-- Change generation_type = 'hydro' to 'run_of_river' for compatibility reasons

UPDATE model_draft.ego_supply_res_powerplant
	SET generation_type = 'run_of_river'
	WHERE generation_type = 'hydro';

<commit_msg>Add delete statement<commit_after>DROP TABLE IF EXISTS model_draft.ego_supply_res_powerplant CASCADE; 

CREATE TABLE model_draft.ego_supply_res_powerplant AS
	TABLE supply.ego_renewable_powerplant; 

ALTER TABLE model_draft.ego_supply_res_powerplant
  	ADD COLUMN subst_id bigint,
  	ADD COLUMN otg_id bigint,
  	ADD COLUMN un_id bigint;

CREATE INDEX model_draft.ego_supply_res_powerplant_idx
  ON model_draft.ego_supply_res_powerplant
  USING gist
(geom);

ALTER TABLE model_draft.ego_supply_res_powerplant OWNER TO oeuser; 


-- Delete entries without information on installed capacity or where electrical_capacity <= 0
DELETE  FROM model_draft.ego_supply_res_powerplant
	WHERE electrical_capacity IS NULL OR electrical_capacity <= 0; 


-- Delete entries where generation_type and subtype are inconsistent
DELETE  FROM model_draft.ego_supply_res_powerplant
	WHERE generation_type = 'biomass' AND generation_subtype ='wind_onshore'
	OR generation_type = 'biomass' AND generation_subtype ='solar_roof_mounted'
	OR generation_type = 'solar' AND generation_subtype ='wind_onshore'
	OR generation_type = 'wind' AND generation_subtype ='solar_roof_mounted';

-- Update missing subtype of some offshore windturbines

UPDATE model_draft.ego_supply_res_powerplant
SET generation_subtype = 'wind_offshore'
WHERE city = 'Ausschließliche Wirtschaftszone';


-- Change generation_type = 'hydro' to 'run_of_river' for compatibility reasons

UPDATE model_draft.ego_supply_res_powerplant
	SET generation_type = 'run_of_river'
	WHERE generation_type = 'hydro';


{'fraction_non_alphanumeric': 0.052845528455284556, 'fraction_numerical': 0.0013550135501355014, 'mean_word_length': 6.513994910941475, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '2653628', 'n_tokens_mistral': 974, 'n_tokens_neox': 939, 'n_words': 248}