-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add table creation from files (#230)
* Add table creation from files * remove mock bsvs * pr feedback * meant to adjust the other test, whoops * test cleanup * corrected upload path
- Loading branch information
1 parent
ca83935
commit 0aacf20
Showing
28 changed files
with
504 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
icd/*.parquet |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
cumulus_library/studies/vocab/reference_sql/vocab_icd_builder.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-- noqa: disable=all | ||
-- This sql was autogenerated as a reference example using the library | ||
-- CLI. Its format is tied to the specific database it was run against, | ||
-- and it may not be correct for all databases. Use the CLI's build | ||
-- option to derive the best SQL for your dataset. | ||
|
||
-- ########################################################### | ||
|
||
CREATE EXTERNAL TABLE IF NOT EXISTS `cumulus_mhg_dev_db`.`vocab__icd` ( | ||
CUI STRING, | ||
TTY STRING, | ||
CODE STRING, | ||
SAB STRING, | ||
STR STRING | ||
) | ||
STORED AS PARQUET | ||
LOCATION 's3://cumulus-athena-933137588087-us-east-1/results/cumulus_user_uploads/cumulus_mhg_dev_db/vocab/icd' | ||
tblproperties ("parquet.compression"="SNAPPY"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{%- import 'syntax.sql.jinja' as syntax -%} | ||
{%- if db_type == 'athena' -%} | ||
CREATE EXTERNAL TABLE IF NOT EXISTS `{{ schema_name }}`.`{{ table_name }}` ( | ||
{%- elif db_type == 'duckdb' -%} | ||
CREATE TABLE IF NOT EXISTS {{ table_name }} AS SELECT | ||
{%- endif %} | ||
{%- for col in table_cols %} | ||
{{ col }}{% if db_type == 'athena' %} {{ remote_table_cols_types[loop.index0] }}{%- endif -%} | ||
{{- syntax.comma_delineate(loop) }} | ||
{%- endfor %} | ||
{%- if db_type == 'athena' %} | ||
) | ||
{#- TODO: we may want to consider an optional partition parameter for | ||
large tables, though we would need to also run a MSCK REPAIR TABLE query | ||
after this table is created to make the data available. | ||
See https://docs.aws.amazon.com/athena/latest/ug/parquet-serde.html | ||
for more info #} | ||
STORED AS PARQUET | ||
LOCATION '{{ remote_location }}' | ||
tblproperties ("parquet.compression"="SNAPPY"); | ||
{%- elif db_type == 'duckdb' %} | ||
FROM read_parquet('{{ local_location }}/*.parquet') | ||
{%- endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Oops, something went wrong.