Skip to content
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

Separate concerns by adding a dialect.type field #921

Open
khusmann opened this issue Apr 17, 2024 · 0 comments · May be fixed by #1055
Open

Separate concerns by adding a dialect.type field #921

khusmann opened this issue Apr 17, 2024 · 0 comments · May be fixed by #1055
Assignees
Labels
Milestone

Comments

@khusmann
Copy link
Contributor

khusmann commented Apr 17, 2024

Our current approach in Table Dialect is to mix-in new properties for new formats. This means properties like delimter can be set along with sheetName, which doesn't make sense. It's going to get more unwieldy & potentially contradictory the more features of different formats we support.

To separate concerns & make validation easier / better defined, I would suggest we add a dialect.type field that enables us to separate delimited, sql, workbook, structured. Then, like field types, this would form a discriminated union and dictate which properties would also be present in the dialect:

When "type" = "delimited", we could set delimiter, lineTerminator, etc.

When "type" = "sql", we could set table, etc.

When "type" = "workbook", we could set sheetNumber, sheetName, etc.

New formats could be added via new dialect types, in the same way new fields are added via new field types.

This would really help with declarative parsing systems (like pydantic, zod, etc.) by making illegal states unrepresentable.

It would also be 100% backwards compatible if we made "type" = "delimited" the default, when type was unset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants