-
Notifications
You must be signed in to change notification settings - Fork 67
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
casting complex type is order dependent when docs say different #5168
Comments
@chrismo: Actually, I think the middle example is behaving in a way that's aligned with the docs, though your experience shows there's room for improvement. Let's start from the base of your middle example.
So that
That's is in line with where the
What's implied here (but should likely be called out explicitly) is that the order of such added fields is undefined. There's a separate
Putting
...does line up with what you quoted from the
i.e., Ultimately, it's good that you found your way to @chrismo: Before I put pen to paper on those changes, do you have any feedback on the above? |
The added note sounds good. I feel like I'm still interpreting the cast docs on "order independent" to mean the order is not important for cast to work, so maybe it should say the "field order must match the ordering in the declared type" for cast to work in that part? What do you think about that wording? |
@chrismo: Hmm! I'm not sure where the remaining confusion lies, since it still matches what I think of as "order independent". Let me cook up a slightly simpler example, since the prior examples used
So that's in line with your interpretation that "the order is not important for cast to work", i.e., even though Any clearer? 😄 |
Ahhhh! So you're saying the cast was successful in this case, too, because the two fields in the record were cast to their appropriate types:
But it can't cast the entire record to |
@chrismo and I further discussed this online. I now understand that what made this most confusing was that in his middle example:
...the final output record lacked the The shaping functions are due for some revision (#2342), so I'll keep this issue open to make sure this is considered in that effort. |
The cast docs mention:
The middle example shows that the casting fails (returns the original input) because the order of fields isn't correct, but the docs say that "fields are matched by name and are order independent".
As a result of looking for similar issues, I discovered the
shape
function, which is what I can use going forward and not be impacted by this.The text was updated successfully, but these errors were encountered: