Conversation
…back to matching on column names
…le type conversion
… to return an error
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as duplicate.
This comment was marked as duplicate.
zachmu
left a comment
There was a problem hiding this comment.
Overall this looks great, nice work.
There are probably things we haven't thought of but the tests look good enough for an initial release.
| } | ||
|
|
||
| // Load the overridden schema and convert it to a sql.Schema | ||
| overriddenSchema, err := t.GetSchema(ctx) |
There was a problem hiding this comment.
These GetSchema calls are very expensive and will give you a performance hit when customers use this feature. They're the main reason we have caching in getTable(). Because we cache based on root values, you can just reuse the same cache here as well, and it should help a lot. Probably fine to check in this way as is, but you should do a pass on perf.
| if !ok { | ||
| return fmt.Errorf("unable to find table '%s' at overridden schema root", tableName) | ||
| } | ||
| overriddenSchema, err := overriddenTable.GetSchema(ctx) |
| // set value by testing against nil. | ||
| func getOverriddenSchemaValue(ctx *sql.Context) (*string, error) { | ||
| doltSession := dsess.DSessFromSess(ctx.Session) | ||
| varValue, err := doltSession.GetSessionVariable(ctx, dsess.DoltOverrideSchema) |
There was a problem hiding this comment.
These session variable lookups are kind of expensive as well, you might be surprised. I recommend profiling this after you get everything checked in.
Check out DoltSession.dbdbSessionVarsStale() to see where I added some caching for this interaction the last time I was working on session code.
…ides for other queries
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
|
@coffeegoddd DOLT
|
Allows customers to specify a commit, branch, or tag in the
@@dolt_schema_override_commitsession variable and have all table's data mapped to the schema from that commit, branch, or tag, when queried.Example
As a simple example, consider a database with a
mainbranch that has added the new columnbirthdayto a table, and anolderBranchbranch with a table that has not been updated with that schema change. Customers cannot use the same queries from themainbranch to query the data on theolderBranchbecause of the schema difference. Setting a schema override allows the customer to map the table schemas on theolderBranchbranch to the same schema as on themainbranch. This can be useful when you want to run queries on older data, but don't want to rewrite your queries for older schemas.Limitations
The first version of schema override support is subject to several limitations. Please reach out to us and let us know if you'd like any of these to be prioritized.
NULLis a planned enhancement.Design doc
Reference docs update: dolthub/docs#2062
Fixes: #5486