-
Notifications
You must be signed in to change notification settings - Fork 18
Fix: Escape col names by manually generating node #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| } from "@uwdata/mosaic-core"; | ||
| import { | ||
| asc, | ||
| column, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
column() contructs an actual column node:
If column's second argument table is other than undefined, query comes out like SELECT "table"."colname"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| let cols = this.#meta.schema.fields.map((field) => { | ||
| let info = infos.find((c) => c.column === field.name); | ||
| let info = infos.find((c) => c.column === `"${field.name}"`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Frustratingly, mosaic doesn't handle identifier syntax properly if a string (completely ignores quotes).
However, round-tripping from a column ref node like this seems to produce properly escaped column names.
A bit speculative.
|
Should we try to fix this in mosaic instead? |
|
I might submit a PR there, i just can't decide how i would build the parser. You still have to make a modification to DatatableClient in quak because it doesn't yet properly quote table names (which you can't do right now since mosaic breaks) and then it's like do you rather quote table names and escape quotes as well or just type the column like Im doing here |
|
So aside from fixing the SQL layer to parse properly... Also you have this issue where the SQL layer of mosaic uses proper SQL terms (ref, expr, identifier, etc) but the utility layer uses layman's terms like "column" and so it's not clear if they really mean column there to be a column in a colloquial sense or a field identifier, and it looks closer to undefined behavior upon analysis. |
|
I maintain mosaic so if you have concrete suggestions for how the behavior is broken or the API is inconsistent, please file an issue over there. PRs are super welcome as well. |
|
It seems a bit of work on my end but that's okay Another user has the issue here: uwdata/mosaic#933 So I posed some clarifying questions there. I would to see this PR go through because its a good solution IMO @manzt but I am going to expand it a bit this week. |
|
Could you apply linting fix? diff --git a/lib/clients/DataTable.ts b/lib/clients/DataTable.ts
index e42258ab52..7bc88c89b7 100644
--- a/lib/clients/DataTable.ts
+++ b/lib/clients/DataTable.ts
@@ -58,9 +58,11 @@
let empty = await options.coordinator.query(
Query
.from(table)
- .select(options.columns?.map( columnName => {
- return column(columnName, undefined);
- }) ?? ["*"])
+ .select(
+ options.columns?.map((columnName) => {
+ return column(columnName, undefined);
+ }) ?? ["*"],
+ )
.limit(0),
{ type: "arrow" },
);deno fmt |
manzt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the addition. I'm happy to push this through to unblock you, but upstream would be ideal.
|
@manzt I'm going to do another review Upstream is a bit more work and will require several reviews, and imo using an actual column type > string manipulation anyway |
Periods in column names used to completely break rendering. Now they don't.
Mosaic has 0 proper field/string/name parsing:
I didn't want to build a parser, and then we'd have to quote all col names anyway. I pass an already initialized Column type which skips string parsing.
More comments about fixes in commit.
Fixes #95