Skip to content

stash: switch serialization to JSON - #14298

Merged
madelynnblue merged 2 commits into
MaterializeInc:mainfrom
madelynnblue:stash-json
Aug 24, 2022
Merged

madelynnblue merged 2 commits into
MaterializeInc:mainfrom
madelynnblue:stash-json

Conversation

@madelynnblue

Copy link
Copy Markdown
Contributor

This makes introspection in the backing cockroach databases possible with merely a SQL connection. This PR contains no migration code and must not be merged until there is migration code (which would be added as another commit into this PR) or we have another flag day where we start all instances over from scratch (in which case this PR can be merged as is).

Motivation

Checklist

@madelynnblue

Copy link
Copy Markdown
Contributor Author
root@:26257/defaultdb> select key, value->'definition'->'V1'->'create_sql' from adapter.data where value->'definition' is not null;
          key          |                                               ?column?
-----------------------+-------------------------------------------------------------------------------------------------------
  {"gid": {"User": 1}} | "CREATE TABLE \\"materialize\\".\\"public\\".\\"t\\" (\\"i\\" [s19 AS \\"pg_catalog\\".\\"int4\\"])"

@madelynnblue
madelynnblue marked this pull request as ready for review August 24, 2022 02:32
@madelynnblue
madelynnblue requested a review from jkosh44 August 24, 2022 02:32

@jkosh44 jkosh44 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, I had a couple of questions and one small comment. I'd also be very interested in a performance comparison of using JSON vs Protobuf.

Comment thread src/adapter/src/catalog.rs Resolved
Comment thread src/stash/src/lib.rs Resolved
Comment thread src/stash/src/postgres.rs Resolved
This removes protobuf for JSON. While JSON is easier to introspect in
the backing store, it is also easier to incorrectly migrate. However, we
were already using prost derives, which are equally unsafe against
migrations as JSON.
A few types were manually serialized to strings or byte arrays. Switch
all of those to their existing JSON types, making them completely
queryable in their backing data store.
@madelynnblue
madelynnblue merged commit e121eda into MaterializeInc:main Aug 24, 2022
@madelynnblue
madelynnblue deleted the stash-json branch August 24, 2022 16:31
@madelynnblue

Copy link
Copy Markdown
Contributor Author

Didn't run benchmarks. Might later, but not a priority now.

def- added a commit to def-/materialize that referenced this pull request Nov 21, 2026
The byte (de)serialization helpers, the VersionedStorageUsage accessors
and From<bool> for SchedulingDecisionV1 have no callers left, and
deserialize was the library's only use of anyhow. This deletes 46 lines
of uncalled code and one dependency, and cargo check --all-targets of
mz-audit-log, mz-catalog, mz-sql and mz-adapter still passes. The
helpers lost their last callers in MaterializeInc#14298, MaterializeInc#29127 and MaterializeInc#38101.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Ca97tqbjzmJpgDjc4QXDyG
def- added a commit to def-/materialize that referenced this pull request Nov 23, 2026
The byte (de)serialization helpers, the VersionedStorageUsage accessors
and From<bool> for SchedulingDecisionV1 have no callers left, and
deserialize was the library's only use of anyhow. This deletes 46 lines
of uncalled code and one dependency, and cargo check --all-targets of
mz-audit-log, mz-catalog, mz-sql and mz-adapter still passes. The
helpers lost their last callers in MaterializeInc#14298, MaterializeInc#29127 and MaterializeInc#38101.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.

2 participants