Skip to content

Conversation

@ayjayt
Copy link

@ayjayt ayjayt commented Dec 13, 2025

Periods in column names used to completely break rendering. Now they don't.

Mosaic has 0 proper field/string/name parsing:

// TODO: handle case where identifiers are already quoted?
export function parseIdentifier(id: string) {
  return id.split('.');
}

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

} from "@uwdata/mosaic-core";
import {
asc,
column,
Copy link
Author

@ayjayt ayjayt Dec 13, 2025

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:

https://github.com/uwdata/mosaic/blob/9dc9d0aa1ec9a18aaee3dc87820071f5f3aff1ff/packages/mosaic/sql/src/functions/column.ts#L15-L23

If column's second argument table is other than undefined, query comes out like SELECT "table"."colname"

Copy link
Author

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}"`);
Copy link
Author

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.

@domoritz
Copy link
Collaborator

Should we try to fix this in mosaic instead?

@ayjayt
Copy link
Author

ayjayt commented Dec 13, 2025

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

@ayjayt
Copy link
Author

ayjayt commented Dec 13, 2025

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.

@domoritz
Copy link
Collaborator

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.

@ayjayt
Copy link
Author

ayjayt commented Dec 14, 2025

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.

@manzt
Copy link
Owner

manzt commented Dec 18, 2025

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

Copy link
Owner

@manzt manzt left a 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.

@ayjayt
Copy link
Author

ayjayt commented Dec 18, 2025

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Periods in column names completely break rendering

3 participants