It has to do with the nature of SQL++ and structured data as compared to traditional SQL and flat data.
When you’re joining multiple extents such as this:
SELECT * FROM profile INNER JOIN user ON user.id = profile.userId
Then each extent is returned in the query rows array nested based on its name:
[
{
"profile": { "userId": 1, email: "user@gmail.com" },
"user": { "id": 1, name: "User" }
},
{
"profile": { "userId": 2, email: "user2@gmail.com" },
"user": { "id": 2, name: "User2" }
}
]
For consistency, this same rule applies to queries that only have a single extent, such as yours. So your original query output would be something like this:
[
{
"profile": {
"accountIds": "Bhdsfdsfds",
"updatedAt": "2024-04-16T23:41:24.0967139Z",
"createdAt": "2024-04-16T23:41:24.0967682Z",
"rvn": 0,
"accountId": "sssssss",
"type": "profile_main"
}
}
]
By using profile.*
in the projection instead of *
you’re requesting the attributes from the specific profile
extent of the query, rather than requesting all extents, so it will return unnested:
[
{
"accountIds": "Bhdsfdsfds",
"updatedAt": "2024-04-16T23:41:24.0967139Z",
"createdAt": "2024-04-16T23:41:24.0967682Z",
"rvn": 0,
"accountId": "sssssss",
"type": "profile_main"
}
]