How do we handle quoted field names? #563
Replies: 2 comments 1 reply
-
There could also be collisions when converting illegal characters to underbar. For example, with fields like |
Beta Was this translation helpful? Give feedback.
-
Please leave further comments in the pull request if you have them #1153 |
Beta Was this translation helpful? Give feedback.
-
Most SQL dialects allow field names contain just about any character so long as they are quoted. The exception here is BigQuery which still only allows
r/[A-z_][A-z0-9_]*/
even when a backquote is applied.Spaces in field names are really useful in that you can use the display name of a field to show in the result. When reading a spreadsheet, the column heading is usable as a field name, regardless of what it contains. Data at rest needs lest conversion to be useful.
Malloy already supports backquote as a mechanism to escape keywords but it would be really nice to support arbitrary strings.
For example this model can be programmed directly against a CSV provided by data.gov.
And the result can look like
The problem here is how do we degrade in BigQuery? On schema read, we could easily convert illegal characters to underbar. The problem is Malloy models that have output identifiers that would be illegal in BigQuery, how would we map them? Could we store a map with the result? Could we make something that would fail gracefully?
Beta Was this translation helpful? Give feedback.
All reactions