Skip to content

feat: Implement asynchronous getSchemas method and prepare for not querying schemas and server information on initialization #124

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

Merged
merged 11 commits into from
Jun 28, 2023

Conversation

jimmycallin
Copy link
Contributor

@jimmycallin jimmycallin commented Jun 19, 2023

  • I have added automatic tests where applicable
  • The PR title is suitable as a release note
  • The PR contains a description of what has been changed
  • The description contains manual test instructions

Changes

Longterm, to reduce initial session initialization time, we want to move away from having to call the query_schemas and query_server_information on initialization, and move it to being called lazily whenever asynchronous methods session.getSchemas or session.getServerInformation are called.

This PR sets up these methods, and make some additional changes to make the future breaking change as easy as possible.

Test

Make sure the methods work as intended, and haven't introduced any breaking changes.

@jimmycallin jimmycallin requested a review from a team as a code owner June 19, 2023 09:11
@jimmycallin jimmycallin changed the title feat/get schemas feat: implement asynchronous getSchemas method and prepare for not querying schemas and server information on initialization Jun 19, 2023
@jimmycallin jimmycallin changed the title feat: implement asynchronous getSchemas method and prepare for not querying schemas and server information on initialization feat: Implement asynchronous getSchemas method and prepare for not querying schemas and server information on initialization Jun 19, 2023
Copy link
Contributor

@lucaas lucaas left a comment

Choose a reason for hiding this comment

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

It looks like we might to run into problems with some usage. The schemas are currently being used to decode the server response (for the de-duplication functionality).

call -> decode -> _mergeEntity -> getIdentifyingKey -> getPrimaryKeyAttributes -> this.schemas

There is also a subtle change in default values that might be better to hold off on until we do a new major.

@@ -83,7 +87,7 @@ export class Session {
apiKey: string,
{
autoConnectEventHub = false,
serverInformationValues,
serverInformationValues = [],
Copy link
Contributor

Choose a reason for hiding this comment

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

This is potentially a breaking change.

Previously, this would mean - use the defaults from the server.

if values is None:
    values = [
        'schema_hash',
        'storage_scenario',
        'is_timezone_support_enabled'
    ]

Maybe leave this for a major?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, good catch

@@ -688,6 +752,7 @@ export class Session {
* @return {Object|null} Schema definition
*/
getSchema(schemaId: string): Schema | null {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to move the transformation from array to map from data utils here so that it can be re-used by e.g. this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we do, would it be as a private attribute? I don't think I want to expand the scope of the api client and make it diverge from the python api more than necessary?

Copy link
Contributor

Choose a reason for hiding this comment

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

The map itself, sure. Could you still replace all it's usage in data-utils by this getSchema method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have now implemented the map. since it's not public, we have to still do the same mapping in the frontend codebase, so no change is necessary. please review.

@jimmycallin
Copy link
Contributor Author

It looks like we might to run into problems with some usage. The schemas are currently being used to decode the server response (for the de-duplication functionality).

call -> decode -> _mergeEntity -> getIdentifyingKey -> getPrimaryKeyAttributes -> this.schemas

As long as we are doing the deduplication, we will have to load schemas for each query, unfortunately, yes. This change does not affect that functionality, since we are still loading schema on initialization, but it would be nice to continue moving towards fixing that server side so we can remove this in a coming major version as well.

@jimmycallin jimmycallin merged commit 950638f into main Jun 28, 2023
@jimmycallin jimmycallin deleted the feat/get-schemas branch June 28, 2023 10:29
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.

3 participants