koopjs / koop-provider-elastic-sql

Koop provider to fetch data in elastic/opensearch datastores through the SQL API
Other
2 stars 0 forks source link

Generated SQL is incorrect if the index name contains special characters #3

Open haoliangyu opened 4 months ago

haoliangyu commented 4 months ago

While ElasticSearch allows . (or other special characters) in the index name, the SQL generated from this provider will fail with a parsing error. Double-quoting the index name will fix the issue.

This does not work

SELECT * FROM index.name

This works

SELECT * FROM "index.name"

It is mentioned at the ElasticSearch SQL documentation:

If the table name contains special SQL characters (such as .,-,*,etc…​) use double quotes to escape them

This bug can be fixed at https://github.com/koopjs/koop-provider-elastic-sql/blob/main/src/model.js#L130.

rgwozdz commented 4 months ago

Thanks @haoliangyu.