Permalink
Browse files

Merge branch 'master' of /home/gkettler/Dropbox/git/pypitches

  • Loading branch information...
2 parents 6b517d8 + b671f8c commit b8ab763d4614023b1c530414b18a095304c43c41 @gregoryck committed Apr 22, 2012
Showing with 12 additions and 36 deletions.
  1. +5 −32 baseball.sql
  2. +7 −4 baseball.sql.pre
View
@@ -9,36 +9,8 @@ begin;
--drop table player;
--drop table team;
-<<<<<<< HEAD:baseball.sql
-
-create temp table ranges
-
--- FOREIGN KEY (pitcher) references player (id),
--- primary key (pitcher)
- as
- select pitch.pitcher,
- avg(start_speed) - 2*stddev(start_speed) as low_speed,
- avg(start_speed) + 2 * stddev(start_speed) as high_speed,
- (avg(pfx_x * lefty(p_throws)) - 2*stddev(pfx_x * lefty(p_throws))) as low_pfx_x,
- (avg(pfx_x * lefty(p_throws)) + 2*stddev(pfx_x * lefty(p_throws))) as high_pfx_x,
- avg(pfx_z) - 2*stddev(pfx_z) as low_pfx_z,
- avg(pfx_z) + 2*stddev(pfx_z) as high_pfx_z
- from pitch
- join atbat on pitch.atbatnum = atbat.num and pitch.game_pk = atbat.game_pk
- group by pitch.pitcher;
-
- alter table ranges add FOREIGN KEY (pitcher) references player (id);
- alter table ranges add PRIMARY KEY (pitcher);
-=======
-create function normalized_speed(integer) returns float as
-$normalized_speed$
-declare
- id alias for $1;
-begin
-
-end;
-$normalized_speed$ language pgsql;
->>>>>>> smaller:baseball.sql
+
+
CREATE TABLE stadium (
id INTEGER PRIMARY KEY,
@@ -183,8 +155,9 @@ CREATE TABLE pitch (
on_1b INTEGER,
on_2b INTEGER,
on_3b INTEGER,
- payoff INTEGER, --:SQLITE
- payoff BOOLEAN, --:POSTGRES
+
+ payoff INTEGER, --SQLITE
+
balls INTEGER,
strikes INTEGER,
View
@@ -26,8 +26,6 @@ create or replace aggregate normalize(float)
-- pfx_z
-- release point?
-create or replace function normalize(
-
create or replace function normalized_speed(get_game_pk integer, get_num integer) returns float as
$normalized_speed$
-- takes the primary key of a pitch.
@@ -70,6 +68,7 @@ end;
$lefty$ language 'plpgsql';
{% endif %}
+{% if ranges %}
create temp table ranges
-- FOREIGN KEY (pitcher) references player (id),
@@ -88,6 +87,7 @@ create temp table ranges
alter table ranges add FOREIGN KEY (pitcher) references player (id);
alter table ranges add PRIMARY KEY (pitcher);
+{% endif %}
CREATE TABLE stadium (
id INTEGER PRIMARY KEY,
@@ -240,8 +240,11 @@ CREATE TABLE pitch (
on_1b INTEGER,
on_2b INTEGER,
on_3b INTEGER,
- payoff INTEGER, --:SQLITE
- payoff BOOLEAN, --:POSTGRES
+ {% if postgres %}
+ payoff BOOLEAN, --POSTGRES
+ {% else %}
+ payoff INTEGER, --SQLITE
+ {% endif %}
balls INTEGER,
strikes INTEGER,

0 comments on commit b8ab763

Please sign in to comment.