specify insert columns in import from s3 (#3968)

Co-authored-by: RobertJoonas <56999674+RobertJoonas@users.noreply.github.com>
pull/3949/head^2
ruslandoga 3 years ago committed by GitHub
parent 1f778e0c11
commit 2ba4988c95
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -43,9 +43,17 @@ defmodule Plausible.Imported.CSVImporter do
{table, _, _} = parse_filename!(filename)
s3_structure = input_structure!(table)
s3_structure_cols_expr =
s3_structure
|> String.split(",", trim: true)
|> Enum.map_join(", ", fn kv ->
[col, _type] = String.split(kv)
col
end)
statement =
"""
INSERT INTO {table:Identifier} \
INSERT INTO {table:Identifier}(site_id, #{s3_structure_cols_expr}, import_id) \
SELECT {site_id:UInt64} AS site_id, *, {import_id:UInt64} AS import_id \
FROM s3({s3_url:String},{s3_access_key_id:String},{s3_secret_access_key:String},{s3_format:String},{s3_structure:String}) \
WHERE date >= {start_date:Date} AND date <= {end_date:Date}\

Loading…
Cancel
Save