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

Show SQL names instead of primitive types in catalog #84

Merged
merged 1 commit into from
May 9, 2023
Merged

Conversation

jbeisen
Copy link
Collaborator

@jbeisen jbeisen commented Apr 27, 2023

Define a mapping of primitive types to SQL types. Add a field 'sql_name' to the SourceFieldType message, and populate it for primitive types. Display this value in the catalog.

Resolves: #73


image

arroyo-api/src/sources.rs Outdated Show resolved Hide resolved
arroyo-api/src/sources.rs Outdated Show resolved Hide resolved
arroyo-api/src/sources.rs Outdated Show resolved Hide resolved
@@ -329,7 +344,7 @@ impl TryFrom<SchemaField> for SourceField {
type Error = String;

fn try_from(value: SchemaField) -> Result<Self, Self::Error> {
let typ = match value.typ {
let typ = match value.clone().typ {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The clone is not necessary, just need to take a reference to value.typ instead of taking it by value

Suggested change
let typ = match value.clone().typ {
let typ = match &value.typ {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do that then we get this error:

error[E0277]: the trait bound `SourceField: From<&SchemaField>` is not satisfied
   --> arroyo-api/src/sources.rs:365:43
    |
365 |                         .filter_map(|f| f.try_into().ok())
    |                                           ^^^^^^^^ the trait `From<&SchemaField>` is not implemented for `SourceField`
    |
    = note: required for `&SchemaField` to implement `Into<SourceField>`
    = note: required for `SourceField` to implement `TryFrom<&SchemaField>`
    = note: required for `&SchemaField` to implement `TryInto<SourceField>`

Should I implement those functions?

Copy link
Member

@mwylde mwylde Apr 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You would still need to clone that (as you try_into() is implemented on the owned type) but it's preferable to cloning the entire struct. It's not a huge deal here (as this isn't performance-sensitive code), and eager cloning can make rust development easier.

Define a mapping of primitive types to SQL types. Add a field 'sql_name'
to the SourceFieldType message, and populate it for primitive types.
Display this value in the catalog.

Resolves: #73
@jbeisen jbeisen merged commit 35c46d5 into master May 9, 2023
@jbeisen jbeisen deleted the sql-types branch May 9, 2023 09:27
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.

Catalog in web ui should show SQL types to the user
3 participants