Skip to content

Commit

Permalink
Makes PARTITION BY happen only for GP
Browse files Browse the repository at this point in the history
generalizing 5aaca9ca5e309bd95204488ed99ba63c909cf5ca
  • Loading branch information
netj committed Jan 24, 2017
1 parent f723895 commit 97c6df5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
49 changes: 31 additions & 18 deletions compiler/compile-config/compile-config-2.01-grounding
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,37 @@ def factorWeightDescriptionSqlExpr:
]
} | asSql | asPrettySqlArg)
deepdive create table \(.factorsTable + "_dummy" | @sh) as \(
"SELECT * FROM \(.factorsTable + "_view") LIMIT 0" | asPrettySqlArg )
# TODO(netj): turn this off for PG
CREATE_TABLE_EXTRA_CLAUSES=\"
PARTITION BY RANGE(pid)
( START (0) INCLUSIVE
END ( \($deepdive.sampler.partitions) ) EXCLUSIVE
EVERY (1) )\" \\
deepdive create table \(.factorsTable | @sh) like \(.factorsTable + "_dummy" | @sh)
deepdive sql \("
INSERT INTO \(.factorsTable | asSqlIdent)
SELECT * FROM \(.factorsTable + "_view")
" | asPrettySqlArg)
deepdive sql \("DROP TABLE \(.factorsTable)_dummy" | asPrettySqlArg)
case $(eval \"$(deepdive db parse)\"; echo $DBVARIANT) in
greenplum) # specialization for Greenplum with PARTITION BY
deepdive create table \(.factorsTable + "_dummy" | @sh) as \("
SELECT * FROM \(.factorsTable + "_view" | asSqlIdent)
LIMIT 0
" | asPrettySqlArg)
CREATE_TABLE_EXTRA_CLAUSES='
PARTITION BY RANGE(pid)
( START (0) INCLUSIVE
END (\($deepdive.sampler.partitions)) EXCLUSIVE
EVERY (1)
)' \\
deepdive create table \(.factorsTable | @sh) like \(
.factorsTable + "_dummy" | @sh)
deepdive sql \("
INSERT INTO \(.factorsTable | asSqlIdent)
SELECT * FROM \(.factorsTable + "_view" | asSqlIdent)
" | asPrettySqlArg)
deepdive sql \("
DROP TABLE \(.factorsTable + "_dummy" | asSqlIdent)
" | asPrettySqlArg)
;;
*) # otherwise, simply materialize the view
deepdive create table \(.factorsTable | @sh) as \("
SELECT * FROM \(.factorsTable + "_view" | asSqlIdent)
" | asPrettySqlArg)
esac
deepdive db analyze \(.factorsTable | @sh)
# find distinct weights for the factors into a separate table
Expand Down
2 changes: 2 additions & 0 deletions database/db-driver/postgresql/db-parse
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# > db-parse "$url"
set -eu

[[ $# -gt 0 ]] || set -- "$DEEPDIVE_DB_URL"

. parse-url.sh "$@"

# use bundled postgresql if no psql is available
Expand Down

0 comments on commit 97c6df5

Please sign in to comment.