RFC: Transportation structured columns #184
Closed
brad-richardson
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
#203 is the current PR to rework segment with structured columns |
Beta Was this translation helpful? Give feedback.
2 replies
-
Closing as completed - see #203 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
As members have started consuming the transportation data, the segment
road
column has emerged as a consistent pain point.road
is currently a string column containing structured JSON. Although JSON has provided flexibility as we develop the schema, we think there might be a better way.We would love to get your feedback and field your questions on these proposed changes! See enumerated options we're considering at the end.
Goals
Proposed Changes
road
into separate, flattened columnsStructured Fields
Currently, the segment
road
column is a string used to store a JSON object. Here is the list of subproperties for this JSON:restrictions.speed_limits
restrictions.access
restrictions.prohibited_transitions
surface
flags
level
width
lanes
Storing this column as JSON introduces consumption challenges, including queries becoming harder to write and understand. Here’s an example query to answer "is access allowed for a given travel mode?":
If we have structured columns, the query could instead look like:
An additional challenge with JSON vs structured fields is that JSON must be parsed in its entirety and held in memory when used for filtering or joining. This will be less performant than having a strict column structure, which could be further improved by flattening the structure a bit, leading to our next topic…
Property Flattening
Some subproperties of the
road
are complex and deeply nested on their own. Here is whatroad.restrictions.speed_limits
(already three layers of nesting) might look like in a create table statement:We can remove a couple layers by flattening vehicle:
We could further flatten by removing the
when
structure, at some expense to readability (speed limit when heading backward vs speed limit heading backward):Options
Here is a list of options we're considering. The transportation task force is leaning towards 3) or 4), and we would like to take action on this soon, possibly for the June release.
Beta Was this translation helpful? Give feedback.
All reactions