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

retire schema.normalizeForHash() & reuse schema.toInlineSchemaString() #7122

Open
shans opened this issue Apr 26, 2021 · 0 comments
Open

retire schema.normalizeForHash() & reuse schema.toInlineSchemaString() #7122

shans opened this issue Apr 26, 2021 · 0 comments

Comments

@shans
Copy link
Contributor

shans commented Apr 26, 2021

(from b/168267507)

The schema.normalizeForHash() method produces a string representation of a schema, used for generating a hash. It has two requirements:
(1) different schemas produce different strings
(2) different representations of the same schemas produce the same string

The second requirement basically requires that the fields of the schema (and any child schemas) be output in a defined order; we use lexicographic.

However, the first requirement in practice has not been met (e.g. see #6104).

Given that the manifest representation of schemas must meet the first requirement (this is the source of schemas, therefore it's not possible to have two different schemas with the same input string representation), it seems like we should switch to using this as the basis for hash generation instead.

In order to do so, we'd need to add an option for sorting the fields before outputting the string; but this doesn't seem particularly difficult.

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

No branches or pull requests

1 participant