In JsonScalarExpression and JsonQueryExpression, we currently have an initial $ path segment. While JSONPATH expressions do indeed start with $, that's a specific detail of JSONPATH, and therefore SQL generation; the expression itself shouldn't contain it. For example, PostgreSQL doesn't use JSONPATH at all to drill into JSON documents, and SQLite has a simplified non-JSONPATH syntax when there's only one path segment (e.g. `JsonColumn ->> 'foo').
In addition, we shouldn't produce empty Json{Scalar,Query}Expression (which we then ignore in SQL generation). The code creating these expressions should simply not create them when there's no path.
See #30745 (comment)