pull/3949/head
ruslandoga 3 years ago
parent e41f7958b1
commit ab6f70c79e

@ -43,9 +43,17 @@ defmodule Plausible.Imported.CSVImporter do
{table, _, _} = parse_filename!(filename)
s3_structure = input_structure!(table)
s3_structure_cols_expr =
String.split(s3_structure, ",", trim: true)
|> Enum.map(fn kv ->
[col, _type] = String.split(kv)
col
end)
|> Enum.join(", ")
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