-
Notifications
You must be signed in to change notification settings - Fork 55
fix: Ensure schema bytes #327
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -531,6 +531,37 @@ func getColumnInfo(arrowSchema *arrow.Schema, schema *cli_service.TTableSchema) | |
| return colInfos | ||
| } | ||
|
|
||
| // GetArrowSchemaBytes returns the Arrow schema bytes from result set metadata. | ||
| // If ArrowSchema is not directly available, it generates the bytes from TTableSchema. | ||
| func GetArrowSchemaBytes(resultSetMetadata *cli_service.TGetResultSetMetadataResp, cfg *config.Config, ctx context.Context) ([]byte, error) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. golang convention is have the context as the first param |
||
| if resultSetMetadata == nil { | ||
| return nil, nil | ||
| } | ||
|
|
||
| // If ArrowSchema is directly available, return it | ||
| if resultSetMetadata.ArrowSchema != nil { | ||
| return resultSetMetadata.ArrowSchema, nil | ||
| } | ||
|
|
||
| // Otherwise, generate from TTableSchema | ||
| if resultSetMetadata.Schema == nil { | ||
| return nil, nil | ||
| } | ||
|
|
||
| arrowConfig := cfg.ArrowConfig | ||
| arrowSchema, err := tTableSchemaToArrowSchema(resultSetMetadata.Schema, &arrowConfig) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| schemaBytes, err := getArrowSchemaBytes(arrowSchema, ctx) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| return schemaBytes, nil | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this function seems to duplicate a lot of logic from tGetResultSetMetadataRespToArrowSchema, can we not make this function a simpler wrapper function that calls tGetResultSetMetadataRespToArrowSchema? |
||
| } | ||
|
|
||
| // Derive an arrow.Schema object and the corresponding serialized bytes from TGetResultSetMetadataResp | ||
| func tGetResultSetMetadataRespToArrowSchema(resultSetMetadata *cli_service.TGetResultSetMetadataResp, arrowConfig config.ArrowConfig, ctx context.Context, logger *dbsqllog.DBSQLLogger) ([]byte, *arrow.Schema, dbsqlerr.DBError) { | ||
|
|
||
|
|
||
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.
we should add tests for this, for ex, to repro locally i used: