-
-
Notifications
You must be signed in to change notification settings - Fork 280
Open
Description
func main() {
sfsLoader, err := pongo2.NewSandboxedFilesystemLoader(".")
tplset := pongo2.NewSet("name", sfsLoader)
tpl, tplErr := tplset.FromFile("create-table.sql.tpl")
out, outErr := tpl.Execute(pongo2.Context{
"table_settings": "SETTINGS merge_with_ttl_timeout = 86400, storage_policy = 's3'",
})
return out
}create-table.sql.tpl:
CREATE TABLE IF NOT EXISTS db.table
(
`name` String,
`type` String,
`help` String,
`labels` Map(String, String) DEFAULT map(),
`value` Float64,
`timestamp` Int64
)
ENGINE = MergeTree
PARTITION BY toDate(fromUnixTimestamp64Milli(`timestamp`, 'Asia/Shanghai'))
PRIMARY KEY (`timestamp`, `name`)
ORDER BY (`timestamp`, `name`, `labels`)
-- SETTINGS
{% if (table_settings | default : "") == "" %}
SETTINGS merge_with_ttl_timeout = 86400
{% else %}
{{ table_settings }}
{% endif %}
;out is:
...Omit
...Omit
-- SETTINGS
SETTINGS merge_with_ttl_timeout = 86400, storage_policy = \u0026#39;s3\u0026#39;
;
Why ' is escaped to \u0026#39; ? How can I avoid this?
Because SQL can not parse \u successfully and can not use ; again and again.
Thank you very much!
Metadata
Metadata
Assignees
Labels
No labels