Created
March 21, 2018 00:37
-
-
Save sadhasivam/fda6904b9765f0cc800c1d4d99ae4071 to your computer and use it in GitHub Desktop.
snowflake_local_file_upload_download.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
-- input data | |
put file:///Users/kadalamittai/Downloads/data_domain.csv@~/staged; | |
CREATE TEMPORARY TABLE PUBLIC.tmp_domain_orders( | |
increment_id varchar(256), | |
subtotal double, | |
order_date date | |
); | |
copy into tmp_domain_orders from @~/staged/data_domain.csv.gz file_format = (type = csv skip_header = 1); | |
-- export data | |
copy into @~/domain_orders.csv.gz from ( | |
select tmp_domain_orders.*, domain_orders.order_subtotal as domain_orders_SUBTOTAL | |
from tmp_domain_orders | |
LEFT JOIN domain_orders on tmp_domain_orders.increment_id = domain_orders.MERCHANT_ORDER_ID | |
WHERE tmp_domain_orders.order_date between '2018-01-29' and '2018-03-05' | |
) file_format = (type=csv COMPRESSION='gzip') single=true header = true; | |
get @~/domain_orders.csv.gz file:///Users/kadalamittai/Downloads/.; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment